Skip to content

fix(mir-importer): lower core::intrinsics::typed_swap_nonoverlapping - #239

Merged
nihalpasham merged 4 commits into
NVIDIA:mainfrom
haixuanTao:fix/typed-swap-intrinsic
Jun 17, 2026
Merged

nihalpasham merged 4 commits into
NVIDIA:mainfrom
haixuanTao:fix/typed-swap-intrinsic

Conversation

@haixuanTao

Copy link
Copy Markdown
Contributor

typed_swap_nonoverlapping::<T>(x, y) — the primitive behind mem::swap / mem::replace — has no MIR body. Lower it as a load/load/store/store crossover; the two pointers are guaranteed non-overlapping, so no temporary is needed. The element type is read off the pointer operand. Dispatched from try_dispatch_intrinsic.

haixuanTao and others added 2 commits June 17, 2026 19:09
`typed_swap_nonoverlapping::<T>(x, y)` — the primitive behind `mem::swap` /
`mem::replace` — has no MIR body. Lower it as a load/load/store/store crossover;
the two pointers are guaranteed non-overlapping, so no temporary is needed. The
element type is read off the pointer operand. Dispatched from `try_dispatch_intrinsic`.
core::mem::swap / mem::replace lower to the typed_swap_nonoverlapping
intrinsic (no MIR body). The kernel swaps two locals and replaces a
sentinel; on main it fails with 'rustc intrinsic
typed_swap_nonoverlapping is not yet supported on the device', and with
the fix every lane returns b*1000 + a, GPU-verified on sm_120.
@nihalpasham
nihalpasham force-pushed the fix/typed-swap-intrinsic branch from c42ffe5 to 6149445 Compare June 17, 2026 13:42
@nihalpasham nihalpasham added bug Something isn't working codegen Device code-generation pipeline (Rust MIR to IR to PTX) intrinsics Device intrinsics and libdevice math mappings labels Jun 17, 2026
@nihalpasham

Copy link
Copy Markdown
Collaborator

LGTM

  • Rebased onto main, added a test that swaps two values. GPU-verified.

@nihalpasham
nihalpasham merged commit 77ab0ae into NVIDIA:main Jun 17, 2026
24 checks passed
meefs pushed a commit to meefs/cuda-oxide that referenced this pull request Sep 30, 2026
…he management (NVIDIA#239)

Second fix round for NVIDIA#239, addressing the adversarial pass on the first
round. All behind experimental-tune; nothing un-gated.

- Required-coverage on resume + a custom searcher: seed the resumed required
  trial into the RequiredFirst cache (both run paths) so the searcher is served
  the known-good measurement instead of re-measuring it, and make
  merge_unclaimed prefer a Measured pre-measurement over a searcher's Invalid of
  the same config — the incumbent can no longer be silently dropped from Output.
- Trial::measured records a non-finite min_ms (not just median) as Invalid; a
  non-finite min serialized to null and was dropped on resume.
- LoggingObjective stamps the config_id captured BEFORE dispatch, so an
  objective that reorders its config vector during measure can't mislabel.
- Resume warns when the caller supplies an arch but the log records none (the
  guard is only as strong as the log's first writer); book examples show .arch().
- Document TrialLog's single-writer-per-path assumption.
- Add the missing retain_kernels re-entrancy regression test.

Signed-off-by: Melih Elibol <[email protected]>
meefs pushed a commit to meefs/cuda-oxide that referenced this pull request Sep 30, 2026
…NVIDIA#225, NVIDIA#185) (NVIDIA#256)

Three squash merges landed from branches that had resolved a merge against
main by keeping pre-merge copies of files, so each one quietly reverted an
earlier, unrelated merge:

- NVIDIA#239 (2482cb9) reverted NVIDIA#240 (1216aef): the const raw-pointer surface
  (as_ptr, program_id/num_programs, the cast_* and get_tensor_base helpers,
  unsafe on load_ptr_tko/store_ptr_tko), the compiler's const-pointer
  typing, the two GPU test files and the matching book and tutorial text.
- NVIDIA#247 (5f5f4c5) reverted NVIDIA#225 (a2843e7): integer division and remainder
  serialization (rounding<zero> and inferred signedness on divi/remi) and
  its test.
- NVIDIA#187 (35a9cc2) reverted NVIDIA#185 (cbf52c0): the flake.nix toolkit-assembly
  hardening and host-arch driver directory derivation.

This re-applies all three verbatim as cherry-picks. The only overlapping
file, cutile-book/guide/performance.md, merges cleanly with NVIDIA#239's own
edits. A per-file scan of the last 60 merges finds no other reversal still
missing at HEAD: NVIDIA#249's removal of the About page was deliberate, and the
two setup-python flips in .github/workflows/pages.yml were re-applied by
the later dependabot bump.

Verified: cargo fmt, cargo build, and the restored GPU tests
(const_pointers, program_id) plus integer_ops, memory_and_atomic_ops and
optimization_hints pass on an RTX 5090 with CUDA 13.3.

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

Labels

bug Something isn't working codegen Device code-generation pipeline (Rust MIR to IR to PTX) intrinsics Device intrinsics and libdevice math mappings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants