This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Vector] Add option to fully unroll for VectorTransfer to SCF lowering
ClosedPublic

Authored by nicolasvasilache on May 17 2020, 10:02 PM.

Details

Summary

Previously, the only support partial lowering from vector transfers to SCF was
going through loops. This requires a dedicated allocation and extra memory
roundtrips because LLVM aggregates cannot be indexed dynamically (for more
details see the deep-dive).

This revision allows specifying full unrolling which removes this additional roundtrip.
This should be used carefully though because full unrolling will spill, negating the
benefits of removing the interim alloc in the first place.

Proper heuristics are left for a later time.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptMay 17 2020, 10:02 PM
ftynse added inline comments.May 18 2020, 10:34 AM
mlir/include/mlir/Conversion/VectorToSCF/VectorToSCF.h
16

struct or you'll break msvc

57

Something's missing here

59

Copy-pasta?

ftynse accepted this revision.May 19 2020, 2:00 AM
ftynse added inline comments.
mlir/include/mlir/Dialect/Vector/VectorOps.td
377

I was confused by this comment wrt the builder above. Consider "which assumes the values in position are defined by ConstantIndexOp`".

544

The position of this comment is just weird

545

Nit: no need for #, string literals are auto-concatenated like in C

mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
149

Nit: we mildly prefer using auto when the type is either very long or obvious from the context. In this function, types are almost never obvious and one has to look up the declarations of other functions.

226

Typo: inbBounds

243

Plz remind me if Append() appends to the end of the block or before the terminator

261

https://llvm.org/docs/CodingStandards.html#do-not-use-braced-initializer-lists-to-call-a-constructor

Maybe just do vector = vector_insert(vector, ...); loop_yield(vector);, reads better IMO

329

inbBounds again

mlir/lib/Dialect/Vector/VectorUtils.cpp
36

std::accumulate(basis.begin(), basis.end(), 1, std::multiplies<int64_t>()); ?

This revision is now accepted and ready to land.May 19 2020, 2:00 AM
aartbik added inline comments.May 19 2020, 11:10 AM
mlir/include/mlir/Conversion/VectorToSCF/VectorToSCF.h
78

nit: broadcasts (same verb form)

mlir/test/Conversion/VectorToLoops/vector-to-loops.mlir
225 ↗(On Diff #264668)

empty line?

nicolasvasilache marked 16 inline comments as done.May 20 2020, 7:58 AM
nicolasvasilache added inline comments.
mlir/include/mlir/Conversion/VectorToSCF/VectorToSCF.h
16

dropped it from here

mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
243

before the terminator if it is there otherwise end of the block.

nicolasvasilache marked 2 inline comments as done.

Address review.

This revision was automatically updated to reflect the committed changes.
rriddle added inline comments.May 27 2020, 1:47 PM
mlir/lib/Dialect/Vector/VectorOps.cpp
478

getDefiningOp can return null, which would make this crash instead of assert.

757

Same here.