Repository navigation
[Codegen][CPU] Add RISC-V V f32 vfmacc.vf inner_tiled MMA. - #24933
Conversation
3e65978 to
9bdc4a4
Compare
phemashekar
left a comment
There was a problem hiding this comment.
Thanks for the PR and for splitting it out of #24926! Since Ege is on vacation, I'm picking up the review.
In general, the lowering looks right to me. I've left some small inline comments.
The one thing I'd like addressed before landing this is Ege's ask here: #24932 (comment). Could you take a look at the disassembly and see what's causing the performance gap compared to ukernels? I think it'd help to start with the inner loop of the matmul dispatch :))
Hi @phemashekar, sorry it took me a while to get back at Ege on that comment still working on it. Was caught up in the past couple days but will push a update soon. still running some local tests and collecting numbers. |
following up on the disassembly the inner loop was a great start. on one thread for both small and large shapes, every K step zero-padded the accumulator and did a tail-undisturbed Per K, before fix: one Now the lowering hoists that accumulator insert/extract out of K, pads with per K, after: 1 same loop in mmt4d ukernel for reference: 1 I reran the same X60 sweep referenced here #24932 and below are the results. note ratio is flipped from the original dashboard, its ukernel wall / inner_tiled wall (more intuitive).
1 thread inner_tiled is faster on every shape. the remaining loss is 4/8 thread large. I will update the standing table on this issue. |
|
@phemashekar could you please take a look at the updates when you get the chance and start the ci tests? thanks! |
phemashekar
left a comment
There was a problem hiding this comment.
Thanks for the ping, I somehow missed it! the results look much better now, nice recovery. Just a few small comments :)
|
@phemashekar I have applied the feedback and fixed the failing CI run. |
|
@TMahlatini, the CI seems a bit flaky – could you try a rebase please? |
yeah sure |
Lower MMA_RISCV_V_VFMACC_*_F32_F32 to llvm.riscv.vfmacc. N is vlen/8. Introduce lowerRiscvVFmaccLike. Restrict RISC-V inner_tiled e2e to --shapes=small (iree-org#24593). Towards iree-org#24311 Signed-off-by: Terence <[email protected]> Co-authored-by: Cursor <[email protected]>
f32 accs are now scalable across the reduction loop and now using poison with tail/mask-agnostic pollicy to avoid redundant vector moves. Signed-off-by: Terence <[email protected]>
Signed-off-by: Terence <[email protected]>
c3aa030 to
7cdba91
Compare
…tiled MMA. (#25000) Lowers the RISC-V V f16 `inner_tiled` MMA paths. Native f16 enums are already on main from #24858. This adds lowering, the widening `vfwmacc.vf` pair, and the `+zvfhmin`-only fallbacks. All of them reuse `lowerRiscvVFmaccLike` and the hoisted accumulator legalization from #24933. Tile N is `vlen/8`. | Encoding | `+zvfh` | `+zvfhmin` only | | --- | --- | --- | | f16×f16→f16 | `llvm.riscv.vfmacc` (`MMA_RISCV_V_VFMACC_*_F16_F16`) | `extf` the accumulator to f32, f32 `vfmacc`, `truncf` back (`*_F16_F16_WIDENF32`) | | f16×f16→f32 | `llvm.riscv.vfwmacc` (`MMA_RISCV_V_VFWMACC_*_F32_F16`) | `extf` both panels, then f32 `vfmacc` (`*_F32_F16_CASTF32`) | `+zvfh` implies `+zvfhmin`. When both are legal, the earlier enum wins: native `vfmacc` for an f16 accumulator, `vfwmacc` for an f32 accumulator. At VLEN=256 the cost model picks `intrinsics_m` 14 (native), 7 (`vfwmacc`), and 6 (both `+zvfhmin` paths). CASTF32 and WIDENF32 bill the widened f32 vector operand as f32. Performance is tracked on #24932. On the X60 (VLEN=256), 1-thread inner_tiled is faster than the mmt4d ukernel for native f16 and `vfwmacc`. The 4-thread and 8-thread large shapes are still slower. Native f16 is non-widening `vfmacc`; the f16 ukernel widens with `vfwmacc`, so that ratio is not the same instruction sequence. `vfwmacc` is the closer comparison. Assisted-by: Cursor Towards #24311 --------- Signed-off-by: Terence <[email protected]> Co-authored-by: Cursor <[email protected]>
Summary
Lowers RISC-V V f32
inner_tiledMMA (MMA_RISCV_V_VFMACC_*_F32_F32) tollvm.riscv.vfmacc(vfmacc.vf). Tile N isvlen/8. Introduces shared helperlowerRiscvVFmaccLike.This is the first stacked dtype PR from #24926 review. Performance will be tracked here #24932
Assisted-by: Cursor
Towards: #24311