Rust-GPU / Rust-GPU/rust-gpu

[Migrated] Initializing workgroup memory

Open
#80 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Issue automatically imported from old repo: https://github.com/EmbarkStudios/rust-gpu/issues/1077
Old labels: t: enhancement
Originally creatd by kevinboulain on 2023-07-04T20:07:53Z


As far as I can tell, the workgroup/shared memory (context) can not be declared as to be zero-initialized and one has to do it manually.

https://github.com/KhronosGroup/Vulkan-Docs/issues/1457 has a bunch of interesting links: the extension VK_KHR_zero_initialize_workgroup_memory (promoted to core in Vulkan 1.3) allows to declare workgroup/shared variables with a null initializer. On the SPIR-V side, OpVariable with a Workgroup storage class is allowed to be initialized with OpConstantNull only (like so).

I don't know what the project would prefer, it could be an option to pass to the SpirvBuilder (I assume it could be desirable to always initialize these variables) or another symbol (similarly to how storage_buffer allows extra arguments):

#[spirv(compute(threads(256)))]  
fn compute(
    #[spirv(workgroup, null_initialized = true)] array: &mut [u32; N],
    // ...
) {
  // ...
}

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 by tracing the SpirvBuilder and the existing handling of workgroup/shared memory, then compare it with the linked Vulkan and SPIR-V rules for OpConstantNull. Done means the project has a decided API for requesting zero-initialized workgroup memory and supports the corresponding valid SPIR-V output.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, computer-graphics
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.