Skip to content

[libc] Update fence to use scoped fence now that it's supported #119018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions libc/src/__support/CPP/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,12 @@ template <typename T> struct Atomic {
};

// Issue a thread fence with the given memory ordering.
LIBC_INLINE void atomic_thread_fence([[maybe_unused]] MemoryOrder mem_ord) {
// The NVPTX backend currently does not support atomic thread fences so we use a
// full system fence instead.
#ifdef LIBC_TARGET_ARCH_IS_NVPTX
__nvvm_membar_sys();
LIBC_INLINE void atomic_thread_fence(
MemoryOrder mem_ord,
[[maybe_unused]] MemoryScope mem_scope = MemoryScope::DEVICE) {
#if __has_builtin(__scoped_atomic_thread_fence)
__scoped_atomic_thread_fence(static_cast<int>(mem_ord),
static_cast<int>(mem_scope));
#else
__atomic_thread_fence(static_cast<int>(mem_ord));
#endif
Expand Down
Loading