Skip to content

[Codegen][CPU] Pick inner-tiled unroll factors from a register budget. - #24303

Merged
bjacob merged 1 commit into
mainfrom
users/bjacob/inner-tiled-unroll-factors
Apr 30, 2026
Merged

bjacob merged 1 commit into
mainfrom
users/bjacob/inner-tiled-unroll-factors

Conversation

@bjacob

@bjacob bjacob commented Apr 29, 2026 •

Copy link
Copy Markdown
Collaborator

Replace the hard-coded intrinsics_m = intrinsics_n = 1 from #24289
with a simple cost model based on maximizing arithmetic intensity
under the constraint of fitting in register space.

AI: Claude Opus 4.7

Base automatically changed from users/bjacob/inner-tiled-materialize-encoding to main April 29, 2026 17:19
@bjacob
bjacob force-pushed the users/bjacob/inner-tiled-unroll-factors branch from 97453de to 5931ff3 Compare April 29, 2026 18:53
Replace the hard-coded `intrinsics_m = intrinsics_n = 1` from the
previous commit with a cost model that, for the intrinsic/orientation
already chosen by chooseIntrinsic, picks the largest power-of-two
unroll factors such that the three tiles (ACC + LHS + RHS) still fit
in the target's architectural vector register file, breaking ties
with arithmetic intensity (effM*effN)/(effM+effN) so approximately-
square tiles win.

Introduces:
- `getRegisterSpaceBytes(intrinsic)` returning the bit capacity of the
  three-tile budget; scalable ISAs (SVE/SVE2) are treated as their
  128-bit VL minimum.
- `po2UnrollCap` to round the static-matmul-extent cover count down to
  a power of two (and fall back to the budget for dynamic dims).
- `chooseUnrolling` as Phase 2 of `chooseCpuInnerTiledMmaForEncoding`.

Updates materialize_encoding_x86_64.mlir to reflect the new unroll
choices (e.g. intrinsics_m = 16 on dynamic AVX-512 f32 matmul).

Made-with: Cursor
Signed-off-by: Benoit Jacob <[email protected]>
@bjacob
bjacob force-pushed the users/bjacob/inner-tiled-unroll-factors branch from 5931ff3 to b6b6a44 Compare April 29, 2026 18:54
@bjacob
bjacob marked this pull request as ready for review April 29, 2026 18:58

@egebeysel egebeysel 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.

Looked super interesting so I decided to give it a quick review and leave some comments/questions :) Thanks!

@bjacob
bjacob merged commit 5872dc2 into main Apr 30, 2026
65 of 66 checks passed
@bjacob
bjacob deleted the users/bjacob/inner-tiled-unroll-factors branch April 30, 2026 18:09
@bjacob bjacob mentioned this pull request Apr 30, 2026
25 of 28 tasks
jerryyin pushed a commit that referenced this pull request May 7, 2026
#24303)

Replace the hard-coded `intrinsics_m = intrinsics_n = 1` from #24289
with a simple cost model based on maximizing arithmetic intensity
under the constraint of fitting in register space.

AI: Claude Opus 4.7

Signed-off-by: Benoit Jacob <[email protected]>
RattataKing pushed a commit to RattataKing/iree that referenced this pull request May 27, 2026
iree-org#24303)

Replace the hard-coded `intrinsics_m = intrinsics_n = 1` from iree-org#24289
with a simple cost model based on maximizing arithmetic intensity
under the constraint of fitting in register space.

AI: Claude Opus 4.7

Signed-off-by: Benoit Jacob <[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