@@ -433,16 +433,80 @@ def test_queue__repr__():
433
433
r2 = q2 .__repr__ ()
434
434
q3 = dpctl .SyclQueue (property = "enable_profiling" )
435
435
r3 = q3 .__repr__ ()
436
- q4 = dpctl .SyclQueue (property = [ "in_order" , "enable_profiling" ] )
436
+ q4 = dpctl .SyclQueue (property = "default" )
437
437
r4 = q4 .__repr__ ()
438
+ q5 = dpctl .SyclQueue (property = ["in_order" , "enable_profiling" ])
439
+ r5 = q5 .__repr__ ()
438
440
assert type (r1 ) is str
439
441
assert type (r2 ) is str
440
442
assert type (r3 ) is str
441
443
assert type (r4 ) is str
444
+ assert type (r5 ) is str
445
+
446
+
447
+ def test_queue_invalid_property ():
448
+ with pytest .raises (ValueError ):
449
+ dpctl .SyclQueue (property = 4.5 )
450
+ with pytest .raises (ValueError ):
451
+ dpctl .SyclQueue (property = ["abc" , tuple ()])
442
452
443
453
444
454
def test_queue_capsule ():
445
455
q = dpctl .SyclQueue ()
446
456
cap = q ._get_capsule ()
457
+ cap2 = q ._get_capsule ()
447
458
q2 = dpctl .SyclQueue (cap )
448
459
assert q == q2
460
+ del cap2 # call deleter on non-renamed capsule
461
+
462
+
463
+ def test_cpython_api ():
464
+ import ctypes
465
+ import sys
466
+
467
+ q = dpctl .SyclQueue ()
468
+ mod = sys .modules [q .__class__ .__module__ ]
469
+ # get capsule storign get_context_ref function ptr
470
+ q_ref_fn_cap = mod .__pyx_capi__ ["get_queue_ref" ]
471
+ # construct Python callable to invoke "get_queue_ref"
472
+ cap_ptr_fn = ctypes .pythonapi .PyCapsule_GetPointer
473
+ cap_ptr_fn .restype = ctypes .c_void_p
474
+ cap_ptr_fn .argtypes = [ctypes .py_object , ctypes .c_char_p ]
475
+ q_ref_fn_ptr = cap_ptr_fn (
476
+ q_ref_fn_cap , b"DPCTLSyclQueueRef (struct PySyclQueueObject *)"
477
+ )
478
+ callable_maker = ctypes .PYFUNCTYPE (ctypes .c_void_p , ctypes .py_object )
479
+ get_queue_ref_fn = callable_maker (q_ref_fn_ptr )
480
+
481
+ r2 = q .addressof_ref ()
482
+ r1 = get_queue_ref_fn (q )
483
+ assert r1 == r2
484
+
485
+
486
+ def test_constructor_many_arg ():
487
+ with pytest .raises (TypeError ):
488
+ dpctl .SyclQueue (None , None , None , None )
489
+ with pytest .raises (TypeError ):
490
+ dpctl .SyclQueue (None , None )
491
+
492
+
493
+ def test_queue_wait ():
494
+ try :
495
+ q = dpctl .SyclQueue ()
496
+ except dpctl .SyclQueueCreationError :
497
+ pytest .skip ("Failed to create device with supported filter" )
498
+ q .wait ()
499
+
500
+
501
+ def test_queue_memops ():
502
+ try :
503
+ q = dpctl .SyclQueue ()
504
+ except dpctl .SyclQueueCreationError :
505
+ pytest .skip ("Failed to create device with supported filter" )
506
+ from dpctl .memory import MemoryUSMDevice
507
+
508
+ m1 = MemoryUSMDevice (512 , queue = q )
509
+ m2 = MemoryUSMDevice (512 , queue = q )
510
+ q .memcpy (m1 , m2 , 512 )
511
+ q .prefetch (m1 , 512 )
512
+ q .mem_advise (m1 , 512 , 0 )
0 commit comments