[llvm] [AMDGPU] Use wavefront scope for single-wave workgroup synchronization (PR #187673)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 1 04:28:21 PDT 2026


================
@@ -165,6 +166,19 @@ class SIMemOpInfo final {
     // AGENT scope as a conservatively correct alternative.
     if (this->Scope == SIAtomicScope::CLUSTER && !ST.hasClusters())
       this->Scope = SIAtomicScope::AGENT;
+
+    // When max flat work-group size is at most the wavefront size, the
+    // work-group fits in a single wave, so LLVM workgroup scope matches
+    // wavefront scope. Demote workgroup → wavefront here for fences and for
+    // atomics with ordering stronger than monotonic.
+    if (ScopeDemotionFn && this->Scope == SIAtomicScope::WORKGROUP &&
+        (llvm::isStrongerThan(this->Ordering, AtomicOrdering::Monotonic) ||
+         llvm::isStrongerThan(this->FailureOrdering,
+                              AtomicOrdering::Monotonic)) &&
+        ST.getFlatWorkGroupSizes(*ScopeDemotionFn).second <=
----------------
arsenm wrote:

Also shouldn't call this every time you encounter a fence 

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


More information about the llvm-commits mailing list