Skip to content

Add extension subgroup-size-control#5578

Open
Jiawei-Shao wants to merge 16 commits intogpuweb:mainfrom
Jiawei-Shao:add-subgroup-size-control
Open

Add extension subgroup-size-control#5578
Jiawei-Shao wants to merge 16 commits intogpuweb:mainfrom
Jiawei-Shao:add-subgroup-size-control

Conversation

@Jiawei-Shao
Copy link
Copy Markdown
Contributor

@Jiawei-Shao Jiawei-Shao commented Feb 27, 2026

This patch adds a new WebGPU and WGSL extension subgroup-size-control
based on subgroup-size-control.md.

Fixed: #5545

@Jiawei-Shao Jiawei-Shao marked this pull request as draft February 27, 2026 07:19
@Jiawei-Shao Jiawei-Shao marked this pull request as ready for review February 27, 2026 07:58
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 27, 2026

Previews, as seen when this build job started (22e75bf):
WebGPU webgpu.idl | Explainer | Correspondence Reference
WGSL grammar.js | wgsl.lalr.txt

@dneto0 dneto0 requested review from dneto0 February 27, 2026 14:40
spec/index.bs Outdated
Comment on lines +1985 to +1986
readonly attribute unsigned long minExplicitComputeSubgroupSize;
readonly attribute unsigned long maxExplicitComputeSubgroupSize;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's a bit awkward that there are two min/max attributes. Are there devices where subgroupMin/MaxSize do not match min/maxExplicitComputeSubgroupSize?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Separately the naming conventions seem mismatched. If these are needed, maybe explicit[Compute]SubgroupMinSize and explicit[Compute]SubgroupMaxSize. Not sure including compute is helpful.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It's a bit awkward that there are two min/max attributes. Are there devices where subgroupMin/MaxSize do not match min/maxExplicitComputeSubgroupSize?

On D3D12 we should use D3D12_FEATURE_DATA_D3D12_OPTIONS1::waveLaneCountMin and D3D12_FEATURE_DATA_D3D12_OPTIONS1::waveLaneCountMax to verify the range of the [WaveSize] attribute in compute shader, but these two values are not always used as wgpu::AdapterInfo::subgroupMinSize or wgpu::AdapterInfo::subgroupMaxSize.

For example:

spec/index.bs Outdated

Note: To preserve privacy, the user agent may choose to not support some features or provide values
for the property which do not distinguish different devices, but are still usable
(e.g. use the default value of 4 for all devices).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this wouldn't work. The user agent can't default to 4 for all devices unless 4 is supported by all devices.

Maybe it would be better to say the user agent may choose a narrower range for min (and max) to limit distinguishing devices.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Now I all use 0 as the default values since they won't be used when subgroup-size-control is not supported.

spec/index.bs Outdated

1. If {{GPUFeatureName/"subgroup-size-control"}} is supported, set
{{GPUAdapterInfo/maxComputeWorkgroupSubgroups}} to the largest supported number of
subgroups per compute workgroup with explicit subgroup size. Otherwise, set this value to 32.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is 32 guaranteed supported on all devices or are implementations expected to filter out devices with less?

vulkan.gpuinfo.org seems to indicate there are devices that only support 16.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Now I all use 0 as the default values since they won't be used when subgroup-size-control is not supported.

@Jiawei-Shao Jiawei-Shao marked this pull request as draft March 4, 2026 07:59
@Jiawei-Shao Jiawei-Shao marked this pull request as ready for review March 4, 2026 08:02
@jimblandy
Copy link
Copy Markdown
Contributor

Should this PR also update the correspondence reference?

@Jiawei-Shao Jiawei-Shao marked this pull request as draft March 12, 2026 03:06
@Jiawei-Shao Jiawei-Shao marked this pull request as ready for review March 12, 2026 03:17
@Jiawei-Shao
Copy link
Copy Markdown
Contributor Author

Should this PR also update the correspondence reference?

Done

@Jiawei-Shao
Copy link
Copy Markdown
Contributor Author

PTAL, thanks!

Comment on lines +2044 to +2049
: <dfn>maxComputeWorkgroupSubgroups</dfn>
::
If the {{GPUFeatureName/"subgroup-size-control"}} feature is supported, the maximum
number of subgroups per workgroup when [=attribute/subgroup_size=] is used in compute shaders
on the [=adapter=].

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This isn't mentioned in the correspondence. Where does this limit come from?

Comment on lines +2101 to +2102
Note: To preserve privacy, the user agent may choose a larger value for the property which do not
distinguish different devices, but are still usable.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Note: To preserve privacy, the user agent may choose a larger value for the property which do not
distinguish different devices, but are still usable.
Note: To preserve privacy, the user agent may choose a larger value for the property which does not
distinguish different devices, but is still usable.

Comment on lines +2108 to +2109
Note: To preserve privacy, the user agent may choose a smaller value for the property which do not
distinguish different devices, but are still usable.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Note: To preserve privacy, the user agent may choose a smaller value for the property which do not
distinguish different devices, but are still usable.
Note: To preserve privacy, the user agent may choose a smaller value for the property which does not
distinguish different devices, but is still usable.


1. If {{GPUFeatureName/"subgroup-size-control"}} is supported, set
{{GPUAdapterInfo/explicitComputeSubgroupMinSize}} to the smallest supported explicit compute
subgroup size. Otherwise, set this value to 0.
Copy link
Copy Markdown
Contributor

@jimblandy jimblandy Apr 8, 2026

Choose a reason for hiding this comment

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

This text should explicitly refer to the @subgroup_size attribute in WGSL. Similarly for the Max limit.

Comment on lines +2115 to +2116
Note: To preserve privacy, the user agent may choose a smaller value for the property which do not
distinguish different devices, but are still usable.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Note: To preserve privacy, the user agent may choose a smaller value for the property which do not
distinguish different devices, but are still usable.
Note: To preserve privacy, the user agent may choose a smaller value for the property which does not
distinguish different devices, but is still usable.

Comment on lines +8352 to +8354
1. |entryPoint| |must| use &le;
<code>|subgroupSize| &times; |this|.{{GPUDevice/adapterInfo}}.{{GPUAdapterInfo/maxComputeWorkgroupSubgroups}}</code>
per workgroup.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think there's a word missing from this sentence. What must be less than or equal to the given expression?

<h3 id=dom-gpufeaturename-subgroup-size-control data-dfn-type=enum-value data-dfn-for=GPUFeatureName>`"subgroup-size-control"`
</h3>

Allows the use of [=attribute/subgroup_size=] attribute in WGSL to control over compute pipeline subgroup size.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
Allows the use of [=attribute/subgroup_size=] attribute in WGSL to control over compute pipeline subgroup size.
Allows the use of the [=attribute/subgroup_size=] attribute in WGSL to control compute pipeline subgroup size.

Copy link
Copy Markdown
Contributor

@jimblandy jimblandy left a comment

Choose a reason for hiding this comment

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

My comments above were mostly editorial, but there was one spot that required a fix.

Copy link
Copy Markdown

@mwyrzykowski mwyrzykowski left a comment

Choose a reason for hiding this comment

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

In general the concept seems fine as an optional extension, as noted on Metal this property is read only and can not be configured as far as I know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Subgroup Size Control

4 participants