Add portable PTX export and verified modern LLVM cleanup - #4
Draft
brandonros wants to merge 58 commits into
Draft
brandonros wants to merge 58 commits into
brandonros wants to merge 58 commits into
Conversation
brandonros
added this pull request to stack #5
September 14, 2026 02:36
brandonros
removed this pull request from stack #5
September 14, 2026 02:39
brandonros
added this pull request to stack #6
September 14, 2026 02:40
brandonros
force-pushed
the
poc/portable-ptx-export
branch
2 times, most recently
from
September 14, 2026 03:00
94b808a to
059beda
Compare
…d point [skip ci]
brandonros
force-pushed
the
poc/portable-ptx-export
branch
from
September 14, 2026 03:33
059beda to
d2104a0
Compare
This was referenced Sep 14, 2026
brandonros
removed this pull request from stack #6
September 15, 2026 00:50
`core::intrinsics::{ctpop, ctlz, cttz, ctlz_nonzero, cttz_nonzero}` are
declared as returning `u32` for every operand width, while the LLVM
intrinsics they lower to return a value as wide as their operand.
`rustc_codegen_llvm` casts the result back; this backend did not.
The oversized value was then stored into the 4-byte result slot. For
`u64`/`u128` that store is out of bounds for the slot and is discarded, the
intrinsic call becomes dead, and the device silently computes `0` -- the
emitted PTX contains no `popc`/`clz` at all. For `u8`/`u16` the store is in
bounds, so the high bytes of the result are left uninitialized. Only width
32 was correct, because there the cast is a no-op.
Wrap the whole arm in a single `intcast` to the intrinsic's result layout
rather than casting in each of the five arms. Casting to an identical type
is a no-op, so the intrinsics in this arm that do return the operand width
(`bswap`, `bitreverse`, `rotate_*`, `saturating_*`) are unaffected, and any
intrinsic added here later is covered automatically.
Add `dis` compiletests pinning the emitted PTX for `u64::count_ones`
(`popc.b64`), `u64::leading_zeros` (`clz.b64`), and the emulated
`u128::count_ones` (two `popc.b64` plus the combining `add`). Before this
change all three kernels compiled down to a bare `ret`.
Also correct the 128-bit row in the feature table, which claimed the
bit-manipulation intrinsics were unsupported.
Fixes Rust-GPU#401
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
(cherry picked from commit 4aa57f2)
Separate configuration, flag generation, Cargo execution, backend loading, artifact parsing, and errors. Remove backend discovery and automatic builds, updating callers, CI, and documentation. Use version-independent LLVM cleanup APIs and dialect-based intrinsic filenames. Add focused builder tests and improve failure diagnostics.
Restore CudaBuilder::new(kernels) with a Cargo-managed backend dependency and retain with_backend for external compilers. An internal proc macro identifies the linked backend library without exposing rustc_private to consumer build scripts or scanning directories. Update examples, CI, documentation, and artifact provenance. Add backend identity tests covering cached builds, feature forwarding, release builds, and stale artifacts.
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.
Upstream review: Rust-GPU#409
Add a GPU-independent Rust-to-PTX exporter, restore default merged-module GlobalDCE on the modern backend, and expose optional verified cleanup pipelines with retention regressions and workload inspection tools. Include modern NVVM shuffle wrappers, guarded-select fixtures, and recorded optimization experiments.
This is the top of stack Rust-GPU#6, based on #3 (
experiment/cuda13.3-llvm21). All 52 export commits were rebased intact apart from the DCE conflict resolution. A separate integration commit connects the exporter, cleanup gates, intrinsic assembly, scripts, and workflow caches to LLVM 21. The existingLlvm19Cleanup/llvm19_*experimental API names remain available for caller compatibility.The checked-in LLVM 19 reports remain historical evidence. They have not been relabeled as LLVM 21 results. Fresh workflow runs are required to validate the combined backend and its generated PTX.
Validation:
ptx_export/llvm21.git diff --checkpasses.git range-diffaccounts for every original export commit; pre-rebase backup refs are retained locally.