[stinkytofu] Use typed enums for DPP and MFMA modifier fields#7258
[stinkytofu] Use typed enums for DPP and MFMA modifier fields#7258darrenhsieh-amd wants to merge 2 commits intodevelopfrom
Conversation
KKyang
left a comment
There was a problem hiding this comment.
Nice cleanup — typed enums are a clear improvement over raw ints/strings. A few things:
-
Stale README:
tools/stinkytofu-opt/README.mdline 314 still shows the oldmod.mfmaserialization format (inputPermute,scaleStr,negStr,neg_lo,neg_hi). Should be updated to match the new format. -
Unused parameter in
handleMXMFMAModifiers: After the refactor,mxmfmaInstis never read — the function only parses frominstString. If string parsing is the intended approach, therocisa::MXMFMAInstruction*parameter should be removed from the signature (and callers updated). If the structured fields from rocisa are more reliable, consider using them instead of string extraction. -
No range check in DPP builder helpers (nit): e.g.
dppRowShr(16)silently produces0x120which isROW_ROR0— a valid but wrongDppCtrl. A debug assert onn >= 1 && n <= 15would be cheap insurance.
…re encoding DPPModifiers previously carried only 3 ints (row_shr, row_bcast, bound_ctrl) — too narrow for the actual dpp_ctrl encoding and dropped quad_perm, row_shl, row_share, row_xmask, DPP8, etc. Replace with a DppCtrl enum and full field set matching the hardware, plus deserialize support that was previously missing.
… types MFMAModifiers previously carried matrix format and neg-bit data as raw strings (inputPermute, negStr, scaleStr) plus redundant rocisa-pipeline ints (isMXMFMA, mxInstType, mxScaleAType, mxScaleBType). Replace with typed MatrixFmt/MatrixScaleFmt enums and an MFMANegBits sub-struct, and move matrix data/scale formats to a separate MatrixFmtModifiers so the cost-override table can match on it as a first-class Modifier type.
8562152 to
681d260
Compare
|
Thanks for the feedback. |
Motivation
The DPP and MFMA modifier fields were raw ints and free-form strings — hardware semantics buried in field names, re-parsed at every use. Move DPP and MFMA modifier fields onto typed enums for compile-time safety and direct hardware mapping. The new enums also cover the full hardware encoding space (all 9-bit dpp_ctrl shapes, the full F8F6F4 matrix-format family), where the pre-refactor int/string fields only expressed the partial set earlier code happened to need.
Technical Details
Commit 1 — DPP:
Commit 2 — MFMA:
Test Plan
st unit tests(including filecheckes) all passed.
codegen tests all passed.
Submission Checklist