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

Add the ability to Sleep and/or reduce a wave's priority #335

Open
AdamJMiles opened this issue Oct 11, 2024 · 3 comments
Open

Add the ability to Sleep and/or reduce a wave's priority #335

AdamJMiles opened this issue Oct 11, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@AdamJMiles
Copy link
Member

Hi,

As the algorithms we put into Compute Shaders get more and more complex there's an ever increasing number of shaders that have a property of being inherently producer-consumer. That may be one wave producing work that other waves in a thread group can consume, or something more complex where thread groups are producing work that other thread groups consume.

Today, neither of those algorithms are strictly legal without a Forward Progress guarantee, but they are being written and for the most part are being shipped regardless.

Given that, I've sometimes felt the need to be able to indicate that a wave (or set of waves) should temporarily either yield execution completely to other waves / thread groups, or at least indicate that other waves / thread groups should take priority thereafter. In a CPU world, this would be achieved through a combination of YieldProcessor, Sleep and SetThreadPriority.

The timescales that GPU shaders work on would make a Sleep that takes milliseconds (or even microseconds) too long, and expressing the intended delay in cycles does not feel like an appropriate proposal that would work across GPUs past, present and future. CUDA exposes __nanosleep(ns) for this purpose. A Yield intrinsic that communicates that a wave does not need to immediately continue execution, and if necessary can be ignored by an IHV would be one way to at 'context switch' to other work.

Based on public information, switching wave priority is something that some GPUs do support and could be another way to get the most important (producer) waves some priority over those waves that would otherwise just spin infinitely looking for work that would be produced until other waves get a chance. Like Yield, this intrinsic could be ignored if it's not supported, and would simply serve as a hint if an IHV is able to achieve something akin to a change in wave priority.

Thanks,

Adam

@devshgraphicsprogramming

This is a Shader Model / Environment (Vulkan / DirectX) issue, first such a capability must exist in SPIR-V and the client graphics API.

On the Vulkan side, the correct door to knock on is KhronosGroup/Vulkan-Docs#2233

@devshgraphicsprogramming

Also doesn't this depend on #336 ?

@llvm-beanz
Copy link
Collaborator

This is a Shader Model / Environment (Vulkan / DirectX) issue, first such a capability must exist in SPIR-V and the client graphics API.

On the Vulkan side, the correct door to knock on is KhronosGroup/Vulkan-Docs#2233

Respectfully disagree. This is the right place for us to track this request. The HLSL team participates in the Khronos Vulkan and SPIR working groups. We're able to handle that coordination.

@damyanp damyanp added this to the Shader Model Backlog milestone Oct 16, 2024
@damyanp damyanp moved this to Triaged in HLSL Triage Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Triaged
Development

No branches or pull requests

4 participants