@@ -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" ]
@@ -48,11 +48,46 @@ unsafe extern "C" {
48
48
fn thread_idx_z ( ) -> i32 ;
49
49
}
50
50
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.
70
+ ///
71
+ /// TODO: The more restrictive "aligned" semantics of
72
+ /// `llvm.nvvm.barrier.sync.aligned` are [currently
73
+ /// miscompiled](https://github.com/rust-lang/rust/issues/137086) due to MIR
74
+ /// JumpThreading and lack of `convergent` attribute propagated to LLVM. Once
75
+ /// resolved, this intrinsic should be exposed at all target features
76
+ ///
77
+ #[ inline]
78
+ #[ target_feature( enable = "sm_70" ) ]
79
+ #[ unstable( feature = "stdarch_nvptx" , issue = "111199" ) ]
80
+ pub unsafe fn _barrier_sync ( a : u32 ) -> ( ) {
81
+ barrier_sync ( a)
82
+ }
83
+
51
84
/// Synchronizes all threads in the block.
52
85
#[ inline]
86
+ #[ target_feature( enable = "sm_70" ) ]
53
87
#[ unstable( feature = "stdarch_nvptx" , issue = "111199" ) ]
88
+ #[ deprecated( since = "1.87.0" , note = "use _barrier_sync(0)" ) ]
54
89
pub unsafe fn _syncthreads ( ) -> ( ) {
55
- syncthreads ( )
90
+ _barrier_sync ( 0 )
56
91
}
57
92
58
93
/// x-th thread-block dimension.
0 commit comments