Rust-GPU / Rust-GPU/rust-gpu

Confusing "cannot use `AtomicOrdering::SeqCst` on Vulkan memory model"

Offen
#399 5 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug
Vorherrschende Sprache
Rust
Sterne
3.4k
Forks
126
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

I'm getting the following error when trying to use AtomicU32:

  error: cannot use `AtomicOrdering::SeqCst` on Vulkan memory model (check if `AcqRel` fits your needs)
      --> /home/nazar-pc/.rustup/toolchains/nightly-2025-06-23-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/sync/atomic.rs:3984:23
       |
  3984 |             SeqCst => intrinsics::atomic_xadd::<T, { AO::SeqCst }>(dst, val),
       |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       |
  note: used from within `core::sync::atomic::atomic_add::<u32>`
      --> /home/nazar-pc/.rustup/toolchains/nightly-2025-06-23-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/sync/atomic.rs:3984:23
       |
  3984 |             SeqCst => intrinsics::atomic_xadd::<T, { AO::SeqCst }>(dst, val),
       |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  note: called by `<core::sync::atomic::AtomicU32>::fetch_add`
      --> /home/nazar-pc/.rustup/toolchains/nightly-2025-06-23-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/sync/atomic.rs:3748:1
       |
  3748 | / atomic_int! {
  3749 | |     cfg(target_has_atomic = "32"),
  3750 | |     cfg(target_has_atomic_equal_alignment = "32"),
  3751 | |     stable(feature = "integer_atomics_stable", since = "1.34.0"),
  ...    |
  3764 | |     u32 AtomicU32
  3765 | | }
       | |_^
  note: called by `ab_proof_of_space_gpu::shader::find_matches_in_buckets::log_message`
      --> crates/farmer/ab-proof-of-space-gpu/src/shader/find_matches_in_buckets.rs:109:34
       |
  109  |     let write_at = debug_counter.fetch_add(message_length, Ordering::Relaxed);
       |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The confusing part is that I'm not using SeqCst. Looks like the code that references SeqCst is technically compiled in and causes issues even though it is practically unreachable.

Would have been nice for it to compile successfully.

After above failure I tried spirv_std::arch::atomic_i_add(), which did work, but it has a bit strange syntax due to the need to provide not just ordering semantics, but also scope and it doesn't work on AtomicU32, only on u32. It is also unsafe for some reason.

Ultimately I think the error should say to use spirv_std::arch::atomic_i_add() (because I don't think hiding/guessing scope is a great idea) and spirv_std::arch::atomic_i_add() should support Atomic32, which has the same memory layout as regular u32.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit crates/farmer/ab-proof-of-space-gpu/src/shader/find_matches_in_buckets.rs beim AtomicU32 fetch_add-Aufruf etwa in Zeile 109. Untersuche anschließend die gemeldete SeqCst-Diagnose und spirv_std::arch::atomic_i_add(). Ermittle, wie die atomare Reihenfolge von Vulkan behandelt wird und ob die Unterstützung für AtomicU32 behoben werden kann. Als erledigt gilt die Aufgabe, wenn der gemeldete Anwendungsfall kompiliert oder der Fehler die Benutzer eindeutig an die unterstützte atomare Operation verweist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
rust
Bereich
compilers
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.