[Openmp-commits] [openmp] 073d019 - [OpenMP] Use the standard fences now that they are supported (#187138)

via Openmp-commits openmp-commits at lists.llvm.org
Wed Mar 18 06:42:13 PDT 2026


Author: Joseph Huber
Date: 2026-03-18T08:42:07-05:00
New Revision: 073d019c450da7948a23ae240bfc6388971a8f25

URL: https://github.com/llvm/llvm-project/commit/073d019c450da7948a23ae240bfc6388971a8f25
DIFF: https://github.com/llvm/llvm-project/commit/073d019c450da7948a23ae240bfc6388971a8f25.diff

LOG: [OpenMP] Use the standard fences now that they are supported (#187138)

Summary:
We can now use these on NVPTX properly.

Added: 
    

Modified: 
    openmp/device/include/Synchronization.h

Removed: 
    


################################################################################
diff  --git a/openmp/device/include/Synchronization.h b/openmp/device/include/Synchronization.h
index f164a55e46a12..3ab4f680739a0 100644
--- a/openmp/device/include/Synchronization.h
+++ b/openmp/device/include/Synchronization.h
@@ -62,11 +62,7 @@ V add(Ty *Address, V Val, atomic::OrderingTy Ordering,
 template <typename Ty, typename V = utils::remove_addrspace_t<Ty>>
 V load(Ty *Address, atomic::OrderingTy Ordering,
        MemScopeTy MemScope = MemScopeTy::device) {
-#ifdef __NVPTX__
-  return __scoped_atomic_fetch_add(Address, V(0), Ordering, MemScope);
-#else
   return __scoped_atomic_load_n(Address, Ordering, MemScope);
-#endif
 }
 
 template <typename Ty, typename V = utils::remove_addrspace_t<Ty>>
@@ -179,34 +175,21 @@ atomicExchange(uint32_t *Address, uint32_t Val, atomic::OrderingTy Ordering,
 
 } // namespace atomic
 
-// FIXME: NVPTX does not respect the memory scope argument.
 namespace fence {
 
 /// Memory fence with \p Ordering semantics for the team.
 static inline void team(atomic::OrderingTy Ordering) {
-#ifdef __NVPTX__
-  __nvvm_membar_cta();
-#else
   __scoped_atomic_thread_fence(Ordering, atomic::workgroup);
-#endif
 }
 
 /// Memory fence with \p Ordering semantics for the contention group.
 static inline void kernel(atomic::OrderingTy Ordering) {
-#ifdef __NVPTX__
-  __nvvm_membar_gl();
-#else
   __scoped_atomic_thread_fence(Ordering, atomic::device);
-#endif
 }
 
 /// Memory fence with \p Ordering semantics for the system.
 static inline void system(atomic::OrderingTy Ordering) {
-#ifdef __NVPTX__
-  __nvvm_membar_sys();
-#else
   __scoped_atomic_thread_fence(Ordering, atomic::system);
-#endif
 }
 
 } // namespace fence


        


More information about the Openmp-commits mailing list