[Openmp-commits] [clang] [openmp] [OFFLOAD] Build DeviceRTL with SPIRV backend (PR #174675)

via Openmp-commits openmp-commits at lists.llvm.org
Fri Jan 9 16:50:28 PST 2026


================
@@ -258,6 +258,80 @@ void setCriticalLock(omp_lock_t *Lock) { setLock(Lock); }
 #endif
 ///}
 
+#if defined(__SPIRV__)
+
+MemorySemantics_t convertOrderingType(atomic::OrderingTy Ordering) {
+  switch (Ordering) {
+  default:
+    __builtin_unreachable();
+  case atomic::relaxed:
+    return MemorySemantics_t::Relaxed;
+  case atomic::acquire:
+    return MemorySemantics_t::Acquire;
+  case atomic::release:
+    return MemorySemantics_t::Release;
+  case atomic::acq_rel:
+    return MemorySemantics_t::AcquireRelease;
+  case atomic::seq_cst:
+    return MemorySemantics_t::SequentiallyConsistent;
+  }
+}
+uint32_t atomicInc(uint32_t *Address, uint32_t Val, atomic::OrderingTy Ordering,
+                   atomic::MemScopeTy MemScope) {
+  return __spirv_AtomicIAdd(Address, (int)MemScope,
+                            convertOrderingType(Ordering), Val);
----------------
fineg74 wrote:

I believe I used am incorrect API for that so implemented it using existing API 

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


More information about the Openmp-commits mailing list