Repository navigation
always use std::atomic; stop preferring cuda::std::atomic (#2042) - #2601
Merged
Merged
Conversation
__atomic.hpp switched the whole of STDEXEC::__std's atomics to cuda::std::atomic whenever <cuda/std/atomic> was merely installed. On Windows cuda::std::atomic<T>::wait polls instead of using WaitOnAddress, so sync_wait latency was ~15 ms instead of ~6 us. Nothing needs it: nvexec spells ::cuda::std::atomic_flag and ::cuda::atomic_ref<..., thread_scope_*> itself, and its host-side shared state already uses std::atomic. test.nvexec builds and passes (136 cases) with nvcc 13.5 and nvc++ 26.11 with std::atomic used unconditionally. Remove STDEXEC_HAS_CUDA_STD_ATOMIC and STDEXEC_DISABLE_CUDA_STD_ATOMIC; Relacy no longer needs the opt-out. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2042.
__atomic.hppswitched all ofSTDEXEC::__std's atomics tocuda::std::atomicwhenever<cuda/std/atomic>was merely installed. On Windowscuda::std::atomic<T>::waitpolls instead of usingWaitOnAddress, which madesync_waitwake-up latency ~15 ms rather than ~6 µs (benchmark in the issue).Nothing in stdexec/exec needs it:
::cuda::std::atomic_flagand::cuda::atomic_ref<..., thread_scope_*>itself (detail/queue.cuh,stream/common.cuh,stream/split.cuh), viadetail/cuda_atomic.cuh.when_all,ensure_started) already usesstd::atomic.This removes
STDEXEC_HAS_CUDA_STD_ATOMIC()and theSTDEXEC_DISABLE_CUDA_STD_ATOMICopt-out (the Relacy tests no longer need it), and drops the!STDEXEC_HAS_CUDA_STD_ATOMIC()condition on__atomic_shared_ptr.Behavior change: user code that called stdexec's own atomic-backed facilities (e.g.
inplace_stop_token::stop_requested(),intrusive_ptr) from__device__code relied oncuda::std::atomicand would now get a host-from-device error. Nothing in the repo does this.Testing: with
std::atomicused unconditionally,test.nvexecbuilds and passes (136 cases, 789 assertions) with nvcc 13.5 (g++-15 host, sm_86) and nvc++ 26.11. A host build ofsync_waitonstatic_thread_poolpasses with g++-15 at C++20/26. Clang-CUDA is untested; CI will cover it.🤖 Generated with Claude Code