Skip to content

Commit 497203c

Browse files
committed
test(cuda.core): share VMM leak test allocation size
Use one module constant for the cached warm-up and uncached measured allocations. Preserve eight measured iterations and the strict one-allocation leak threshold.
1 parent 4ed9dd0 commit 497203c

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎cuda_core/tests/test_memory.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,6 +1507,9 @@ def __init__(self, size):
15071507
assert ("release", NEW_HANDLE) in calls
15081508

15091509

1510+
VMM_LEAK_TEST_REQUESTED_SIZE = 8 * 1024 * 1024
1511+
1512+
15101513
def _vmm_allocate_and_close(mr, requested_size, grow):
15111514
buf = mr.allocate(requested_size)
15121515
if grow:
@@ -1523,7 +1526,7 @@ def _warm_up_vmm_allocate_and_close(device_id, grow):
15231526
device,
15241527
config=VirtualMemoryResourceOptions(handle_type="win32_kmt" if IS_WINDOWS else "posix_fd"),
15251528
)
1526-
return _vmm_allocate_and_close(mr, 8 * 1024 * 1024, grow)
1529+
return _vmm_allocate_and_close(mr, VMM_LEAK_TEST_REQUESTED_SIZE, grow)
15271530

15281531

15291532
@pytest.mark.thread_unsafe(reason="cuMemGetInfo measures process-wide free memory")
@@ -1538,11 +1541,9 @@ def test_vmm_allocate_close_does_not_leak(init_cuda, grow):
15381541
device,
15391542
config=VirtualMemoryResourceOptions(handle_type="win32_kmt" if IS_WINDOWS else "posix_fd"),
15401543
)
1541-
requested_size = 8 * 1024 * 1024
1542-
15431544
baseline = handle_return(driver.cuMemGetInfo())[0]
15441545
for _ in range(8):
1545-
_vmm_allocate_and_close(mr, requested_size, grow)
1546+
_vmm_allocate_and_close(mr, VMM_LEAK_TEST_REQUESTED_SIZE, grow)
15461547
free = handle_return(driver.cuMemGetInfo())[0]
15471548

15481549
# A leak would cost at least one allocation per iteration.

0 commit comments

Comments
 (0)