Skip to content

Commit c50610b

Browse files
authored
Add __syncwarp operation (#160)
Change-Id: I6a3783beafdbb9f11a3b37333f4ff3f5be27ea54
1 parent 32eb6a5 commit c50610b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

hipamd/include/hip/amd_detail/amd_warp_sync_functions.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,20 @@ T __hip_readfirstlane(T val) {
164164
} \
165165
} while(0)
166166

167+
__device__ inline void __syncwarp() {
168+
__builtin_amdgcn_fence(__ATOMIC_RELEASE, "wavefront");
169+
__builtin_amdgcn_wave_barrier();
170+
__builtin_amdgcn_fence(__ATOMIC_ACQUIRE, "wavefront");
171+
}
172+
173+
template <typename MaskT> __device__ inline void __syncwarp(MaskT mask) {
174+
static_assert(__hip_internal::is_integral<MaskT>::value && sizeof(MaskT) == 8,
175+
"The mask must be a 64-bit integer. "
176+
"Implicitly promoting a smaller integer is almost always an error.");
177+
__hip_check_mask(mask);
178+
return __syncwarp();
179+
}
180+
167181
// __all_sync, __any_sync, __ballot_sync
168182

169183
template <typename MaskT>

0 commit comments

Comments
 (0)