Repository navigation
Description
WIP (& AI generated summary)
Tracking inner_tiled MMA codegen vs the existing mmt4d ukernel path on RISC-V V. Hardware is a SpaceMiT X60 (VLEN=256). First-iteration codegen is not required to be on-par; this issue is the dashboard. Per-dtype absolute ms, CPU/wall, and follow-ups live in child issues.
Towards #24311. Split from #24926 review. F32 codegen: #24933.
Setup
-
Board: SpaceMiT X60, 8 cores @ 1600 MHz, VLEN=256 (
v/zve64d/zvfh) -
Tool:
iree-benchmark-module,--benchmark_repetitions=10 -
Metric:
BM_matmul/process_time/real_time_meanTime (wall ms). Ratio = inner_tiled / ukernel. Also record CPU/wall as a threading sanity check (~1 at 1 thread, rising toward 4 and 8). -
Thread sweep, matched compile + runtime:
threads compile run 1 --iree-llvmcpu-disable-distribution=true--device=local-sync4 --iree-llvmcpu-number-of-threads=4--device=local-task --task_topology_group_count=48 --iree-llvmcpu-number-of-threads=8--device=local-task --task_topology_group_count=8 -
Shared compile flags (same triple/abi/features on both paths):
- inner_tiled:
--iree-opt-data-tiling --iree-llvmcpu-enable-ukernels=none --iree-llvmcpu-enable-inner-tiled=true - ukernel:
--iree-opt-data-tiling --iree-llvmcpu-enable-ukernels=all --iree-llvmcpu-enable-inner-tiled=false
- inner_tiled:
-
Features:
+m,+a,+f,+d,+c,+v,+zvl256bplus the dtype extras -
Shapes: 64×64×64, 256×256×256, 81×41×19, 540×516×332
Children
- f32 ([Codegen][CPU] Add RISC-V V f32 vfmacc.vf inner_tiled MMA. #24933)
- f16 ([Codegen][CPU] Lower RISC-V V f16 vfmacc, vfwmacc, and Zvfhmin inner_tiled MMA. #25000)
- bf16 ([Codegen][CPU] Add RISC-V V bf16 vfwmaccbf16 inner_tiled MMA. #25120 )
- i8 CASTI16 ([Codegen][CPU] Add RISC-V V i8 CASTI16 inner_tiled MMA #25357)
Standing
Cells are 1 / 4 / 8 thread ratios (ukernel wall / inner_tiled wall). >1 means inner_tiled is faster. the f32 row is a re-run after the per-K accumulator insert/extract left the inner loop.
| dtype | small 64³ | medium 256³ | rect 81×41×19 | large 540×516×332 | notes |
|---|---|---|---|---|---|
| f32 | 1.66 / 1.06 / 1.12× | 1.21 / 1.04 / 0.96× | 1.88 / 1.24 / 1.05× | 1.26 / 0.77 / 0.64× | f32 vfmacc.vf (intrinsics_m = 6). 1-thread wins (large 26.4 vs 33.2 ms). 4/8-thread large still behind: 11.2 / 9.39 ms vs ukernel 8.57 / 6.00. Distribution tiles stay 1 |
| f16 native | 1.49 / 0.88 / 0.87× | 1.75 / 0.36 / 0.34× | 1.46 / 1.05 / 0.93× | 1.78 / 0.36 / 0.40× | +zvfh, f16 vfmacc (intrinsics_m = 14). 1-thread wins. 4-thread large wall 19.6 ms vs 13.6 ms at 1 thread. Ukernel often widens to f32 |
| f16 VFWMACC | 1.43 / 0.91 / 0.95× | 1.15 / 0.37 / 0.41× | 1.74 / 1.14 / 1.05× | 1.42 / 0.36 / 0.41× | +zvfh, vfwmacc into f32 (intrinsics_m = 7). Closer ukernel match. 1-thread wins. 4-thread large wall 23.1 ms vs 19.8 ms at 1 thread |
| f16 CASTF32 | 0.83 / 1.13 / 1.02× | 0.76 / 0.66 / 0.62× | 0.93 / 1.02 / 1.13× | 0.74 / 0.76 / 0.89× | +zvfhmin only, extf then f32 vfmacc (intrinsics_m = 6). Not the +zvfh f32-acc path. Medium/large behind. Large scales 222 → 32.8 ms |
| f16 WIDENF32 | 0.81 / 1.20 / 1.04× | 0.75 / 0.75 / 0.70× | 0.79 / 1.05 / 1.05× | 0.73 / 0.85 / 0.99× | +zvfhmin only, f16 acc via f32 vfmacc (intrinsics_m = 6). Large 8-thread ~parity (0.99×). Medium stays behind |
| bf16 | |||||
| i8 |
Activity
egebeysel commentedon Sep 17, 2026
Thanks for the initial PR on F32 and the performance numbers!
Could you maybe briefly take a look at why we're leaving so much performance on the table and try and reason about it? I don't think the unrolling factor of 6 (inner_tiled) vs 7 (mmt4d) is the reason for it. It might be related to the memory layout transformation ops
pack -> expand (-> transpose)or(transpose ->) collapse -> unpacknot being vectorized and being scalarized as well.I see that we're utilizing
vector.scalable.insert/extractand some broadcast instructions while lowering the inner_tiled op to the intrinsics. There might be something related to that causing the inefficiencies. Could you take a look at the generated assembly for a matmul example and try and reason about it maybe?TMahlatini commentedon Sep 18, 2026
I will dig into it and share an update soon
TMahlatini commentedon Sep 28, 2026
@egebeysel I noted my findings from the disassembly here: #24933 (comment)
[Codegen][CPU] Add RISC-V V f32 vfmacc.vf inner_tiled MMA. (#24933)
egebeysel commentedon Oct 7, 2026
Hmm, it's a bit odd to have
1.26 / 0.77 / 0.64×for the large case. Maybe we should take a look at this, because this might actually come from some tile size selection heuristic for the distribution tiles that is very ineffective for theinner_tiledcase in comparison to themmt4dones. I wouldn't expect scaling problems otherwise 🤔TMahlatini commentedon Oct 7, 2026
Yeah your read is right.
setRootConfigforiree_codegen.inner_tiledsets every parallel distribution tile to 1.getMmt4dLoweringConfigstill picks M1/N1 divisors under the 256 KiB budget, and both paths then go through the same workgroup split. That tile is the 4/8-thread large drop.I'll file a separate issue to port that cost model onto inner_tiled.
[Codegen][CPU] Lower RISC-V V f16 vfmacc, vfwmacc, and Zvfhmin inner_…
shuangjuliu commentedon Nov 3, 2026
@egebeysel
I have created a PR to port that cost model onto inner_tiled.
Related PR: #25130
[Codegen][CPU] Cover the iree-org#24932 benchmark matrix in inner_til…
[Codegen][CPU] Cover the iree-org#24932 benchmark matrix in inner_til…
[Codegen][CPU] Add RISC-V V bf16 vfwmaccbf16 inner_tiled MMA. (#25120)
[Codegen][CPU] Cover the iree-org#24932 benchmark matrix in inner_til…