Index: openmp/trunk/libomptarget/deviceRTLs/nvptx/src/data_sharing.cu =================================================================== --- openmp/trunk/libomptarget/deviceRTLs/nvptx/src/data_sharing.cu +++ openmp/trunk/libomptarget/deviceRTLs/nvptx/src/data_sharing.cu @@ -553,8 +553,7 @@ if (GetThreadIdInBlock() == 0) { *frame = omptarget_nvptx_simpleMemoryManager.Acquire(buf, size); } - // FIXME: use __syncthreads instead when the function copy is fixed in LLVM. - __SYNCTHREADS(); + __kmpc_impl_syncthreads(); return; } ASSERT0(LT_FUSSY, GetThreadIdInBlock() == GetMasterThreadID(), @@ -568,8 +567,7 @@ if (is_shared) return; if (isSPMDExecutionMode) { - // FIXME: use __syncthreads instead when the function copy is fixed in LLVM. - __SYNCTHREADS(); + __kmpc_impl_syncthreads(); if (GetThreadIdInBlock() == 0) { omptarget_nvptx_simpleMemoryManager.Release(); } Index: openmp/trunk/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.h =================================================================== --- openmp/trunk/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.h +++ openmp/trunk/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.h @@ -56,14 +56,6 @@ #define __ACTIVEMASK() __ballot(1) #endif // CUDA_VERSION -#define __SYNCTHREADS_N(n) asm volatile("bar.sync %0;" : : "r"(n) : "memory"); -// Use original __syncthreads if compiled by nvcc or clang >= 9.0. -#if !defined(__clang__) || __clang_major__ >= 9 -#define __SYNCTHREADS() __syncthreads() -#else -#define __SYNCTHREADS() __SYNCTHREADS_N(0) -#endif - // arguments needed for L0 parallelism only. class omptarget_nvptx_SharedArgs { public: Index: openmp/trunk/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.cu =================================================================== --- openmp/trunk/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.cu +++ openmp/trunk/libomptarget/deviceRTLs/nvptx/src/omptarget-nvptx.cu @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// #include "omptarget-nvptx.h" +#include "target_impl.h" //////////////////////////////////////////////////////////////////////////////// // global data tables @@ -106,7 +107,7 @@ } if (!RequiresOMPRuntime) { // Runtime is not required - exit. - __SYNCTHREADS(); + __kmpc_impl_syncthreads(); return; } @@ -125,8 +126,7 @@ // init team context currTeamDescr.InitTeamDescr(); } - // FIXME: use __syncthreads instead when the function copy is fixed in LLVM. - __SYNCTHREADS(); + __kmpc_impl_syncthreads(); omptarget_nvptx_TeamDescr &currTeamDescr = getMyTeamDescriptor(); omptarget_nvptx_WorkDescr &workDescr = getMyWorkDescriptor(); @@ -168,8 +168,7 @@ if (!RequiresOMPRuntime) return; - // FIXME: use __syncthreads instead when the function copy is fixed in LLVM. - __SYNCTHREADS(); + __kmpc_impl_syncthreads(); int threadId = GetThreadIdInBlock(); if (threadId == 0) { // Enqueue omp state object for use by another team. Index: openmp/trunk/libomptarget/deviceRTLs/nvptx/src/sync.cu =================================================================== --- openmp/trunk/libomptarget/deviceRTLs/nvptx/src/sync.cu +++ openmp/trunk/libomptarget/deviceRTLs/nvptx/src/sync.cu @@ -75,8 +75,7 @@ // parallel region and that all worker threads participate. EXTERN void __kmpc_barrier_simple_spmd(kmp_Ident *loc_ref, int32_t tid) { PRINT0(LD_SYNC, "call kmpc_barrier_simple_spmd\n"); - // FIXME: use __syncthreads instead when the function copy is fixed in LLVM. - __SYNCTHREADS(); + __kmpc_impl_syncthreads(); PRINT0(LD_SYNC, "completed kmpc_barrier_simple_spmd\n"); } Index: openmp/trunk/libomptarget/deviceRTLs/nvptx/src/target_impl.h =================================================================== --- openmp/trunk/libomptarget/deviceRTLs/nvptx/src/target_impl.h +++ openmp/trunk/libomptarget/deviceRTLs/nvptx/src/target_impl.h @@ -63,6 +63,15 @@ #endif // CUDA_VERSION } +INLINE void __kmpc_impl_syncthreads() { + // Use original __syncthreads if compiled by nvcc or clang >= 9.0. +#if !defined(__clang__) || __clang_major__ >= 9 + __syncthreads(); +#else + asm volatile("bar.sync %0;" : : "r"(0) : "memory"); +#endif // __clang__ +} + INLINE void __kmpc_impl_syncwarp(__kmpc_impl_lanemask_t Mask) { #if CUDA_VERSION >= 9000 __syncwarp(Mask);