This is an archive of the discontinued LLVM Phabricator instance.

[mlir][spirv] Add OpGroupBroadcast
ClosedPublic

Authored by abialas on Aug 6 2020, 8:32 AM.

Details

Summary

OpGroupBroadcast added to SPIRV dialect

Diff Detail

Event Timeline

abialas created this revision.Aug 6 2020, 8:32 AM
abialas requested review of this revision.Aug 6 2020, 8:32 AM
ThomasRaoux added inline comments.Aug 6 2020, 9:56 AM
mlir/include/mlir/Dialect/SPIRV/SPIRVGroupOps.td
89

You can use AllTypesMatch<["value", "result"]> to enforce that the source and result have the same type and then you can remove it from the assembly format to avoid having redundant types.

mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
2013–2017

nit: Don't use '{' for single line 'if'

mlir/test/Dialect/SPIRV/group-ops.mlir
19–23

Would be good to have an extra positive test with vector of localid

mravishankar requested changes to this revision.Aug 6 2020, 11:51 AM

We also need tests for roundtripping the serialization to SPIR-V binary. Please see this section : https://mlir.llvm.org/docs/Dialects/SPIR-V/#add-a-new-op

"Tests for the op’s custom assembly form and verification should be added to the proper file in test/Dialect/SPIRV/.

The generated op will automatically gain the logic for (de)serialization. However, tests still need to be coupled with the change to make sure no surprises. Serialization tests live in test/Dialect/SPIRV/Serialization."

mlir/lib/Dialect/SPIRV/SPIRVOps.cpp
2006

As Thomas suggested, if you add the AllTypesMatch this would not be needed.

This revision now requires changes to proceed.Aug 6 2020, 11:51 AM
flaub added a subscriber: flaub.Aug 6 2020, 2:14 PM
abialas updated this revision to Diff 283834.Aug 7 2020, 1:09 AM

Changes added after code review

We also need tests for roundtripping the serialization to SPIR-V binary. Please see this section : https://mlir.llvm.org/docs/Dialects/SPIR-V/#add-a-new-op

"Tests for the op’s custom assembly form and verification should be added to the proper file in test/Dialect/SPIRV/.

The generated op will automatically gain the logic for (de)serialization. However, tests still need to be coupled with the change to make sure no surprises. Serialization tests live in test/Dialect/SPIRV/Serialization."

Thank You for the review. Regarding Serialization tests, is there anything more needed than what I already added to mlir/test/Dialect/SPIRV/Serialization/group-ops.mlir?

ThomasRaoux accepted this revision.Aug 7 2020, 1:49 AM

Thanks Artur. Looks good to me.

mravishankar accepted this revision.Aug 7 2020, 3:13 PM
mravishankar added inline comments.
mlir/include/mlir/Dialect/SPIRV/SPIRVGroupOps.td
50

Nit: Refactor this to be within 80 chars.

This revision is now accepted and ready to land.Aug 7 2020, 3:13 PM
mravishankar added inline comments.Aug 7 2020, 3:16 PM
mlir/test/Dialect/SPIRV/Serialization/group-ops.mlir
10

Could you also add one for vector<..xi32> for localID.

Nit: Prefer the CHECK-* to be formatted like this to make it easier to read

CHECK-LABEL: func @group_broadcast
      CHECK:   spv.GroupBroadcast ...

i.e.
Align the ':'
and indent the check statements to make what is being checked more readable.
Suport nit, you dont need the leadeing %{{.*}} = if you are not trying to capture the value.

abialas updated this revision to Diff 284273.Aug 10 2020, 1:14 AM
abialas marked 4 inline comments as done.

Changes after code review

I added remaining changes requested. Regarding the CHECK-* format I believe it is consistent with other tests.
Since I do not have rw access to llvm repo, may I ask someone to push this change to trunk?

This revision was automatically updated to reflect the committed changes.