This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Vector] Refactor vector distribution and fix an issue related to non-homogenous transfer indices.
ClosedPublic

Authored by nicolasvasilache on Sep 1 2022, 5:47 AM.

Details

Summary

Running: mlir-opt -test-vector-warp-distribute=rewrite-warp-ops-to-scf-if -canonicalize -verify-each=0.

Prior to this revision, IR resembling the following would be produced:

%4 = "vector.load"(%3, %arg0) : (memref<1x32xf32, 3>, index) -> vector<1x1xf32>

This fails verification since it needs 2 indices to load but only 1 is provided.

Diff Detail

Event Timeline

nicolasvasilache requested review of this revision.Sep 1 2022, 5:47 AM
Herald added a project: Restricted Project. · View Herald Transcript
nicolasvasilache retitled this revision from [mlir][Vector] WIP - Add a test that exhibits bugs in vector distribution to [mlir][Vector] Refactor and fix vector distribution bugs (out of bounds memory accesses and non-homogenous transfer indices)..
nicolasvasilache edited the summary of this revision. (Show Details)

Fix the bugs

nicolasvasilache retitled this revision from [mlir][Vector] Refactor and fix vector distribution bugs (out of bounds memory accesses and non-homogenous transfer indices). to [mlir][Vector] Refactor vector distribution and fix an issue related to non-homogenous transfer indices..
nicolasvasilache edited the summary of this revision. (Show Details)

Drop %laneid usage within the warp_execute_on_lane_0 as this will be illegal in the verifier.

Update doc and move code.

Close namespace drop spurious includes.

ThomasRaoux accepted this revision.Sep 1 2022, 11:41 PM

Looks good, I think we should remove the assumption that the distributed dimension is the most inner one but I can do that in a follow up patch.

mlir/lib/Dialect/Vector/Transforms/VectorDistribute.cpp
78

the distributed dimension should be inferred from the distributed vector type.

283

We shouldn't have this assumption. In the rest of the code the distributed dimension is based on the types. That being said since there is no test for it, it could be broken.
We can extend generalize it in a follow up patch.

This revision is now accepted and ready to land.Sep 1 2022, 11:41 PM
nicolasvasilache marked an inline comment as done.Sep 2 2022, 12:10 AM
nicolasvasilache added inline comments.
mlir/lib/Dialect/Vector/Transforms/VectorDistribute.cpp
78

Atm the convention I use is most minor dimension.
Before this PR is was just shape[0] and would crash for >1-D vectors.

Do you have a procedure to determine which dimension this should be in general?
I.e. if you have vector<32x32x128xf32>, which one should be used?
I anticipate this will require a small analysis based on analyzing coalesced memory accesses.

I'll add some more doc, the analysis part is separable from the rest.

283

ok, since the impl only worked for 1-D up to this point, the question didn't even really arise but an analysis step and a bit of refactoring will be welcome.

nicolasvasilache marked an inline comment as done.

Refactor to separate out the distribution dimension and add doc for a future analysis.