Rust-GPU / Rust-GPU/rust-gpu

atomic ops unsafe, but unclear why

Open
#450 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Rust
Stars
3.4k
Forks
125
PR merge metrics
No merged PRs in 30d

Description

this is basically a follow up to issue #382, where @nazar-pc said:

"""
Functions like workgroup_memory_barrier_with_group_sync() are unsafe, but it is not clear why (no "Safety" section in docs).

They should either not be unsafe or "Safety" section should be added to corresponding function docs explaining how to use them safely.
"""

Similar concern with the files in e.g. crates/spirv-std/src/arch/atomics.rs -- all of the atomic ops seem to be marked as unsafe. I don't understand the spir-v / Vulkan / whatevs memory model... like... at all... but I always thought atomic ops like these were specifically designed to provide a safe way to update memory that might be touched by multiple threads? If this is not the case, then as @nazar-pc suggested re barriers, a comment saying how to uphold any invariants required for safety would be a big help! Thanks!! :-)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with crates/spirv-std/src/arch/atomics.rs and read issue #382 for the related discussion about unsafe functions and safety documentation. Determine whether the atomic operations require caller-managed invariants under the SPIR-V/Vulkan memory model; done means either clarifying their safety requirements in the function docs or establishing that the unsafe markers should change.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.