Skip to content

Conversation

@llvmbot
Copy link
Member

@llvmbot llvmbot commented May 6, 2025

Backport dfcb8cb

Requested by: @ye-luo

@llvmbot
Copy link
Member Author

llvmbot commented May 6, 2025

@shiltian What do you think about merging this PR to the release branch?

@llvmbot
Copy link
Member Author

llvmbot commented May 6, 2025

@llvm/pr-subscribers-offload

Author: None (llvmbot)

Changes

Backport dfcb8cb

Requested by: @ye-luo


Full diff: https://github.com/llvm/llvm-project/pull/138626.diff

1 Files Affected:

  • (modified) offload/DeviceRTL/include/Synchronization.h (+4)
diff --git a/offload/DeviceRTL/include/Synchronization.h b/offload/DeviceRTL/include/Synchronization.h
index 5a789441b9d35..c510fbf0774c2 100644
--- a/offload/DeviceRTL/include/Synchronization.h
+++ b/offload/DeviceRTL/include/Synchronization.h
@@ -61,7 +61,11 @@ 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>>

@ye-luo
Copy link
Contributor

ye-luo commented May 6, 2025

I manually verified the effectiveness of this patch on 20.x release branch.

Copy link
Contributor

@shiltian shiltian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-project-automation github-project-automation bot moved this from Needs Triage to Needs Merge in LLVM Release Status May 6, 2025
Summary:
Different ordering modes aren't supported for an atomic load, so we just
do an add of zero as the same thing. It's less efficient, but it works.

Fixes llvm#138560

(cherry picked from commit dfcb8cb)
@tstellar tstellar merged commit 961ce35 into llvm:release/20.x May 9, 2025
6 of 8 checks passed
@github-project-automation github-project-automation bot moved this from Needs Merge to Done in LLVM Release Status May 9, 2025
@github-actions
Copy link

github-actions bot commented May 9, 2025

@ye-luo (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Development

Successfully merging this pull request may close these issues.

5 participants