Skip to content

Commit 34c0349

Browse files
committed
unprivileged/integrated-matrix: Refactor SAIL pseudocode into shared helpers
Extract common patterns from the 11 GEMM instruction SAIL blocks into 5 shared helper functions, eliminating ~300 lines of duplication: decode_gemm_geometry(W, vl_divisor_is_lambda) — unified preamble that decodes SEW, LMUL, lambda, computes K_eff/M/N/MUL_C, and checks VL divisibility and MUL_C legality. Parameterised by the widening factor W and the VL divisor convention (K_eff vs lambda). read_block_scales(vm, i, j, s, R, EEW_C, fmt_C, rm) — reads and unpacks paired E8M0 block scales from v0, returning the combined scale and a NaN flag. When vm=1, returns (1.0, false). fp_block_dot(i, j, k_lo, k_hi, g, fmt_A, fmt_B, fmt_C, rm, vs1, vs2) — FP inner product over a K-dimension block with widening. int_block_dot(i, j, k_lo, k_hi, g, signed_A, signed_B, vs1, vs2) — exact signed/unsigned integer inner product over a block. check_microscaling_legality(W, LMUL, EEW_C, lambda) — checks the SEW×λ≥16 and BS=16 LMUL constraints. Each instruction body now consists of instruction-specific checks (vm=0 reserved, SEW restrictions, altfmt checks) followed by a call to decode_gemm_geometry and a compact main loop using the helpers. Tile load/store instructions (vmtl, vmts, vmttl, vmtts) are unchanged.
1 parent 31c72e7 commit 34c0349

File tree

1 file changed

+319
-626
lines changed

1 file changed

+319
-626
lines changed

0 commit comments

Comments
 (0)