Skip to content

Commit ab9a3ab

Browse files
committed
test(cuda.core): split managed-memory ops tests into tests/memory/
Move the managed-memory advise/prefetch/discard/discard_prefetch tests (plus their TestLocation/TestLocationCoerce/TestPrefetch/TestDiscard/ TestDiscardPrefetch/TestAdvise classes and skip helpers) from test_memory.py into tests/memory/test_managed_ops.py per Andy's nit. Promote DummyDeviceMemoryResource to helpers.buffers so both files can import it; the remaining DummyHost/DummyPinned/NullMemoryResource stay in test_memory.py since they're only used there. Broader memory-tests reorg ("and siblings": buffer/managed_resource/ pinned/vmm) tracked as a follow-up cleanup PR to keep this diff focused.
1 parent 10de998 commit ab9a3ab

3 files changed

Lines changed: 737 additions & 715 deletions

File tree

cuda_core/tests/helpers/buffers.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from . import libc
1010

1111
__all__ = [
12+
"DummyDeviceMemoryResource",
1213
"DummyUnifiedMemoryResource",
1314
"PatternGen",
1415
"TrackingMR",
@@ -18,6 +19,30 @@
1819
]
1920

2021

22+
class DummyDeviceMemoryResource(MemoryResource):
23+
def __init__(self, device):
24+
self.device = device
25+
26+
def allocate(self, size, stream=None) -> Buffer:
27+
ptr = handle_return(driver.cuMemAlloc(size))
28+
return Buffer.from_handle(ptr=ptr, size=size, mr=self)
29+
30+
def deallocate(self, ptr, size, stream=None):
31+
handle_return(driver.cuMemFree(ptr))
32+
33+
@property
34+
def is_device_accessible(self) -> bool:
35+
return True
36+
37+
@property
38+
def is_host_accessible(self) -> bool:
39+
return False
40+
41+
@property
42+
def device_id(self) -> int:
43+
return 0
44+
45+
2146
class DummyUnifiedMemoryResource(MemoryResource):
2247
def __init__(self, device):
2348
self.device = device

0 commit comments

Comments
 (0)