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

[SPIR-V] Implement WaveMatch intrinsic support #6545

Closed
sudonatalie opened this issue Apr 18, 2024 · 8 comments · Fixed by #6546
Closed

[SPIR-V] Implement WaveMatch intrinsic support #6545

sudonatalie opened this issue Apr 18, 2024 · 8 comments · Fixed by #6546
Assignees
Labels
bug Bug, regression, crash spirv Work related to SPIR-V

Comments

@sudonatalie
Copy link
Collaborator

The WaveMatch() Function was introduced in shader model 6.5 but is not yet supported by the SPIR-V backend. It should be implemented using: https://htmlpreview.github.io/?https://github.com/KhronosGroup/SPIRV-Registry/blob/main/extensions/NV/SPV_NV_shader_subgroup_partitioned.html

@sudonatalie sudonatalie added bug Bug, regression, crash spirv Work related to SPIR-V labels Apr 18, 2024
@sudonatalie sudonatalie self-assigned this Apr 18, 2024
sudonatalie added a commit to sudonatalie/DirectXShaderCompiler that referenced this issue Apr 18, 2024
Adds support for the WaveMatch() intrinsic function from Shader Model
6.5 using the OpGroupNonUniformPartitionNV instruction from the
SPV_NV_shader_subgroup_partitioned extension.

Requires KhronosGroup/SPIRV-Tools#5648

Fixes microsoft#6545
@Keenuts
Copy link
Collaborator

Keenuts commented Apr 18, 2024

Shall we add an option for DXC to specify the targeted vendor?
If I'm an HLSL user targeting AMD cards, I might want to know when a feature will only be available on Nvidia, and at least have a warning.

@damyanp
Copy link
Member

damyanp commented Apr 18, 2024

Is "vendor" the right thing to slice on, or should it be on which extensions should be allowed?

@llvm-beanz
Copy link
Collaborator

Shall we add an option for DXC to specify the targeted vendor? If I'm an HLSL user targeting AMD cards, I might want to know when a feature will only be available on Nvidia, and at least have a warning.

I’d like to have a larger discussion about the design for something like this. I see the utility, but I wonder if there is a better way to express it (perhaps in terms of which extensions a user wants to enable)? We should also make sure whatever we do for this aligns with LLVM/Clang so that we can avoid introducing a feature that would be difficult to support in the future.

@Keenuts
Copy link
Collaborator

Keenuts commented Apr 18, 2024

Is "vendor" the right thing to slice on, or should it be on which extensions should be allowed?

There is already a SPIR-V flag to specify the list of extension you are allowed to use.
So an tool like an engine can restrict DXC to only use the subset of extensions they decided to require for the game to run.
This flag however takes full names, no regex/wildcard like SPV_NV_*.
So a normal user might never use this, and be surprised by this accidental "vendor lock"

Yes, this issue might not be the best location to discuss this.

@sudonatalie
Copy link
Collaborator Author

Right, we already support slicing on which extensions are allowed, realizing that has drawbacks and is difficult to use. Vulkan profiles will probably provide a more user-friendly way to express which capability are supported by a target environment, and is tentatively our plan for future upstream work, but it's not something we're likely to change in DXC right now, and is definitely outside the scope of this PR.

@devshgraphicsprogramming

All KHR subgroup ops except for Arithmetic, Quad and Clustered are pretty much ubiquitous across all shader stages on Desktop when targetting Vulkan 1.3

Not sure you need Clustered (aka NV partitioned) ops for this?

@sudonatalie
Copy link
Collaborator Author

Unfortunately I don't think there is a substitute for OpGroupNonUniformPartitionNV in core or a KHR extension at this point. As far as I can tell this is also how the split of subgroup* functions are handled in GLSL.

@devshgraphicsprogramming

Ah yeah I see that you're after partitioning according to an arbitrary ballot.

There's Subgroup Clustered ops, but that partitions into sets of consecutive invocations of power-of-two, i.e 4, 8, 16

sudonatalie added a commit to sudonatalie/DirectXShaderCompiler that referenced this issue May 6, 2024
Adds support for the WaveMatch() intrinsic function from Shader Model
6.5 using the OpGroupNonUniformPartitionNV instruction from the
SPV_NV_shader_subgroup_partitioned extension.

Requires KhronosGroup/SPIRV-Tools#5648

Fixes microsoft#6545
sudonatalie added a commit that referenced this issue May 6, 2024
Adds support for the `WaveMatch()` intrinsic function from Shader Model
6.5 using the `OpGroupNonUniformPartitionNV` instruction from the
`SPV_NV_shader_subgroup_partitioned` extension.

SPIRV-Tools bumped to include:
KhronosGroup/SPIRV-Tools#5648

Fixes #6545
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug, regression, crash spirv Work related to SPIR-V
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants