Add prmt.b32 byte permute intrinsic#333
Open
honeyspoon wants to merge 1 commit into
Open
Conversation
Adds the PTX `prmt.b32` byte-permute instruction across all four compiler layers (cuda-device, dialect-nvvm, mir-importer, mir-lower). The `prmt` instruction selects and rearranges four bytes from two 32-bit source registers according to a control mask, producing a single 32-bit result. This is the foundation for efficient byte manipulation in quantization, dequantization, and format conversion kernels. ```ptx prmt.b32 %d, %a, %b, %c; ``` Includes dialect-nvvm verifier tests and mir-lower lowering tests. Part of tracking issue NVlabs#274 (Phase 4). Signed-off-by: abder <bobmatt911@gmail.com>
This was referenced Jul 3, 2026
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.
Summary
Adds the PTX
prmt.b32byte-permute instruction across all four compiler layers (cuda-device,dialect-nvvm,mir-importer,mir-lower).The
prmtinstruction selects and rearranges four bytes from two 32-bit source registers according to a control mask, producing a single 32-bit result. Each 4-bit nibble of the control value indexes one of the eight source bytes (four from each operand). This is the foundation for efficient byte manipulation in quantization, dequantization, and format conversion kernels.Available on all SM architectures (no minimum floor).
Part of tracking issue #274 (Phase 4).
What changed
cuda-device: Addedprmtmodule withprmt_b32user-facing stub.dialect-nvvm: AddedPrmtOpoperation with verifier tests (3 operands, 1 result, register-only).mir-importer: Added dispatch table entry andprmtintrinsic emitter module.mir-lower: Added lowering conversion using inline asm with=r,r,r,rconstraints.prmt.b32instruction.Testing
cargo fmt --checkcleancargo test -p dialect-nvvm --all-targets— verifier tests passcargo test -p mir-lower --all-targets— lowering tests passcargo oxide rune2e on GPUChecklist
crates/cuda-bindings/changes