Skip to content

test(mir-lower): Add representative unit tests for MIR cast lowering - #302

Merged
nihalpasham merged 2 commits into
NVIDIA:mainfrom
uurl:test/mir-cast-lowering
Jun 29, 2026
Merged

nihalpasham merged 2 commits into
NVIDIA:mainfrom
uurl:test/mir-cast-lowering

Conversation

@uurl

@uurl uurl commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Closes #301

Part of #303.

Summary

Adds six representative tests for existing MIR cast lowering. The tests build
minimal MIR functions, run the normal lower_mir_to_llvm pass, and inspect the
selected LLVM operations.

What changed

  • Signed integer widening lowers to llvm.sext.
  • Unsigned integer widening lowers to llvm.zext.
  • Integer narrowing lowers to llvm.trunc.
  • Unsigned integer-to-float lowers to llvm.uitofp.
  • Signed float-to-integer lowering declares and directly calls
    llvm_fptosi_sat_i32_f32.
  • Pointer address exposure lowers to llvm.ptrtoint.

Maintainer hardening

The saturation test now connects the emitted call to its declaration by
requiring a direct callee named llvm_fptosi_sat_i32_f32. This prevents an
unrelated call plus an unused correct declaration from passing.

Testing

  • cargo fmt --all -- --check
  • cargo test -p mir-lower cast::tests --lib
  • cargo test -p mir-lower
  • cargo clippy --workspace -- -D warnings
  • Adversarial wrong-callee mutation fails the strengthened test

Checklist

  • Test coverage only; no compiler behavior change
  • Contributor authorship and DCO sign-off preserved
  • No crates/cuda-bindings/ changes

@nihalpasham
nihalpasham force-pushed the test/mir-cast-lowering branch from 219b84a to bcd22e5 Compare June 29, 2026 10:29
@nihalpasham nihalpasham added QoL-improvement Quality-of-life improvement; not a correctness fix IR-lowering Lowering between dialects (dialect-mir to LLVM dialect) tests Adds or improves test coverage labels Jun 29, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator

Thanks for the PR. I see the cast matrix is well chosen. I layered a maintainer assertion on top that proves the saturation call directly targets llvm_fptosi_sat_i32_f32. A wrong target now fails the test. All six focused tests and the full suite pass.

closes #301, and supplies the cast portion of #303.

@nihalpasham
nihalpasham merged commit 479868a into NVIDIA:main Jun 29, 2026
28 checks passed
@uurl
uurl deleted the test/mir-cast-lowering branch July 20, 2026 18:40
meefs pushed a commit to meefs/cuda-oxide that referenced this pull request Sep 30, 2026
…submissions (NVIDIA#302)

Per launch, each tensor argument cost two heap allocations (an Arc<()>
access id and a Box<dyn Send> owner); access ids are now u64 counters and
leases are stored inline in the submission. Graph replays walked every
recorded context and re-registered every recorded resource; the recorded
resources are now frozen and deduplicated by storage at capture time, and
a replay reacquires each distinct buffer once. Lifetime and cross-stream
conflict semantics are unchanged: every in-flight access is still
registered on its storage and released when the submission completes.

Host-only enqueue cost (RTX 5090, benches/host_overhead):
  tiny 4-tensor launch   1.954 -> 1.884 us (pre-NVIDIA#275: 1.640)
  32-node graph replay  14.68  -> 1.67  us (pre-NVIDIA#275: 1.139)

Signed-off-by: Melih Elibol <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

IR-lowering Lowering between dialects (dialect-mir to LLVM dialect) QoL-improvement Quality-of-life improvement; not a correctness fix tests Adds or improves test coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add representative unit tests for MIR cast lowering

2 participants