33
44import ctypes
55import sys
6- from ctypes import wintypes
76
87try :
98 from cuda .bindings import driver
@@ -325,23 +324,8 @@ def test_device_memory_resource_initialization(use_device_object):
325324
326325
327326def get_handle_type ():
328- def get_sa ():
329- class SECURITY_ATTRIBUTES (ctypes .Structure ):
330- _fields_ = [
331- ("nLength" , wintypes .DWORD ),
332- ("lpSecurityDescriptor" , wintypes .LPVOID ),
333- ("bInheritHandle" , wintypes .BOOL ),
334- ]
335-
336- sa = SECURITY_ATTRIBUTES ()
337- sa .nLength = ctypes .sizeof (sa )
338- sa .lpSecurityDescriptor = None
339- sa .bInheritHandle = False # TODO: why?
340-
341- return sa
342-
343327 if IS_WINDOWS :
344- return (("win32" , get_sa () ), ("win32_kmt" , None ))
328+ return (("win32" , None ), ("win32_kmt" , None ))
345329 else :
346330 return (("posix_fd" , None ),)
347331
@@ -362,17 +346,17 @@ def test_vmm_allocator_basic_allocation(use_device_object, handle_type):
362346 pytest .skip ("Virtual memory management is not supported on this device" )
363347
364348 handle_type , security_attribute = handle_type # unpack
365- win32_handle_metadata = ctypes .addressof (security_attribute ) if security_attribute else 0
366- options = VirtualMemoryResourceOptions (
367- handle_type = handle_type ,
368- win32_handle_metadata = win32_handle_metadata ,
369- )
349+ options = VirtualMemoryResourceOptions (handle_type = handle_type )
370350 # Create VMM allocator with default config
371351 device_arg = device if use_device_object else device .device_id
372352 vmm_mr = VirtualMemoryResource (device_arg , config = options )
373353
374354 # Test basic allocation
375- buffer = vmm_mr .allocate (4096 )
355+ try :
356+ buffer = vmm_mr .allocate (4096 )
357+ except NotImplementedError :
358+ assert handle_type == "win32"
359+ return
376360 assert buffer .size >= 4096 # May be aligned up
377361 assert buffer .device_id == device .device_id
378362 assert buffer .memory_resource == vmm_mr
@@ -483,16 +467,15 @@ def test_vmm_allocator_grow_allocation(handle_type):
483467 pytest .skip ("Virtual memory management is not supported on this device" )
484468
485469 handle_type , security_attribute = handle_type # unpack
486- win32_handle_metadata = ctypes .addressof (security_attribute ) if security_attribute else 0
487- options = VirtualMemoryResourceOptions (
488- handle_type = handle_type ,
489- win32_handle_metadata = win32_handle_metadata ,
490- )
491-
470+ options = VirtualMemoryResourceOptions (handle_type = handle_type )
492471 vmm_mr = VirtualMemoryResource (device , config = options )
493472
494473 # Create initial allocation
495- buffer = vmm_mr .allocate (2 * 1024 * 1024 )
474+ try :
475+ buffer = vmm_mr .allocate (2 * 1024 * 1024 )
476+ except NotImplementedError :
477+ assert handle_type == "win32"
478+ return
496479 original_size = buffer .size
497480
498481 # Grow the allocation
0 commit comments