codegen: support grid-constant kernel parameters - #1225
Conversation
Let #[kernel] declarations mark immutable reference parameters as grid constants, derive the generated host launch ABI from the same declaration, and carry pointee layout through MIR and LLVM lowering. Emit LLVM byval alignment and NVVM grid_constant metadata, with compiler and SM120 contract coverage. Signed-off-by: Zihua Wu <13583761+lucifer1004@users.noreply.github.com>
|
The generic-kernel path needs to be part of the design before this lands:
#[kernel]
pub fn k<T: Copy>(#[grid_constant] d: &Desc, out: *mut u32, _tag: T) {
unsafe { *out = d.values[3] }
} fails with kernel contains duplicate grid-constant marker for source
other(d: &Desc, out: *mut u32) {
k::<u8>(d, out, 0)
} with no attribute comes out with
And we need tests in the PR exercise a generic kernel with To land this: the strip in both generic paths, a generic |
nihalpasham
left a comment
There was a problem hiding this comment.
Changes requested, details in #1225 (comment)
Signed-off-by: Zihua Wu <13583761+lucifer1004@users.noreply.github.com>
|
Addressed the generic-helper ABI concern in f2b6b15. The macro now captures the grid-constant marker for the generated entry and strips it from the re-emitted callable helper in both generic expansion paths. The contract example now covers both sides:
Measured validation:
|
Summary
Adds parameter-local
#[grid_constant]support so one Rust kernel declaration controls both the device grid-constant ABI and generated host by-value marshalling.Closes #1223.
Changes
#[grid_constant]on immutable, sized reference parameters.byval(T) align Nand the one-based NVVMgrid_constantparameter list.cuda_module_contractexample with a 128-byte, 64-byte-aligned SM120 execution check.Testing
just checkpasses (all stages through CUDA-linked tests and the pre-deny guards passed; the local run stopped becausecargo-denyis not installed)cargo oxide run cuda_module_contract --arch sm_120passescuda-macros,llvm-export,mir-importer,mir-lower, andreserved-oxide-symbolstests pass.-D warningspasses.just check-intrinsicspasses for all 1,025 routes and 2,374 target configurations.just doc-checkpasses.Checklist