Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Migrated] Initializing workgroup memory #80

Open
rust-gpu-bot opened this issue Nov 13, 2024 · 2 comments
Open

[Migrated] Initializing workgroup memory #80

rust-gpu-bot opened this issue Nov 13, 2024 · 2 comments

Comments

@rust-gpu-bot
Copy link

Issue automatically imported from old repo: EmbarkStudios/rust-gpu#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.

KhronosGroup/Vulkan-Docs#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],
    // ...
) {
  // ...
}
@rust-gpu-bot
Copy link
Author

Comment from Patryk27 on 2023-07-05T17:09:35Z


Btw, since recently, Naga automatically includes some glue code that zero-initializes workgroup memory.

@rust-gpu-bot
Copy link
Author

Comment from kevinboulain on 2023-07-07T16:44:29Z


Yeah, but unless I'm handling it wrong, it doesn't support a bunch of features and that limit its usefulness (e.g.: subgroups or atomics).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant