Skip to content

Introduce Subgroup Operations Extension #954

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

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion spec/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,8 @@ enum GPUExtensionName {
"texture-compression-bc",
"pipeline-statistics-query",
"timestamp-query",
"depth-clamping"
"depth-clamping",
"subgroup-operations"
};
</script>

Expand Down
46 changes: 46 additions & 0 deletions wgsl/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,12 @@ variable_decoration

[[builtin global_invocation_id]]
OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId

[[builtin subgroup_size]]
OpDecorate %gl_SubgroupSize BuiltIn SubgroupSize

[[builtin subgroup_invocation_idx]]
OpDecorate %gl_SubgroupInvocationID BuiltIn SubgroupLocalInvocationId
</xmp>
</div>

Expand All @@ -1129,6 +1135,14 @@ type, function decorations and storage class.
<tr><td>local_invocation_id<td>vec3&ltu32&gt<td>Compute Input
<tr><td>global_invocation_id<td>vec3&ltu32&gt<td>Compute Input
<tr><td>local_invocation_idx<td>u32<td>Compute Input
<tr><td>subgroup_size<td>u32<td>Compute Input<br>
Exists if "subgroup-operations"<br>
is both supported by the device/user<br>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need to specify this as "both", since the second one requires the first one. We should just talk about what's enabled on the device

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took that from 6.3. Texture Formats in host spec, does it look good now?

and is enabled in requestDevice
<tr><td>subgroup_invocation_idx<td>u32<td>Compute Input<br>
Exists if "subgroup-operations"<br>
is both supported by the device/user<br>
and is enabled in requestDevice
</table>

<pre class='def'>
Expand Down Expand Up @@ -2747,6 +2761,38 @@ TODO(dsinclair): Add Level-of-Detail via explicit gradient. "Grad" image operand
TODO(dsinclair): Need gather operations
</pre>

## Subgroup built-in functions ## {#subgroup-builtin-functions}

<table class='data'>
<thead>
<tr><td>Subgroup built-in functions<td>SPIR-V
</thead>
<tr><td>subgroup_is_first() -&gt; bool<td>OpGroupNonUniformElect
<tr><td>subgroup_all(bool) -&gt; bool<td>OpGroupNonUniformAll
<tr><td>subgroup_any(bool) -&gt; bool<td>OpGroupNonUniformAny
<tr><td>subgroup_ballot(bool) -&gt; vec4&lt;u32&gt;<td>OpGroupNonUniformBallot
<tr><td>subgroup_broadcast(Scalar,u32) -&gt; Scalar<td>OpGroupNonUniformBroadcast
<tr><td>subgroup_broadcast_first(Scalar) -&gt; Scalar<td>OpGroupNonUniformBroadcastFirst
<tr><td>subgroup_add(Integral) -&gt; Integral<td>OpGroupNonUniformIAdd with Reduce
<tr><td>subgroup_add(Floating) -&gt; Floating<td>OpGroupNonUniformFAdd with Reduce
<tr><td>subgroup_mul(Integral) -&gt; Integral<td>OpGroupNonUniformIMul with Reduce
<tr><td>subgroup_mul(Floating) -&gt; Floating<td>OpGroupNonUniformFMul with Reduce
<tr><td>subgroup_min(Integral) -&gt; Integral<td>OpGroupNonUniformUMin or OpGroupNonUniformSMin with Reduce
<tr><td>subgroup_min(Floating) -&gt; Floating<td>OpGroupNonUniformFMin with Reduce
<tr><td>subgroup_max(Integral) -&gt; Integral<td>OpGroupNonUniformUMax or OpGroupNonUniformSMax with Reduce
<tr><td>subgroup_max(Floating) -&gt; Floating<td>OpGroupNonUniformFMax with Reduce
<tr><td>subgroup_and(Integral) -&gt; Integral<td>OpGroupNonUniformBitwiseAnd
<tr><td>subgroup_or(Integral) -&gt; Integral<td>OpGroupNonUniformBitwiseOr
<tr><td>subgroup_xor(Integral) -&gt; Integral<td>OpGroupNonUniformBitwiseXor
<tr><td>subgroup_prefix_add(Integral) -&gt; Integral<td>OpGroupNonUniformIAdd with ExclusiveScan
<tr><td>subgroup_prefix_add(Floating) -&gt; Floating<td>OpGroupNonUniformFAdd with ExclusiveScan
<tr><td>subgroup_prefix_mul(Integral) -&gt; Integral<td>OpGroupNonUniformIMul with ExclusiveScan
<tr><td>subgroup_prefix_mul(Floating) -&gt; Floating<td>OpGroupNonUniformFMul with ExclusiveScan
</table>

Note: Subgroup functions exist if "subgroup-operations" is both supported
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

by the device/user agent and is enabled in requestDevice.

# Glossary # {#glossary}

<table class='data'>
Expand Down