This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Introduce a pattern to lower `gpu.subgroup_reduce` to `nvvm.redux_op`
ClosedPublic

Authored by guraypp on Jan 19 2023, 3:46 AM.

Details

Summary

This revision introduces a pattern to lower gpu.subgroup_reduce op into to the nvvm.redux_sync op. The op must be run by the entire subgroup, otherwise it is undefined behaviour.

It also adds a flag and populate function, because the op is not avaiable for every gpu (sm80+), so it can be used when it is desired.

Depends on D142088

Diff Detail

Event Timeline

guraypp created this revision.Jan 19 2023, 3:46 AM
guraypp requested review of this revision.Jan 19 2023, 3:46 AM
Hardcode84 added inline comments.
mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
76

Instead of hard crashing should probably return optional and check it in pattern.

92

missing return

guraypp updated this revision to Diff 490479.Jan 19 2023, 5:56 AM

address comments

guraypp marked 2 inline comments as done.Jan 19 2023, 5:56 AM
guraypp added inline comments.
mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
76

good catch, thanks!

nicolasvasilache accepted this revision.Jan 20 2023, 3:30 AM

Looks good once we purge errors

mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
92

not an error but rewriter.notifyMatchFailure everywhere plz

This revision is now accepted and ready to land.Jan 20 2023, 3:30 AM
guraypp updated this revision to Diff 490775.Jan 20 2023, 3:44 AM
guraypp marked an inline comment as done.

Change emitErrors to notifyMatchFailure