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

Subgroup Operations #5301

Merged
merged 89 commits into from
Apr 17, 2024
Merged

Subgroup Operations #5301

merged 89 commits into from
Apr 17, 2024

Conversation

Lichtso
Copy link
Contributor

@Lichtso Lichtso commented Feb 25, 2024

Additional PR for code review as requested in #4190 (comment).

Resolves #4428

exrook and others added 30 commits October 25, 2023 13:55
…sl-out

TODO: metal out, figure out what needs to be done in validation
SPIR-V OpControlBarrier with execution scope Subgroup has implementation
defined behavior when executed nonuniformly. OpenCL SPIR-V execution
spec say nonuniform execution is UB. Vulkan SPIR-V execution spec says
nothing :).
supported operations and stages subgroup operations are supported on
can be passed to the validator after creating it

operations are grouped to follow vulkan:
- basic: elect, barrier
- vote: any, all
- arithmetic: reductions, scan
- ballot: ballot, broadcasts,
- shuffle: shuffles,
- shuffle relative: shuffle up, down
@Lichtso
Copy link
Contributor Author

Lichtso commented Apr 9, 2024

I fiddled with the Vulkan backend since yesterday and it is still complaining that:

Validation Error: Validation Error: [ VUID-VkPipelineShaderStageCreateInfo-flags-02784 ] | MessageID = 0xd65f4ec3 | vkCreateGraphicsPipelines(): pCreateInfos[0].pStages[0].flags includes VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT, but the subgroupSizeControl feature was not enabled. The Vulkan spec states: If flags has the VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT flag set, the subgroupSizeControl feature must be enabled (https://vulkan.lunarg.com/doc/view/1.3.268.0/linux/1.3-extensions/vkspec.html#VUID-VkPipelineShaderStageCreateInfo-flags-02784)

Even though I coupled the setting of PipelineShaderStageCreateFlags directly to the presence of the feature flag:

subgroup_size_control: phd_features
     .subgroup_size_control
     .map_or(false, |ext| ext.subgroup_size_control == vk::TRUE),

if self.shared.private_caps.subgroup_size_control {
     flags |= vk::PipelineShaderStageCreateFlags::ALLOW_VARYING_SUBGROUP_SIZE;
}

@teoxoy Ideas?

@teoxoy
Copy link
Member

teoxoy commented Apr 9, 2024

Ah yes, we need to explicitly enable it when creating the device.

I think the only thing missing is actually pushing the struct.

@teoxoy
Copy link
Member

teoxoy commented Apr 9, 2024

I think the last remaining thing is #5301 (comment).

naga/src/valid/interface.rs Outdated Show resolved Hide resolved
@atlv24
Copy link
Contributor

atlv24 commented Apr 15, 2024

Merge conflicts and compile errors fixed here: Lichtso#1

Copy link
Member

@teoxoy teoxoy left a comment

Choose a reason for hiding this comment

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

I think it's time 🎉

Thank you for this substantial contribution!

@teoxoy
Copy link
Member

teoxoy commented Apr 15, 2024

@cwfitzgerald do you want to give this another look? Since you've previously requested changes.

Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

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

Amazing work everyone!

@cwfitzgerald cwfitzgerald merged commit ea77d56 into gfx-rs:trunk Apr 17, 2024
25 checks passed
@Lichtso Lichtso deleted the subgroup_feature branch April 17, 2024 19:59
@Lichtso
Copy link
Contributor Author

Lichtso commented Apr 17, 2024

@exrook We did it! The subgroup feature is merged.

@teoxoy You might want to adjust the CHANGELOG, I think we accidentally categorized it as "Bug fix" not "New features".

@cwfitzgerald
Copy link
Member

I can touch up the changelog, there is a merge conlfict on trunk between this and #5508 that I'm fixing

@teoxoy
Copy link
Member

teoxoy commented Apr 18, 2024

I put together a new issue to track the differences between our implementation and the WebGPU proposal #5555.

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.

Support subgroup/wave operations
8 participants