Skip to content

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

Open
Snehal-Reddy wants to merge 1 commit into
Rust-GPU:mainfrom
Snehal-Reddy:fix-system-atomic-scope
Open

fix(atomic): use system memory scope for SystemAtomic types#400
Snehal-Reddy wants to merge 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.

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

1 participant