This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Check 'iter_args' in 'isLoopParallel' utility
ClosedPublic

Authored by dcaballe on Feb 23 2021, 4:51 PM.

Details

Summary

Fix 'isLoopParallel' utility so that 'iter_args' is taken into account
and loops with loop-carried dependences are not classified as parallel.

Diff Detail

Event Timeline

dcaballe created this revision.Feb 23 2021, 4:51 PM
dcaballe requested review of this revision.Feb 23 2021, 4:51 PM

Hi Diego,

Does this patch handle iter_args in an inner loop? For example:

%cst = constant 0.000000e+00 : f32
affine.for %arg1 = 0 to 10 {
   %0 = affine.for %arg2 = 0 to 10 iter_args(%arg3 = %cst) -> (f32) {
       %1 = affine.load %arg0[%arg1, %arg2] : memref<10x10xf32>
       %2 = addf %arg3, %1 : f32
       affine.yield %2 : f32
    }
}

Thanks,
Tung.

mlir/test/Dialect/Affine/parallelize.mlir
177

How about using consecutive numbering for arg, and starting from %0 instead of %5?

Does this patch handle iter_args in an inner loop? For example:

Good point! I'll add a test for that but, yes, AffineParallelize pass is processing each loop independently so a parallel loop will be generated for the outer loop but not for the inner loop.

Thanks!

mlir/test/Dialect/Affine/parallelize.mlir
177

Thanks! I'll use more relevant names :)

dcaballe updated this revision to Diff 325990.Feb 23 2021, 10:50 PM

Addressing feedback.

Looks good, thanks !

This revision is now accepted and ready to land.Feb 24 2021, 9:36 AM
tungld accepted this revision.Feb 24 2021, 4:18 PM

LGTM! Thanks!

This revision was automatically updated to reflect the committed changes.