Repository navigation
Further fixes to closure launch ABI - #60
Merged
nihalpasham merged 4 commits intoMay 27, 2026
Merged
Conversation
josephglanville
force-pushed
the
jpg/typed-launch-closures
branch
2 times, most recently
from
May 15, 2026 02:35
e70ae99 to
5aae79c
Compare
Signed-off-by: Joseph Glanville <[email protected]>
Signed-off-by: Joseph Glanville <[email protected]>
josephglanville
force-pushed
the
jpg/typed-launch-closures
branch
from
May 15, 2026 03:45
5aae79c to
33bc50c
Compare
…dency note Three follow-up additions on top of the closure ABI fixes: * Tests 10/11: kernels `map_mut` (`FnMut`) and `map_once` (`FnOnce` + Copy) drive the closure-shape sweep through the two remaining trait bounds the macro already recognises. The captures are same-size f32s on purpose, so these tests don't re-prove the layout fix from tests 7/8 — they exercise the device-side dispatch path (`call_mut` / `call_once`) instead of `Fn::call`. * Test 12: a `#[repr(C)]` counterpart to test 8's reordered struct capture. Same fields (u8 / f64 / f32) and same closure body, but `#[repr(C)]` pins the layout to declaration order with explicit alignment padding. The layout fix in mir-importer has to handle both reordered (default repr) and identity -order (repr(C)) cases. Confirmed by reverting the types.rs change locally: tests 7, 8, AND 12 all fail with 1024 errors per sub-test; tests 10/11 pass (different code path). * Test 9 (non-move ref captures) now documents that it silently depends on Heterogeneous Memory Management — the closure environment carries `&f32` pointers into the host stack, and the GPU dereferences them at kernel entry. On systems without HMM this surfaces as `CUDA_ERROR_ILLEGAL_ADDRESS`, which the smoketest's `verdict_standard` correctly flags as FAIL via the failure- marker regex — but the test should at least name the dependency so the next debugger isn't surprised. Verified: 48/48 sub-tests pass on RTX 5090 (sm_120) via both `cargo oxide run` and `scripts/smoketest.sh --only host_closure`. fmt-check, `clippy --workspace`, and the full per-package cargo test matrix all clean.
nihalpasham
approved these changes
May 27, 2026
nihalpasham
left a comment
Collaborator
There was a problem hiding this comment.
Thanks, this is excellent 🚀 and LGTM.
Pushed 2 commits on top to layer some extra defensive coverage and bring the branch up to date:
ba047a5Mergeorigin/main— no conflicts, picks up PR #44 and PR #52 since fork.fecec55Three additions tohost_closure:- Tests 10/11:
FnMutandFnOncekernels exercising the device-side dispatch paths the macro already recognized viafind_closure_generic. They pass with or without the layout fix (same-size captures) — pure defensive coverage of the dispatch trait. - Test 12:
#[repr(C)]counterpart to test 8. Locks down that the layout fix handles identity-order layouts with alignment padding too. Adversarial check confirms it ALSO fails 1024/1024 whentypes.rsis reverted. - Test 9: one-line note that non-move ref captures depend on HMM (sm_75+ on Linux); GPUs without HMM surface this as
CUDA_ERROR_ILLEGAL_ADDRESS, whichverdict_standardflags as FAIL.
- Tests 10/11:
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
Recently landed fixes to pass aggregate types byval did a lot to unify and fix underlying issues in the closure problem but were not the complete fix, some types of closures aren't getting closure specific handling they need, some problems with ZST and also the pre-existing problem of layout issues.
This PR addresses these problems and extends the test coverage to cover all APIs across a broader range of closure shapes.
Test Coverage
host_closurenow runs the same closure cases across all four launch surfaces. The matrix covers:where-clauseFnboundsmovestack-reference captures