77 from cuda import cuda as driver
88
99import ctypes
10-
1110import platform
11+
1212import pytest
1313
1414from cuda .core .experimental import Buffer , Device , DeviceMemoryResource , MemoryResource
1717
1818POOL_SIZE = 2097152 # 2MB size
1919
20+
2021@pytest .fixture (scope = "function" )
2122def mempool_device ():
2223 """Obtains a device suitable for mempool tests, or skips."""
@@ -31,6 +32,7 @@ def mempool_device():
3132
3233 return device
3334
35+
3436class DummyDeviceMemoryResource (MemoryResource ):
3537 def __init__ (self , device ):
3638 self .device = device
@@ -380,7 +382,7 @@ def test_mempool_attributes(mempool_device, property_name, expected_type):
380382 device = mempool_device
381383 for ipc_enabled in [True , False ]:
382384 if platform .system () == "Windows" :
383- continue # IPC not implemented for Windows
385+ continue # IPC not implemented for Windows
384386
385387 mr = DeviceMemoryResource (device , dict (max_size = POOL_SIZE , ipc_enabled = ipc_enabled ))
386388 assert mr .is_ipc_enabled == ipc_enabled
@@ -421,6 +423,7 @@ def test_mempool_attributes(mempool_device, property_name, expected_type):
421423 flush_buffer = mr .allocate (64 )
422424 flush_buffer .close ()
423425
426+
424427def test_mempool_attributes_ownership (mempool_device ):
425428 """Ensure the attributes bundle handles references correctly."""
426429 device = mempool_device
@@ -432,17 +435,16 @@ def test_mempool_attributes_ownership(mempool_device):
432435
433436 # After deleting the memory resource, the attributes suite is disconnected.
434437 with pytest .raises (RuntimeError , match = "DeviceMemoryResource is expired" ):
435- attributes .used_mem_high
438+ _ = attributes .used_mem_high
436439
437440 # Even when a new object is created (we found a case where the same
438441 # mempool handle was really reused).
439442 mr = DeviceMemoryResource (device , dict (max_size = POOL_SIZE ))
440443 with pytest .raises (RuntimeError , match = "DeviceMemoryResource is expired" ):
441- attributes .used_mem_high
444+ _ = attributes .used_mem_high
442445
443446 # Even if we stuff the original handle into a new class.
444447 mr ._mempool_handle , old_handle = old_handle , mr ._mempool_handle
445448 with pytest .raises (RuntimeError , match = "DeviceMemoryResource is expired" ):
446- attributes .used_mem_high
449+ _ = attributes .used_mem_high
447450 mr ._mempool_handle = old_handle
448-
0 commit comments