Commit b0d1a21
feat(cuda.core): cu13 NUMA round-trip for ManagedBuffer.preferred_location (N8)
Per the self-promised reply on PR #1775's R7 thread, fulfill the
Host(numa_id=N) round-trip on CUDA 13 builds.
The blocker before was that cuda.bindings's Python-level
cuMemRangeGetAttribute wrapper rejects the new
CU_MEM_RANGE_ATTRIBUTE_PREFERRED_LOCATION_TYPE / _ID attributes via
its allowlist. The workaround: call cydriver.cuMemRangeGetAttribute
directly from a new Cython helper _read_preferred_location_v2,
bypassing the Python wrapper.
The helper queries TYPE then ID, then decodes the (kind, id) pair into
Device | Host | Host(numa_id=N) | Host.numa_current() | None.
ManagedBuffer.preferred_location getter dispatches to the v2 path on
binding_version() >= (13, 0, 0); falls back to the legacy single-int
attribute on cu12 (no NUMA info available).
Test:
- TestManagedBuffer.test_preferred_location_roundtrip already exercises
the cu13 v2 path for Device(...) and Host() (no NUMA), which now
passes through _read_preferred_location_v2.
- New test_preferred_location_roundtrip_host_numa exercises Host(numa_id=0)
round-trip; skips on cu12, and also skips on cu13 hardware/drivers
where set_preferred_location with HOST_NUMA is not preserved (e.g.
single-NUMA test machines).
ManagedBuffer class docstring updated to reflect the cu12-only
limitation note.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 0af5bd4 commit b0d1a21
3 files changed
Lines changed: 77 additions & 13 deletions
File tree
- cuda_core
- cuda/core/_memory
- tests/memory
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
| |||
167 | 169 | | |
168 | 170 | | |
169 | 171 | | |
170 | | - | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
179 | 176 | | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
180 | 182 | | |
181 | 183 | | |
182 | 184 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
333 | 333 | | |
334 | 334 | | |
335 | 335 | | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
336 | 375 | | |
337 | 376 | | |
338 | 377 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
578 | 578 | | |
579 | 579 | | |
580 | 580 | | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
581 | 604 | | |
582 | 605 | | |
583 | 606 | | |
| |||
0 commit comments