Repository navigation
feat(llvm-export): AsmKind enum for inline asm optimization hints - #195
Merged
Merged
Conversation
honeyspoon
force-pushed
the
upstream-pure-inline-asm
branch
from
June 12, 2026 21:32
b8fc0cf to
2aabffd
Compare
4 tasks done
honeyspoon
force-pushed
the
upstream-pure-inline-asm
branch
from
June 15, 2026 17:55
2c6a4df to
4e419b5
Compare
The two orthogonal GPU axes (convergent × side-effects) produce exactly four valid combinations. ConvergentPure covers warp-collective ops like shfl.sync and vote.sync that depend on which threads are active but have no observable side effects beyond their register output. No further variants are needed because the remaining LLVM inline asm axes do not apply to PTX: - Memory effects (nomem/readonly): unnecessary — our inline asm is either pure register-to-register or full side-effecting; loads/stores go through proper LLVM ops, not inline asm. - noreturn/may_unwind: PTX inline asm always returns, never unwinds. - preserves_flags/nostack: CPU concepts with no PTX equivalent.
… bf16x2 to AsmKind::Pure The asm_kind docblock was accidentally prepended to asm_kind_opt in the original PR. Remove the stray block so asm_kind_opt has a single, accurate doc comment. Migrate convert_fma_bf16x2 from InlineAsmOp::new(..., false) to InlineAsmOp::build(..., AsmKind::Pure), covering the bf16x2 FMA op added by PR NVIDIA#191 after this branch was cut. The PTX instruction is a pure register-to-register FMA with no memory side effects and no warp synchronization, so Pure is the correct classification.
nihalpasham
force-pushed
the
upstream-pure-inline-asm
branch
from
June 18, 2026 05:48
4e419b5 to
d6b6516
Compare
Collaborator
|
Thanks for this. LGTM I quite like the layered two small fixes:
Reviewer note: verified, |
Replace the plain Rust enum stored as StringAttr with a proper #[pliron_attr(name = "llvm.asm_kind")] type. This follows the pliron best practice: domain-specific attribute types should use the pliron attribute infrastructure, not encode as StringAttr. build() now calls attributes.set(key, kind) directly with the typed AsmKind value, and asm_kind_opt() retrieves it via attributes.get::<AsmKind>() instead of string-matching against a serialized StringAttr.
This was referenced Jun 19, 2026
meefs
pushed a commit
to meefs/cuda-oxide
that referenced
this pull request
Sep 30, 2026
Closes the async-vs-sync launch latency gap: Async was ~22us at N=1, and it's now within noise of sync at every pipeline length. Signed-off-by: Melih Elibol <[email protected]>
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
Replace the
convergent: boolparameter on inline asm with anAsmKindenum that captures the two orthogonal GPU axes — convergent (thread-set dependent) × side effects (observable state changes):Maps to LLVM IR:
sideeffectconvergentConvergentConvergentPureSideEffectPureSuggested labels:
refactor,llvm-export,IR-lowering,codegenMotivation
Inline asm ops currently only model
convergent: bool. Thesideeffectflag is hardcoded — every inline asm call blocks LLVM from optimizing it, even for pure data conversions likecvt.rn.bf16x2.f32that have no observable side effects.Rust's own
asm!macro (RFC 2873) separates side effects (pure) from memory behavior (nomem/readonly) as orthogonal axes. This PR applies the same principle to GPU inline asm, where the relevant axes are convergence and side effects.This is complementary to #215 (
ptx_asm!macro):AsmKindclassifies compiler-generated NVVM intrinsic asm, whileptx_asm!handles user-written inline PTX. The export layer detects which path produced eachInlineAsmOpand reads the appropriate attributes —AsmKindtag for NVVM ops,sideeffect/convergentbools forptx_asm!ops.Why four variants is the complete set
The remaining LLVM inline asm axes do not apply to PTX:
nomem/readonly): unnecessary — cuda-oxide's inline asm is either a pure register-to-register conversion or a full side-effecting op. Loads and stores go through proper LLVM ops, not inline asm.noreturn/may_unwind: PTX inline asm always returns and never unwinds.preserves_flags/nostack: CPU concepts (flags register, stack red zone) with no PTX equivalent.Implementation
Follows the existing
InlineAsmOpExttrait pattern inllvm-export:llvm-export/src/lib.rs:AsmKindenum +InlineAsmOpExt::build()constructor +asm_kind()/asm_kind_opt()queries. Stores the kind as aStringAttron the op (pliron'sInlineAsmOponly modelsconvergentnatively).llvm-export/src/export/ops.rs:asm_kind_opt()checks for theAsmKindtag; if absent (i.e., aptx_asm!op), falls back to reading the individualsideeffect/convergentattributes. Exhaustive matching ensures new variants are handled.mir-lower/intrinsics/: All call sites updated —new_convergent(...)→build(..., AsmKind::Convergent), rawInlineAsmOp::new(..., false)→build(..., AsmKind::Pure).Testing