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

Initializing workgroup memory #1077

Open
kevinboulain opened this issue Jul 4, 2023 · 2 comments
Open

Initializing workgroup memory #1077

kevinboulain opened this issue Jul 4, 2023 · 2 comments
Labels
t: enhancement A new feature or improvement to an existing one.

Comments

@kevinboulain
Copy link

kevinboulain commented Jul 4, 2023

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],
    // ...
) {
  // ...
}
@kevinboulain kevinboulain added the t: enhancement A new feature or improvement to an existing one. label Jul 4, 2023
@Patryk27
Copy link

Patryk27 commented Jul 5, 2023

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

@kevinboulain
Copy link
Author

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
t: enhancement A new feature or improvement to an existing one.
Projects
None yet
Development

No branches or pull requests

2 participants