Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#399 5 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
rust
领域
compilers

调研方向

从 crates/farmer/ab-proof-of-space-gpu/src/shader/find_matches_in_buckets.rs 中第 109 行附近的 AtomicU32 fetch_add 调用开始,然后检查报告的 SeqCst 诊断和 spirv_std::arch::atomic_i_add()。确定 Vulkan 如何处理原子排序,以及是否可以处理对 AtomicU32 的支持。当报告的用例能够编译,或错误能够明确指引用户使用受支持的原子操作时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

bug

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.

主要语言
Rust
星标
3.4k
派生
126
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Rust-GPU/rust-gpu 的其他 Issue

查看 Rust-GPU/rust-gpu 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。