Isolate CUmemLocation construction in a helper - #2683
Open
juenglin wants to merge 2 commits into
Open
Conversation
Contributor
juenglin
force-pushed
the
custom-initializer
branch
from
August 21, 2026 15:54
03e7064 to
a288474
Compare
Build CUmemLocation via field assignment in to_cumemlocation() so cuda.core compiles against both the 13.3 and 13.4 layouts. The localized arm is an optional helper argument that exists only when CUDA_VERSION >= 13040.
juenglin
force-pushed
the
custom-initializer
branch
from
August 21, 2026 16:36
a288474 to
d6c6c39
Compare
juenglin
force-pushed
the
custom-initializer
branch
from
August 21, 2026 18:55
61f4c66 to
f9c4529
Compare
Contributor
Author
|
/ok to test f9c4529 |
|
juenglin
marked this pull request as ready for review
August 21, 2026 20:28
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
Cython's aggregate struct-literal syntax (
CUmemLocation(type=..., id=...)) warns "Not all members given for struct" whenever a call site doesn't name every member Cython knows about for that struct — andcuda.corepromotes that warning to a build error. CUDA 13.4 adds alocalizedunion member toCUmemLocation_stalongside the existingid, so oncecydriver.pxdis regenerated from 13.4 headers, every existingCUmemLocation(type=..., id=...)call site incuda.corefails to build, even thoughidis a complete initializer for the union arm actually being used.This PR consolidates all
CUmemLocationconstruction incuda_core/cuda/core/_memory/_location.pxdinto two small helpers that use field assignment internally (so the warning never fires there), while call sites keep compact constructor-style syntax:to_cumemlocation(kind: str, loc_id: int)— for callers with a semantickind("device"/"host"/"host_numa"/"host_numa_current"), e.g. from_LocSpec.kind.cumemlocation_from_type(loc_type: CUmemLocationType, loc_id: int)— for callers that already hold aCUmemLocationTypeenum value directly (pool configuration, peer-access, graph alloc nodes).Every
CUmemLocation-constructing call site acrosscuda_corenow routes through one of these two helpers instead of duplicating field-assignment or aggregate-literal logic inline.Relationship to #2673
Both PRs fix the same build failure. #2673 replaces every aggregate constructor with bare field assignment at each call site directly — minimal diff, already passed full CI, but it also removes the partial-initialization warning for this struct everywhere it touches. This PR keeps constructor-style call sites and centralizes the field-assignment logic in two helpers instead of duplicating it across call sites. The safety benefit is modest: Cython's aggregate-literal check isn't union-aware and can't verify "the correct arm was set" either way, so the real gain here is having one tested place for the mapping logic rather than six.
Test plan
cuda_coreagainst local CUDA 13.3 headers — no-Werrorfailurescython-lintpasses on all changed files