Skip to content

[LLVMCPU] vlen attribute for DataTiledMMAAttr for RISCV + FP16 port - #24858

Merged
egebeysel merged 2 commits into
iree-org:mainfrom
egebeysel:rvv-vlen-dt-mma-attr
Sep 11, 2026
Merged

egebeysel merged 2 commits into
iree-org:mainfrom
egebeysel:rvv-vlen-dt-mma-attr

Conversation

@egebeysel

@egebeysel egebeysel commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

For RISC-V, the vector length per SIMD register is not fixed and is configurable. Therefore, the tile shape of an intrinsic and the total SIMD register bit budget is also parameterized by the vector length. In order for all of these vector length configurations to share a single intrinsic and not duplicate it per-configurable-vlen, we add a vlen parameter to the DataTiledMMAAttr, which in combination with the intrinsic itself gives the exact shape information, as well as the register budget. These are derived from the +zvl*b flags.

Furthermore, add materialization for data-tiled f16 matmul encodings to iree_codegen.inner_tiled on RISC-V V targets with Zvfh, as the first consumer of the vlen attribute parameter. Lowering to LLVM intrinsics is not included.

Towards #24311

Assisted-by: Claude Code

@egebeysel
egebeysel force-pushed the rvv-vlen-dt-mma-attr branch 2 times, most recently from 193d26c to 58467f8 Compare August 27, 2026 14:10
For RISC-V, the vector length per SIMD register is not fixed and is configurable.
Therefore, the tile shape of an intrinsic and the total SIMD register bit budget
is also parameterized by the vector length. In order for all of these vector length
configurations to share a single intrinsic and not duplicate it per-configurable-vlen,
we add a `vlen` parameter to the `DataTiledMMAAttr`, which in combination with the
intrinsic itself gives the exact shape information, as well as the register budget.
These are derived from the `+zvl*b` flags.

Signed-off-by: Ege Beysel <[email protected]>
@egebeysel
egebeysel force-pushed the rvv-vlen-dt-mma-attr branch from 58467f8 to 76846ad Compare August 31, 2026 13:54
Materializes data-tiled f16 matmul encodings to `iree_codegen.inner_tiled` on
RISC-V V targets with Zvfh, as the first consumer of the `vlen` attribute
parameter.

One enum pair covers every vector length. `MMA_RISCV_V_VFMACC_1x8VLsx1_F16_F16`
and its M<->N-swapped sibling describe a 1x8VLsx1 tile where `8VLs` describes
8 * vscale, and `s` stands for static. This results in one vfmacc.vf instruction
with LMUL=2 register group at 16-bit elements, matching mmt4d.

Lowering to LLVM intrinsics is not included.

Signed-off-by: Ege Beysel <[email protected]>
@egebeysel
egebeysel force-pushed the rvv-vlen-dt-mma-attr branch from 76846ad to f1c2d6c Compare August 31, 2026 14:06
@egebeysel
egebeysel marked this pull request as ready for review August 31, 2026 14:06
@egebeysel

Copy link
Copy Markdown
Contributor Author

cc @TMahlatini

@phemashekar phemashekar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@egebeysel
egebeysel merged commit 0df50f9 into iree-org:main Sep 11, 2026
80 of 84 checks passed
@egebeysel
egebeysel deleted the rvv-vlen-dt-mma-attr branch September 11, 2026 10:38
devtbi pushed a commit that referenced this pull request Oct 21, 2026
…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]>
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