KhronosGroup / KhronosGroup/SPIRV-Cross
MSL: Feature request: Support for 64-bit datatypes in subgroup operations
- Dominant language
- GLSL
- Stars
- 2.5k
- Forks
- 713
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 16
Description
In SPIRV-Cross, subgroup ops are lowered to Metal SIMD intrinsics, ie `OpGroupNonUniformBroadcastFirst` turns into `simd_broadcast_first`.
This doesn't work for 64-bit integers, as Metal lacks an implementation of those intrinsics for `long`. This results in the following error message:
```
program_source:50:12: error: no matching function for call to 'simd_broadcast_first'
return simd_broadcast_first(value);
^~~~~~~~~~~~~~~~~~~~
program_source:216:84: note: in instantiation of function template specialization 'spvSubgroupBroadcastFirst' requested here
builtin_join(spvSubgroupBroadcastFirst(physical_private_buffer[0u + sub_out]), spvSubgroupBroadcastFirst(ulong(physical_private_buffer[add_out]) | (ulong(physical_private_buffer[add_out + 1u]) << 137438953472ul)), stack_ptr, physical_private_buffer, physical_subgroup_buffer, gl_SubgroupInvocationID);
^
/System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/31001/Libraries/lib/clang/31001.525/include/metal/metal_simdgroup:119:14: note: candidate template ignored: requirement '__is_valid_simdgroup_type::value' was not satisfied [with T = unsigned long]
METAL_FUNC T simd_broadcast_first(T data)
^
```
For MoltenVK (issue will be linked after this post), it would be desirable to have this emulated (I think simply splitting the ops into two halves should work ?), so the support for `shaderSubgroupExtendedTypes` can be complete.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing how subgroup operations are lowered to Metal SIMD intrinsics, using the reported simd_broadcast_first failure for 64-bit integers as the reproduction case. Determine how 64-bit subgroup values can be emulated and verify that shaderSubgroupExtendedTypes support covers the affected operations.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100