[AIROCMLIR-602] Add MHAL dialect lit coverage#2394
Draft
bogdan-petkovic wants to merge 6 commits into
Draft
Conversation
Signed-off-by: bogdan-petkovic <bpetkovi@amd.com>
Signed-off-by: bogdan-petkovic <bpetkovi@amd.com>
Signed-off-by: bogdan-petkovic <bpetkovi@amd.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #2394 +/- ##
===========================================
+ Coverage 79.50% 82.40% +2.89%
===========================================
Files 100 120 +20
Lines 31016 42830 +11814
Branches 4819 7112 +2293
===========================================
+ Hits 24659 35291 +10632
- Misses 4245 4881 +636
- Partials 2112 2658 +546
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The MHAL dialect (vendored under external/mlir-hal/) currently has very thin lit coverage, roughly 32% of its source lines are exercised, and one of its conversion passes (--convert-mhal-to-gpu) was not even reachable from rocmlir-opt because its tablegen-generated registration function was never called. This PR closes both gaps:
Wires registerMHALConversionPasses() into rocMLIR's CLI-pass registration entry point, so --convert-mhal-to-gpu is now discoverable from rocmlir-opt --help and can be driven by lit tests.
Adds eight new lit tests under mlir/test/Dialect/MHAL/ that systematically exercise every MHAL transform pass, the MHAL→GPU conversion pass, and all three custom MHAL attributes (round-trip).
The goal is to catch regressions in MHAL parsing/printing and in the pass pipeline at lit time, instead of requiring a full host+device E2E build, and to make any future refactor in external/mlir-hal/lib/Dialect/MHAL/Transforms/ and lib/Conversion/MHALToGPU/ immediately observable.
Technical Details
Source change — mlir/include/mlir/InitRocMLIRPasses.h (+5 lines)
MHAL declares its passes in two separate tablegen groups: Dialect/MHAL/Transforms/Passes.td (registered via registerMHALPasses() in vendored InitMHALPasses.h) and Conversion/MHALPasses.td with -name MHALConversion (registered via the generated registerMHALConversionPasses()). The conversion group was implemented but never wired into any registration entry point, so --convert-mhal-to-gpu was unreachable from rocmlir-opt. This PR adds the missing registerMHALConversionPasses() call inside registerRocMLIRPasses(), with an inline comment explaining the asymmetric tablegen grouping.
The fix is intentionally in rocMLIR-owned code (not in external/mlir-hal/) so the whole patch stays under a single AIROCMLIR-602 commit and adds no merge surface to the in-flight MHAL decoupling work (#2333, #2325).
Tests — 8 new files under mlir/test/Dialect/MHAL/ (+~1000 lines)
attrs-roundtrip.mlir — Custom parse/print for #mhal.target_obj, #mhal.kernel_pkg, #mhal.prefill. Pretty- and generic-printer round-trip; all TargetObjectType and TargetType keywords.
bufferize.mlir — --mhal-bufferize post-#2333 no-op path; preserves MHAL arg attrs and mhal.targets.
convert-mhal-to-gpu.mlir — --convert-mhal-to-gpu: alloc / memcpy / launch / wait; write_access copy-back; GPU-over-CPU selection; explicit negative checks for no-targets and CPU-only callees; scalar operand path.
drop-metadata.mlir — --mhal-drop-binary-metadata: strips properties/kernels; fat-binary across two arches; idempotence; top-level-only isolation.
package-targets.mlir — --mhal-package-targets: single-arch and multi-arch (CHECK-DAG); multiple binaries per kernel module; unmarked nested module and dangling original_func skipped.
prefill.mlir — --mhal-prefill: one/many prefills; f16/i8/i32 element-type matching with non-zero argIdx; missing properties key/dict; mixed-attr dyn_cast filter.
select-targets.mlir — --mhal-select-targets happy paths (4 RUN configurations): arch filter, type filter, last-match-wins, empty target-types wildcard, triple-vs-chip-only SystemDevice::isCompatible.
select-targets-error.mlir — --mhal-select-targets error path with --verify-diagnostics: CPU-only-with-GPU-required, GPU-arch-mismatch, multi-non-matching-packages.
Each test file's leading // COM: comments cite the exact external/mlir-hal/lib/... source file (and line numbers, where relevant) being exercised.
Test Plan
PR CI
Test Result
Submission Checklist