Page MenuHomePhabricator

[MLIR] Add explicit initial values for loop.parallel op.
ClosedPublic

Authored by pifon2a on Feb 26 2020, 12:08 PM.

Details

Summary

Add initial value operands to loop.parallel. The operands correspond
to the result types and loop.reduce ops in the body of the op.

Diff Detail

Event Timeline

pifon2a created this revision.Feb 26 2020, 12:08 PM
herhut accepted this revision.Mar 3 2020, 5:58 AM

Thanks. This looks great with some minor changes addressed.

mlir/include/mlir/Dialect/LoopOps/LoopOps.td
238

This confused me when I read it. The initial values are not optional. You need the same number of initial values as there are return values (which is mentioned below).

mlir/lib/Dialect/LoopOps/LoopOps.cpp
322–323

Drop the const and & and avoid auto if the actual type is concise. for (Value init : initVals).

345–348

I think it is preferred to not mix the two forms and just use op.emitOpError() << ...

428

This should reflect what you actually parsed. So lower.size(), upper.size(), steps.size() and initVals.size().

This revision is now accepted and ready to land.Mar 3 2020, 5:58 AM
This revision was automatically updated to reflect the committed changes.
pifon2a marked 4 inline comments as done.

Addressed the comments.

rriddle added inline comments.Mar 3 2020, 9:20 AM
mlir/lib/Dialect/LoopOps/LoopOps.cpp
416

nit: Can you please add /*variableName=*/ comments when using constant arguments?

mehdi_amini added inline comments.Mar 8 2020, 2:05 PM
mlir/lib/Dialect/LoopOps/LoopOps.cpp
413

Nit: the comment needs an update here.

434

Have you considered having the type closer to the init?

%res = loop.parallel (%i0) = (%arg0) to (%arg1) step (%arg2) init (%zero : f32) {

or

%res = loop.parallel (%i0) = (%arg0) to (%arg1) step (%arg2) init (%zero) -> f32 {

Having to skip visually the body is not the most readable to me.

pifon2a marked 2 inline comments as done.Mar 8 2020, 3:15 PM
pifon2a added inline comments.
mlir/lib/Dialect/LoopOps/LoopOps.cpp
434

https://reviews.llvm.org/D75832 it is more readable indeed.

pifon2a marked 3 inline comments as done.Mar 8 2020, 3:16 PM