Skip to content

fix(atomic): use system memory scope for SystemAtomic types - #400

Merged
LegNeato merged 1 commit into
Rust-GPU:mainfrom
Snehal-Reddy:fix-system-atomic-scope
Sep 30, 2026
Merged

LegNeato merged 1 commit into
Rust-GPU:mainfrom
Snehal-Reddy:fix-system-atomic-scope

Conversation

@Snehal-Reddy

Copy link
Copy Markdown
Contributor

Summary

SystemAtomicF32 and SystemAtomicF64 previously used the device domain scope instead of the intended system scope in their macro instantiations. This mismatch caused .gpu scoped atomic PTX instructions to be emitted (atomic. global.gpu...) rather than .sys scoped instructions.

This bug meant that any system-level synchronization (between the host CPU and GPU, or across multiple GPUs over PCIe/NVLink) would fail to observe proper cache coherency, silently causing data races and corrupted shared memory states. This PR corrects the macro arguments to use the correct system scope for system atomics.

Closes #399

Changes

  • Changed the $scope argument for SystemAtomicF32 and SystemAtomicF64 from device to system in crates/cuda_std/src/atomic.rs.

Testing

  • cargo build passes
  • cargo clippy --workspace passes
  • Tested on: Ubuntu 24.04.1 LTS, NVIDIA GeForce RTX 5060 Ti, CUDA 12.8.93

@Snehal-Reddy

Copy link
Copy Markdown
Contributor Author

#386 should now take care of windows CI failures.

@LegNeato
LegNeato force-pushed the fix-system-atomic-scope branch from 04a0691 to 56c02b8 Compare September 29, 2026 03:23
@LegNeato
LegNeato added this pull request to the merge queue Sep 30, 2026
Merged via the queue into Rust-GPU:main with commit b163bde Sep 30, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Data Races & Flawed Synchronization due to Invalid Atomic Memory Scope in SystemAtomicF32 and `SystemAtomicF64

2 participants