Skip to content

Commit da4a376

Browse files
committed
add missing file
1 parent fbf7572 commit da4a376

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
# Conversion from the internal ``_LocSpec`` record produced by
6+
# ``_managed_location._coerce_location`` to the driver's ``CUmemLocation``.
7+
#
8+
# Header-only so both the managed-memory ops and the batched copy path can
9+
# cimport it without either module depending on the other. ``CUmemLocation``
10+
# is only populated on a CUDA 13 build; the CUDA 12 stub exists so callers
11+
# compiled there still resolve the symbol.
12+
13+
from cuda.bindings cimport cydriver
14+
15+
16+
IF CUDA_CORE_BUILD_MAJOR >= 13:
17+
cdef inline cydriver.CUmemLocation to_cumemlocation(object loc):
18+
cdef str kind = loc.kind
19+
if kind == "device":
20+
return cydriver.CUmemLocation(
21+
type=cydriver.CUmemLocationType.CU_MEM_LOCATION_TYPE_DEVICE,
22+
id=<int>loc.id)
23+
elif kind == "host":
24+
return cydriver.CUmemLocation(
25+
type=cydriver.CUmemLocationType.CU_MEM_LOCATION_TYPE_HOST,
26+
id=0)
27+
elif kind == "host_numa":
28+
return cydriver.CUmemLocation(
29+
type=cydriver.CUmemLocationType.CU_MEM_LOCATION_TYPE_HOST_NUMA,
30+
id=<int>loc.id)
31+
else: # host_numa_current
32+
return cydriver.CUmemLocation(
33+
type=cydriver.CUmemLocationType.CU_MEM_LOCATION_TYPE_HOST_NUMA_CURRENT,
34+
id=0)
35+
ELSE:
36+
cdef inline cydriver.CUmemLocation to_cumemlocation(object loc):
37+
raise NotImplementedError(
38+
"CUmemLocation requires cuda.core built against CUDA 13 headers"
39+
)

0 commit comments

Comments
 (0)