Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン 初心者向け
#399 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1時間未満
初心者へのやさしさ
88/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
rust

調査の方向性

crates/cuda_std/src/atomic.rs から始めて、SystemAtomicF32 と SystemAtomicF64 のマクロインスタンス化を調べます。これらの scope 引数を device から system に変更し、その後、これらのアトミック操作が device スコープの PTX 操作ではなく、期待される system スコープの PTX 操作を出力することを確認します。

索引モデルが issue の本文から書いたものです。

説明

SystemAtomicF32 and SystemAtomicF64 types are mistakenly configured with device scope instead of system scope in their macro instantiations.

This presents the following issues:

  1. Flawed Synchronization: Code that uses SystemAtomicF32 or SystemAtomicF64 intends to synchronize memory accesses across the entire system (between the GPU and host CPU or across multiple GPUs over PCIe/NVLink).
  2. Data Races: Because the emitted PTX operations use the .gpu scope (atomic.global.gpu...) rather than the proper .sys scope (atomic.global.sys...), CPU host accesses and multi-GPU accesses to system memory will not observe proper cache coherency. This leads to data races and corrupted shared memory states without emitting any compilation errors.

Reproduction Case

Using SystemAtomicF32 or SystemAtomicF64 and calling atomic operations (like fetch_add, load, or store) will incorrectly generate device-scoped PTX:

use cuda_std::atomic::SystemAtomicF32;
use core::sync::atomic::Ordering;

#[cuda_std::kernel]
pub unsafe fn system_atomic_kernel(val: &SystemAtomicF32) {
    // PTX generates: atomic.global.gpu.add.f32 ...
    // Expected: atomic.global.sys.add.f32 ...
    val.fetch_add(1.0, Ordering::Relaxed);
}

Issue Details

In crates/cuda_std/src/atomic.rs, the type instantiations for system-level float atomics incorrectly pass the $scope argument as device instead of system to the macro:

// Current instantiations in atomic.rs
atomic_float!(f32, AtomicF32, 4, device, 32);
atomic_float!(f64, AtomicF64, 8, device, 64);
atomic_float!(f32, BlockAtomicF32, 4, block, 32, unsafe);
atomic_float!(f64, BlockAtomicF64, 8, block, 64, unsafe);
atomic_float!(f32, SystemAtomicF32, 4, device, 32); // <--- BUG: device instead of system
atomic_float!(f64, SystemAtomicF64, 8, device, 64); // <--- BUG: device instead of system
主要言語
Rust
スター
5.4k
フォーク
249
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Rust-GPU/rust-cuda のほかの issue

Rust-GPU/rust-cuda の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。