@@ -20,8 +20,8 @@ pub use packed::*;
20
20
21
21
#[ allow( improper_ctypes) ]
22
22
unsafe extern "C" {
23
- #[ link_name = "llvm.nvvm.barrier0 " ]
24
- fn syncthreads ( ) -> ( ) ;
23
+ #[ link_name = "llvm.nvvm.barrier.sync " ]
24
+ fn barrier_sync ( _ : u32 ) -> ( ) ;
25
25
#[ link_name = "llvm.nvvm.read.ptx.sreg.ntid.x" ]
26
26
fn block_dim_x ( ) -> i32 ;
27
27
#[ link_name = "llvm.nvvm.read.ptx.sreg.ntid.y" ]
@@ -49,10 +49,52 @@ unsafe extern "C" {
49
49
}
50
50
51
51
/// Synchronizes all threads in the block.
52
+ ///
53
+ /// The argument `a` is a logical barrier resource with value `0` through `15`.
54
+ ///
55
+ /// This does not require textual alignment, so the following code is valid.
56
+ ///
57
+ /// ```
58
+ /// if tid % 2 == 0 {
59
+ /// shared[tid] *= 2;
60
+ /// _barrier_sync(0);
61
+ /// myval += shared[tid + 1];
62
+ /// } else {
63
+ /// shared[tid] *= 4;
64
+ /// _barrier_sync(0);
65
+ /// }
66
+ /// ```
67
+ ///
68
+ /// This intrinsic has different execution semantics prior to `sm_70`, and thus
69
+ /// it requires the `sm_70` target feature for correct behavior. The instruction
70
+ /// was introduced in PTX 6.0, so its use has a compile-time dependency on the
71
+ /// `ptx60` target feature.
72
+ ///
73
+ /// TODO: The more restrictive "aligned" semantics of
74
+ /// `llvm.nvvm.barrier.sync.aligned` are [currently
75
+ /// miscompiled](https://github.com/rust-lang/rust/issues/137086) due to MIR
76
+ /// JumpThreading and lack of `convergent` attribute propagated to LLVM. Once
77
+ /// resolved, a `_barrier_sync_aligned` intrinsic can be exposed at all target
78
+ /// features.
79
+ ///
80
+ #[ inline]
81
+ #[ cfg( target_feature = "ptx60" ) ]
82
+ #[ target_feature( enable = "sm_70" , enable = "ptx60" ) ]
83
+ #[ unstable( feature = "stdarch_nvptx" , issue = "111199" ) ]
84
+ pub unsafe fn _barrier_sync ( a : u32 ) -> ( ) {
85
+ barrier_sync ( a)
86
+ }
87
+
88
+ /// Synchronizes all threads in the block.
89
+ ///
90
+ /// Deprecated alias for [`_barrier_sync`].
52
91
#[ inline]
92
+ #[ cfg( target_feature = "ptx60" ) ]
93
+ #[ target_feature( enable = "sm_70" , enable = "ptx60" ) ]
53
94
#[ unstable( feature = "stdarch_nvptx" , issue = "111199" ) ]
95
+ #[ deprecated( since = "1.88.0" , note = "use _barrier_sync(0)" ) ]
54
96
pub unsafe fn _syncthreads ( ) -> ( ) {
55
- syncthreads ( )
97
+ _barrier_sync ( 0 )
56
98
}
57
99
58
100
/// x-th thread-block dimension.
0 commit comments