Skip to content

Enable vector transfer flattening. - #8114

Merged
bjacob merged 1 commit into
iree-org:mainfrom
bjacob:enable-vector-transfer-flattening
Jan 21, 2022
Merged

bjacob merged 1 commit into
iree-org:mainfrom
bjacob:enable-vector-transfer-flattening

Conversation

@bjacob

@bjacob bjacob commented Jan 14, 2022

Copy link
Copy Markdown
Collaborator

This fixes the codegen for the 2d vector transfers that we need to do
in matmul kernels targeting 2D (matrix) simd operations, for instance
allowing PR #7778 to achieve nice codegen such as:

   11a14: ad 05 00 f1      subs    x13, x13, #1
   11a18: f8 66 c1 ac      ldp    q24, q25, [x23], #32
   11a1c: 7a 6f c1 ac      ldp    q26, q27, [x27], #32
   11a20: 41 e3 98 4f      sdot    v1.4s, v26.16b, v24.4b[0]
   11a24: 60 e3 98 4f      sdot    v0.4s, v27.16b, v24.4b[0]
   11a28: 43 e3 b8 4f      sdot    v3.4s, v26.16b, v24.4b[1]
   11a2c: 62 e3 b8 4f      sdot    v2.4s, v27.16b, v24.4b[1]
   11a30: 46 eb 98 4f      sdot    v6.4s, v26.16b, v24.4b[2]
   11a34: 64 eb 98 4f      sdot    v4.4s, v27.16b, v24.4b[2]
   11a38: 53 eb b8 4f      sdot    v19.4s, v26.16b, v24.4b[3]
   11a3c: 70 eb b8 4f      sdot    v16.4s, v27.16b, v24.4b[3]
   11a40: 54 e3 99 4f      sdot    v20.4s, v26.16b, v25.4b[0]
   11a44: 71 e3 99 4f      sdot    v17.4s, v27.16b, v25.4b[0]
   11a48: 57 e3 b9 4f      sdot    v23.4s, v26.16b, v25.4b[1]
   11a4c: 76 e3 b9 4f      sdot    v22.4s, v27.16b, v25.4b[1]
   11a50: 55 eb 99 4f      sdot    v21.4s, v26.16b, v25.4b[2]
   11a54: 72 eb 99 4f      sdot    v18.4s, v27.16b, v25.4b[2]
   11a58: 47 eb b9 4f      sdot    v7.4s, v26.16b, v25.4b[3]
   11a5c: 65 eb b9 4f      sdot    v5.4s, v27.16b, v25.4b[3]
   11a60: a1 fd ff 54      b.ne    0x11a14 <.text+0x11a8>

@MaheshRavishankar MaheshRavishankar left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure we want to add this for all backends? @antiagainst @ThomasRaoux ?

@bjacob

bjacob commented Jan 14, 2022

Copy link
Copy Markdown
Collaborator Author

Note: the CI failures are because this relies on a MLIR commit that IREE hasn't sync'd to yet, but should be part of the next dependency update.

@bjacob

bjacob commented Jan 14, 2022

Copy link
Copy Markdown
Collaborator Author

Are we sure we want to add this for all backends? @antiagainst @ThomasRaoux ?

More than happy to limit this to LLVMCPU if you can point out how to do that! Though I can see other similar patterns already enabled right there.

@MaheshRavishankar

Copy link
Copy Markdown
Collaborator

Are we sure we want to add this for all backends? @antiagainst @ThomasRaoux ?

More than happy to limit this to LLVMCPU if you can point out how to do that! Though I can see other similar patterns already enabled right there.

Fine with it going in here unless Lei/Thomas say otherwise.

@bjacob

bjacob commented Jan 15, 2022

Copy link
Copy Markdown
Collaborator Author

Fine with it going in here unless Lei/Thomas say otherwise.

Thanks! Anyway I won't be able to merge this before the next third-party/llvm-project bump.

@bjacob

bjacob commented Jan 15, 2022

Copy link
Copy Markdown
Collaborator Author

Fine with it going in here unless Lei/Thomas say otherwise.

Thanks! Anyway I won't be able to merge this before the next third-party/llvm-project bump.

oh, but i hadn't seen your comments on discord about no longer needing that... thanks, looking into it.

@antiagainst

Copy link
Copy Markdown
Member

So it looks these patterns are doing something similar to FlattenMemRefSubspan. FlattenMemRefSubspan is already used on the SPIR-V side; so I don't think doing something similar here will cause a problem. Also after SPIRVVectorizePass, we should not see multi-dim transfer read/write anymore; they should already be unrolled. So fine to me. But just to be safe, we can add the buildkite:benchmark label to see how benchmarks are affected, once the pull request can build properly.

This fixes the codegen for the 2d vector transfers that we need to do
in matmul kernels targeting 2D (matrix) simd operations, for instance
allowing PR iree-org#7778 to achieve nice codegen such as:

```
   11a14: ad 05 00 f1      subs    x13, x13, #1
   11a18: f8 66 c1 ac      ldp    q24, q25, [x23], iree-org#32
   11a1c: 7a 6f c1 ac      ldp    q26, q27, [x27], iree-org#32
   11a20: 41 e3 98 4f      sdot    v1.4s, v26.16b, v24.4b[0]
   11a24: 60 e3 98 4f      sdot    v0.4s, v27.16b, v24.4b[0]
   11a28: 43 e3 b8 4f      sdot    v3.4s, v26.16b, v24.4b[1]
   11a2c: 62 e3 b8 4f      sdot    v2.4s, v27.16b, v24.4b[1]
   11a30: 46 eb 98 4f      sdot    v6.4s, v26.16b, v24.4b[2]
   11a34: 64 eb 98 4f      sdot    v4.4s, v27.16b, v24.4b[2]
   11a38: 53 eb b8 4f      sdot    v19.4s, v26.16b, v24.4b[3]
   11a3c: 70 eb b8 4f      sdot    v16.4s, v27.16b, v24.4b[3]
   11a40: 54 e3 99 4f      sdot    v20.4s, v26.16b, v25.4b[0]
   11a44: 71 e3 99 4f      sdot    v17.4s, v27.16b, v25.4b[0]
   11a48: 57 e3 b9 4f      sdot    v23.4s, v26.16b, v25.4b[1]
   11a4c: 76 e3 b9 4f      sdot    v22.4s, v27.16b, v25.4b[1]
   11a50: 55 eb 99 4f      sdot    v21.4s, v26.16b, v25.4b[2]
   11a54: 72 eb 99 4f      sdot    v18.4s, v27.16b, v25.4b[2]
   11a58: 47 eb b9 4f      sdot    v7.4s, v26.16b, v25.4b[3]
   11a5c: 65 eb b9 4f      sdot    v5.4s, v27.16b, v25.4b[3]
   11a60: a1 fd ff 54      b.ne    0x11a14 <.text+0x11a8>
```
@bjacob
bjacob force-pushed the enable-vector-transfer-flattening branch from 85e8f89 to 8a5e6ba Compare January 21, 2022 20:49
@bjacob
bjacob merged commit c82e77d into iree-org:main Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants