This is an archive of the discontinued LLVM Phabricator instance.

[mlir][gpu] Add subgroup Id/Size/Num to GPU dialect
ClosedPublic

Authored by ThomasRaoux on Jun 2 2020, 3:36 PM.

Details

Summary

Add SubgroupId, SubgroupSize and NumSubgroups to GPU dialect ops and add the lowering of those ops to SPIRV.

Diff Detail

Event Timeline

ThomasRaoux created this revision.Jun 2 2020, 3:36 PM
Herald added a reviewer: herhut. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
ftynse accepted this revision.Jun 3 2020, 1:14 AM
ftynse added inline comments.
mlir/include/mlir/Dialect/GPU/GPUOps.td
93

I think we use "workgroup" in the documentation. We should actually be consistent in the op names as well

101

let assemblyFormat = "attr-dict : type($result)" and changing the header to have Results<(outs Index:$result)> should give you custom syntax for almost free

This revision is now accepted and ready to land.Jun 3 2020, 1:14 AM
ThomasRaoux marked an inline comment as done.Jun 3 2020, 9:42 AM
ThomasRaoux added inline comments.
mlir/include/mlir/Dialect/GPU/GPUOps.td
93

I can change it but all the Id Op above use block in comments and name (i.e. BlockDimOp, BlockIdOp) so it wold look inconsistent from this point of view. What do you think?

ThomasRaoux updated this revision to Diff 268313.
ThomasRaoux marked 2 inline comments as done.
ThomasRaoux added inline comments.
mlir/include/mlir/Dialect/GPU/GPUOps.td
101

Update the syntax.

ftynse added inline comments.Jun 4 2020, 2:50 AM
mlir/include/mlir/Dialect/GPU/GPUOps.td
93

Other ops with inconsistent names are the reason why I suggested to change it in the documentation only. "Subgroup within the block" just sounds weird.

Arguably, the op names should also be changed, but that would require an RFC and make sure @herhut and @mravishankar sign off on it.

antiagainst accepted this revision.Jun 4 2020, 8:18 AM

Cool, thanks Thomas! SPIR-V side looks good to me. :)

mlir/include/mlir/Dialect/GPU/GPUOps.td
114

Nit: It seems the sgId needs to be properly named ? :)

130

Here too.

mlir/lib/Conversion/GPUToSPIRV/ConvertGPUToSPIRV.cpp
73

SingleDimLaunchConfigConversion?

mlir/test/Conversion/GPUToSPIRV/builtins.mlir
185

I don't think we need this function for this test? Removing it can simplify the test itself. Less code is typically better. :)

Similarly for the rest. :)

ThomasRaoux marked 5 inline comments as done.
ThomasRaoux added inline comments.
mlir/include/mlir/Dialect/GPU/GPUOps.td
93

Thanks for explaining, changed it.

This revision was automatically updated to reflect the committed changes.