Repository navigation
Description
Problem
Packed aggregates are supported by value after #941, but packed aggregates containing shared-memory / address-space-3 pointers still fail closed.
That restriction is necessary for physical memory images because the representation of an AS3 pointer is target-mode dependent. However, the same restriction is currently applied even when the packed aggregate only crosses an internal device-function ABI boundary.
For example:
#[repr(C, packed)]
struct Cursor {
tag: u8,
ptr: *mut SharedThing,
}
#[inline(never)]
#[device]
fn bounce(value: Cursor) -> Cursor {
value
}The semantic device-side value can remain a packed aggregate containing an AS3 pointer, but the internal function return ABI needs a target-stable physical representation.
Background
#867 added address-space-aware internal ABI handling for ordinary aggregate arguments and returns.
#884 established the scalar precedent for AS3 values whose physical representation is target dependent: cross the ABI boundary through the generic-pointer representation rather than relying on the backend pointer width.
#941 added packed aggregate by-value support while deliberately keeping packed aggregates containing shared pointers unsupported.
The remaining gap is the combination of those cases: a packed aggregate with an AS3 pointer crossing an internal device ABI boundary.
Proposed approach
Keep the semantic value unchanged inside the function body:
packed semantic aggregate with AS3 pointer
At the internal return boundary, rebuild it into a target-stable packed carrier:
packed semantic <{ scalar, p3 }>
↓
packed ABI carrier <{ scalar, p0 }>
↓ internal device return
packed ABI carrier <{ scalar, p0 }>
↓
packed semantic <{ scalar, p3 }>
The address-space conversion should be explicit through addrspacecast.
Initial scope
Keep the first implementation deliberately narrow:
- internal device ABI only;
- packed structs only;
- exactly one direct AS3/shared pointer field;
- remaining non-ZST fields must be scalar;
- arguments may continue to use the existing flattened internal ABI path;
- returns use a target-stable generic-pointer aggregate carrier.
Out of scope
This issue should not enable:
- packed AS3 kernel parameters;
- whole-value loads or stores of packed aggregates containing AS3 pointers;
- arrays containing AS3 pointers;
- nested aggregate AS3 leaves;
- vectors containing AS3 pointers;
- multiple AS3 pointer leaves;
- enums or arbitrary recursive packed layouts.
Whole-value packed AS3 memory images must remain fail closed because their physical byte representation is target-mode dependent.
Acceptance criteria
- A packed struct containing one direct AS3 pointer can be constructed as a semantic SSA value.
- An internal device function can return that struct.
- The function ABI uses a packed generic-pointer carrier instead of the semantic AS3 representation.
- The caller reconstructs the semantic AS3 value after the call.
- No change is made to kernel ABI handling.
- Whole-value packed AS3 memory load/store remains rejected.
- Existing shared-pointer aggregate and enum regressions continue to pass.
- End-to-end CUDA execution confirms the shared pointer survives the internal call round trip.
Activity