@@ -160,6 +160,11 @@ cdef void _queue_capsule_deleter(object o):
160
160
o, " SyclQueueRef"
161
161
)
162
162
DPCTLQueue_Delete(QRef)
163
+ elif pycapsule.PyCapsule_IsValid(o, " used_SyclQueueRef" ):
164
+ QRef = < DPCTLSyclQueueRef> pycapsule.PyCapsule_GetPointer(
165
+ o, " used_SyclQueueRef"
166
+ )
167
+ DPCTLQueue_Delete(QRef)
163
168
164
169
165
170
cdef class _SyclQueue:
@@ -284,18 +289,13 @@ cdef class SyclQueue(_SyclQueue):
284
289
status = self ._init_queue_default(props)
285
290
elif len_args == 1 :
286
291
arg = args[0 ]
287
- if type (arg) is unicode :
288
- string = bytes(< unicode > arg, " utf-8" )
292
+ if type (arg) is str :
293
+ string = bytes(< str > arg, " utf-8" )
289
294
filter_c_str = string
290
295
status = self ._init_queue_from_filter_string(
291
296
filter_c_str, props)
292
297
elif type (arg) is _SyclQueue:
293
298
status = self ._init_queue_from__SyclQueue(< _SyclQueue> arg)
294
- elif isinstance (arg, unicode ):
295
- string = bytes(< unicode > unicode (arg), " utf-8" )
296
- filter_c_str = string
297
- status = self ._init_queue_from_filter_string(
298
- filter_c_str, props)
299
299
elif isinstance (arg, SyclDevice):
300
300
status = self ._init_queue_from_device(< SyclDevice> arg, props)
301
301
elif pycapsule.PyCapsule_IsValid(arg, " SyclQueueRef" ):
@@ -537,13 +537,24 @@ cdef class SyclQueue(_SyclQueue):
537
537
538
538
@staticmethod
539
539
cdef SyclQueue _create_from_context_and_device(
540
- SyclContext ctx, SyclDevice dev
540
+ SyclContext ctx, SyclDevice dev, int props = 0
541
541
):
542
+ """
543
+ Static factory method to create :class:`dpctl.SyclQueue` instance
544
+ from given :class:`dpctl.SyclContext`, :class:`dpctl.SyclDevice`
545
+ and optional integer `props` encoding the queue properties.
546
+ """
542
547
cdef _SyclQueue ret = _SyclQueue.__new__ (_SyclQueue)
543
548
cdef DPCTLSyclContextRef cref = ctx.get_context_ref()
544
549
cdef DPCTLSyclDeviceRef dref = dev.get_device_ref()
545
- cdef DPCTLSyclQueueRef qref = DPCTLQueue_Create(cref, dref, NULL , 0 )
550
+ cdef DPCTLSyclQueueRef qref = NULL
546
551
552
+ qref = DPCTLQueue_Create(
553
+ cref,
554
+ dref,
555
+ < error_handler_callback * > & default_async_error_handler,
556
+ props
557
+ )
547
558
if qref is NULL :
548
559
raise SyclQueueCreationError(" Queue creation failed." )
549
560
ret._queue_ref = qref
@@ -644,8 +655,12 @@ cdef class SyclQueue(_SyclQueue):
644
655
else :
645
656
return False
646
657
647
- def get_sycl_backend (self ):
648
- """ Returns the Sycl backend associated with the queue.
658
+ @property
659
+ def backend (self ):
660
+ """ Returns the backend_type enum value for this queue.
661
+
662
+ Returns:
663
+ backend_type: The backend for the queue.
649
664
"""
650
665
cdef _backend_type BE = DPCTLQueue_GetBackend(self ._queue_ref)
651
666
if BE == _backend_type._OPENCL:
@@ -685,7 +700,7 @@ cdef class SyclQueue(_SyclQueue):
685
700
The address of the ``DPCTLSyclQueueRef`` object used to create this
686
701
:class:`dpctl.SyclQueue` cast to a ``size_t``.
687
702
"""
688
- return int ( < size_t> self ._queue_ref)
703
+ return < size_t> self ._queue_ref
689
704
690
705
cpdef SyclEvent submit(
691
706
self ,
@@ -843,8 +858,8 @@ cdef class SyclQueue(_SyclQueue):
843
858
else :
844
859
raise TypeError (" Parameter `mem` should have type _Memory" )
845
860
846
- if (count <= 0 or count > self .nbytes):
847
- count = self .nbytes
861
+ if (count <= 0 or count > mem .nbytes):
862
+ count = mem .nbytes
848
863
849
864
ERef = DPCTLQueue_Prefetch(self ._queue_ref, ptr, count)
850
865
if (ERef is NULL ):
@@ -863,8 +878,8 @@ cdef class SyclQueue(_SyclQueue):
863
878
else :
864
879
raise TypeError (" Parameter `mem` should have type _Memory" )
865
880
866
- if (count <= 0 or count > self .nbytes):
867
- count = self .nbytes
881
+ if (count <= 0 or count > mem .nbytes):
882
+ count = mem .nbytes
868
883
869
884
ERef = DPCTLQueue_MemAdvise(self ._queue_ref, ptr, count, advice)
870
885
if (ERef is NULL ):
@@ -959,16 +974,6 @@ cdef class SyclQueue(_SyclQueue):
959
974
960
975
return SyclEvent._create(ERef, [])
961
976
962
- @property
963
- def backend (self ):
964
- """ Returns the backend_type enum value for the device
965
- associated with this queue.
966
-
967
- Returns:
968
- backend_type: The backend for the device.
969
- """
970
- return self .sycl_device.backend
971
-
972
977
@property
973
978
def name (self ):
974
979
""" Returns the device name for the device
0 commit comments