Repository navigation
fix(mir-lower): support packed AS3 carrier local projections - #1327
Conversation
Signed-off-by: Raul Estrada <[email protected]>
Signed-off-by: nihalpasham <[email protected]>
There was a problem hiding this comment.
The carrier-local contract is sound for the narrow #1036 case. The complete address-use graph is checked before lowering facts are attached, and local memory keeps the generic pointer representation while MIR values keep shared-pointer semantics.
I added four regressions for whole-value conversion directions, forged storage facts, storing a carrier address, and nested projections. No production change was needed.
At e92236ef, all 450 mir-lower unit/lowering tests passed, along with strict Clippy and formatting. On B200:
packed_aggregate_abipassed through LLVM NVPTX, including memcheck and synccheck.- A narrow mutable-local probe passed with full device debug, which disables mem2reg, through LLVM NVPTX and modern libNVVM. Memcheck reported 0 errors on both; LLVM synccheck also reported 0 errors.
- The same narrow probe passed normal modern libNVVM and legacy libNVVM/SM90 builds under memcheck.
This clears the representation question for #1036. Nested/multiple shared-pointer leaves, arrays and arbitrary carrier-address transport remain outside this local-storage contract; #1219 is not fixed as a whole. The PR remains a draft for your decision.
At e92236ef, hosted tests, lint/format checks, guards, docs/book and example compilation passed. CodeQL was still running at the final review check.
…4 restored) Rebase onto upstream ec4aa47 (74 commits) changed the exported .ll shapes; four adaptations, each semantics-preserving: - Step 4: tid.y/tid.z -> llvm.amdgcn.workitem.id.y/z (upstream NVIDIA#1311 computes in-block rank via 3-D coords; on 1-D launches both sides return 0). Declares added to the mapped-strip list. - Step 10: accept dynamic membermask ((1<<live)-1 from the partial-warp collectives) and clamp=0 for .up (PTX clamp is the min-source-lane bound for .up; ds_bpermute's data movement is mask-independent and the convergent marker carries the all-lanes-execute requirement). - Step 12d: parse asm operands with top-level comma splitting - NVIDIA#1327 packed-as3 emits constant-expression pointers (ptr addrspacecast (ptr addrspace(3) @sym to ptr)) that the old [^,)] captures could not span. - Step 12e: panic trap is now inline PTX asm "trap;" (NVIDIA#1309) which the AMDGPU backend rejects; map to llvm.trap() (lowers to s_trap). Batch tool: select artifacts by exact name - the old "*.opt.ll" glob also matched the integrated pipeline's leftover *.amdgcn.preopt.opt.ll (sorted first), so the Python dimension double-rewrote the wrong file; the recorded 9/17 was measurement poisoning as much as shape drift. Verified: batch 14/14 llc-pass; tests/test_gfx1030.py 14 passed.
…tions Mirror of the Python-pipeline adaptation (35bed77) on the integrated path, for the two shapes the Rust prep pass also meets: - Step 10 envelope: dynamic membermask accepted (upstream NVIDIA#1311 partial-warp collectives emit (1<<live)-1 as SSA; ds_bpermute's data movement is mask-independent, convergent survives), and .up clamp=0 accepted (PTX clamp bounds the lowest source lane for .up; the other modes keep width-1=31). Literal non-(-1) masks still fall through for llc to reject explicitly. - Step 12e: panic trap is inline PTX asm post-NVIDIA#1309 and the AMDGPU backend rejects the mnemonic; map the exact shape to llvm.trap() (s_trap on gfx1030). 12d's store/load operand parsing already handled NVIDIA#1327 constant- expression pointers via split_top_level_commas (no change needed). Verified: dynamic-mask up@0 + trap-asm unit tests; lib 1252 green.
#1330) Fixes #1094 ## Summary Extend the packed-AS3 carrier-local contract introduced by #1327 to support: * multiple direct AS3 pointer leaves; * AS3 leaves nested inside structs and tuples; * bounded fixed arrays containing AS3 leaves; * recursive field projections; * array-element projections. The implementation preserves #1327's closed-world model: the complete MIR address-use graph is validated before dialect conversion, and lowering-private physical type facts are attached only after the whole graph succeeds. Carrier identity is never reconstructed from LLVM defining operations, `OperandsInfo`, or converted GEP history. ## Representation and projection contract Semantic values retain AS3 pointers while compiler-owned local storage uses the target-stable generic-pointer carrier: ```text semantic: <{ ..., p3, nested { p3 }, [p3; N], ... }> storage: <{ ..., p0, nested { p0 }, [p0; N], ... }> ``` Conversions remain explicit at load/store boundaries. The verified address graph now admits: ```text carrier alloca | +-- field_addr | +-- field_addr -> ... | `-- array_element_addr -> ... | +-- load `-- store ``` Each projection derives its physical pointee from the already-proven parent carrier type. `mir.field_addr` supports recursive struct/tuple projections, and `mir.array_element_addr` uses the verified physical carrier element type. Ordinary non-carrier addressing is unchanged. ## Bounds and fail-closed behavior The existing 16-leaf array rewrite budget is reused. Local-storage shape admission remains independently classified, so future internal-ABI shape widening cannot implicitly widen carrier-local support. Carrier addresses still fail closed across: * calls; * casts; * block arguments; * returns; * arbitrary pointer offsets; * unknown or unmodelled uses. AS3 pointer vectors and arbitrary packed-AS3 memory remain unsupported. ## Tests Added focused coverage for: * recursive/multi-leaf admission; * bounded arrays, including exact-bound acceptance and above-bound rejection; * vector rejection; * nested struct and tuple projections; * array-element projections; * recursive zero-sized projections; * exact physical carrier child types; * existing call/cast/block-argument rejection. `packed_aggregate_abi` now exercises multiple direct leaves, nested structs, nested tuples, and bounded AS3 pointer arrays through carrier-local projections. ## Validation ```text cargo fmt --all cargo fmt --all -- --check git diff --check cargo test -p mir-lower packed_shared_local_storage -- --nocapture cargo test -p mir-lower packed_shared_internal_abi -- --nocapture cargo test -p mir-lower --all-targets cargo clippy -p mir-lower --all-targets -- -D warnings cargo oxide build packed_aggregate_abi cargo oxide run packed_aggregate_abi CUDA_OXIDE_NO_OPT=1 cargo oxide run packed_aggregate_abi cargo oxide run addressof_sharedarray ``` Results: ```text packed-AS3 carrier-local tests: 12 passed packed-AS3 internal ABI tests: 9 passed mir-lower unit tests: 308 passed lowering tests: 147 passed clippy -D warnings: pass ``` Both optimized and `CUDA_OXIDE_NO_OPT=1` `packed_aggregate_abi` executions pass. `addressof_sharedarray` also continues to pass. ## Out of scope This PR does not add carrier-address transport through calls, block arguments, casts, returns, or arbitrary pointer arithmetic, nor support for AS3 pointer vectors, arbitrary/device-global/kernel-entry packed-AS3 carrier storage, or AS3-containing enum locals. --------- Signed-off-by: Raul Estrada <[email protected]> Signed-off-by: nihalpasham <[email protected]> Co-authored-by: nihalpasham <[email protected]>
What this adds
Packed structs with one direct shared-memory pointer can now use compiler-owned local storage and one direct field projection.
The complete address-use graph must validate before lowering attaches its private type facts. Whole-value loads/stores, direct field projections and debug uses are supported. Escaping addresses, nested projections and unknown uses fail before conversion. This avoids the operation-history inference used by #1092.
Coverage
The GPU example writes through the projected shared pointer and observes the result independently through the original pointer. Maintainer regressions check whole-value conversion directions, preexisting private facts, address escape and nested projections.
Verified at
e92236ef:packed_aggregate_abipassed LLVM NVPTX/SM100a execution, memcheck and synccheck.At
e92236ef, hosted tests, lint/format checks, guards, docs/book and example compilation passed. CodeQL was still running at the final review check.Scope
Only packed roots with one direct AS3 field and scalar or zero-sized remaining fields are covered. Multiple or nested AS3 leaves, arrays, arbitrary memory and carrier-address transport remain unsupported. The broader full-debug failure in #1219 is still open.
Fixes #1036.