@@ -72,6 +72,8 @@ EXTERN uint64_t __lanemask_lt();
72
72
// thread's lane number in the warp
73
73
EXTERN uint64_t __lanemask_gt ();
74
74
75
+ EXTERN void llvm_amdgcn_s_barrier ();
76
+
75
77
// CU id
76
78
EXTERN unsigned __smid ();
77
79
@@ -99,21 +101,25 @@ INLINE uint32_t __kmpc_impl_smid() {
99
101
return __smid ();
100
102
}
101
103
102
- INLINE uint64_t __kmpc_impl_ffs (uint64_t x ) { return __builtin_ffsl (x ); }
104
+ INLINE uint64_t __kmpc_impl_ffs (uint64_t x ) { return __ffsll (x ); }
103
105
104
- INLINE uint64_t __kmpc_impl_popc (uint64_t x ) { return __builtin_popcountl (x ); }
106
+ INLINE uint64_t __kmpc_impl_popc (uint64_t x ) { return __popcll (x ); }
105
107
106
108
INLINE __kmpc_impl_lanemask_t __kmpc_impl_activemask () {
107
109
return __ballot64 (1 );
108
110
}
109
111
110
- EXTERN int32_t __kmpc_impl_shfl_sync (__kmpc_impl_lanemask_t , int32_t Var ,
111
- int32_t SrcLane );
112
+ INLINE int32_t __kmpc_impl_shfl_sync (__kmpc_impl_lanemask_t , int32_t Var ,
113
+ int32_t SrcLane ) {
114
+ return __shfl (Var , SrcLane , WARPSIZE );
115
+ }
112
116
113
- EXTERN int32_t __kmpc_impl_shfl_down_sync (__kmpc_impl_lanemask_t , int32_t Var ,
114
- uint32_t Delta , int32_t Width );
117
+ INLINE int32_t __kmpc_impl_shfl_down_sync (__kmpc_impl_lanemask_t , int32_t Var ,
118
+ uint32_t Delta , int32_t Width ) {
119
+ return __shfl_down (Var , Delta , Width );
120
+ }
115
121
116
- INLINE void __kmpc_impl_syncthreads () { __builtin_amdgcn_s_barrier (); }
122
+ INLINE void __kmpc_impl_syncthreads () { llvm_amdgcn_s_barrier (); }
117
123
118
124
INLINE void __kmpc_impl_named_sync (int barrier , uint32_t num_threads ) {
119
125
// we have protected the master warp from releasing from its barrier
@@ -122,15 +128,4 @@ INLINE void __kmpc_impl_named_sync(int barrier, uint32_t num_threads) {
122
128
__builtin_amdgcn_s_barrier ();
123
129
}
124
130
125
- // DEVICE versions of part of libc
126
- extern "C" {
127
- DEVICE __attribute__((noreturn )) void
128
- __assertfail (const char * , const char * , unsigned , const char * , size_t );
129
- INLINE static void __assert_fail (const char * __message , const char * __file ,
130
- unsigned int __line , const char * __function ) {
131
- __assertfail (__message , __file , __line , __function , sizeof (char ));
132
- }
133
- DEVICE int printf (const char * , ...);
134
- }
135
-
136
131
#endif
0 commit comments