[Openmp-commits] [openmp] [OpenMP] Cleanup synchronization primitives (PR #177710)

Shilei Tian via Openmp-commits openmp-commits at lists.llvm.org
Fri Jan 23 16:50:40 PST 2026


================
@@ -210,16 +216,35 @@ threadsAligned(atomic::OrderingTy Ordering);
 
 } // namespace synchronize
 
+// FIXME: NVPTX does not respect the memory scope argument.
 namespace fence {
 
 /// Memory fence with \p Ordering semantics for the team.
-void team(atomic::OrderingTy Ordering);
+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.
-void kernel(atomic::OrderingTy Ordering);
+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.
-void system(atomic::OrderingTy Ordering);
+static inline void system(atomic::OrderingTy Ordering) {
+#ifdef __NVPTX__
+  __nvvm_membar_sys();
+#else
+  __scoped_atomic_thread_fence(Ordering, atomic::system);
----------------
shiltian wrote:

thse builtins are not gonna be lowered on nvptx?

https://github.com/llvm/llvm-project/pull/177710


More information about the Openmp-commits mailing list