@@ -160,6 +160,11 @@ cdef void _queue_capsule_deleter(object o):
160160 o, " SyclQueueRef"
161161 )
162162 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)
163168
164169
165170cdef class _SyclQueue:
@@ -284,18 +289,13 @@ cdef class SyclQueue(_SyclQueue):
284289 status = self ._init_queue_default(props)
285290 elif len_args == 1 :
286291 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" )
289294 filter_c_str = string
290295 status = self ._init_queue_from_filter_string(
291296 filter_c_str, props)
292297 elif type (arg) is _SyclQueue:
293298 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)
299299 elif isinstance (arg, SyclDevice):
300300 status = self ._init_queue_from_device(< SyclDevice> arg, props)
301301 elif pycapsule.PyCapsule_IsValid(arg, " SyclQueueRef" ):
@@ -537,13 +537,24 @@ cdef class SyclQueue(_SyclQueue):
537537
538538 @staticmethod
539539 cdef SyclQueue _create_from_context_and_device(
540- SyclContext ctx, SyclDevice dev
540+ SyclContext ctx, SyclDevice dev, int props = 0
541541 ):
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+ """
542547 cdef _SyclQueue ret = _SyclQueue.__new__ (_SyclQueue)
543548 cdef DPCTLSyclContextRef cref = ctx.get_context_ref()
544549 cdef DPCTLSyclDeviceRef dref = dev.get_device_ref()
545- cdef DPCTLSyclQueueRef qref = DPCTLQueue_Create(cref, dref, NULL , 0 )
550+ cdef DPCTLSyclQueueRef qref = NULL
546551
552+ qref = DPCTLQueue_Create(
553+ cref,
554+ dref,
555+ < error_handler_callback * > & default_async_error_handler,
556+ props
557+ )
547558 if qref is NULL :
548559 raise SyclQueueCreationError(" Queue creation failed." )
549560 ret._queue_ref = qref
@@ -644,8 +655,12 @@ cdef class SyclQueue(_SyclQueue):
644655 else :
645656 return False
646657
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.
649664 """
650665 cdef _backend_type BE = DPCTLQueue_GetBackend(self ._queue_ref)
651666 if BE == _backend_type._OPENCL:
@@ -685,7 +700,7 @@ cdef class SyclQueue(_SyclQueue):
685700 The address of the ``DPCTLSyclQueueRef`` object used to create this
686701 :class:`dpctl.SyclQueue` cast to a ``size_t``.
687702 """
688- return int ( < size_t> self ._queue_ref)
703+ return < size_t> self ._queue_ref
689704
690705 cpdef SyclEvent submit(
691706 self ,
@@ -843,8 +858,8 @@ cdef class SyclQueue(_SyclQueue):
843858 else :
844859 raise TypeError (" Parameter `mem` should have type _Memory" )
845860
846- if (count <= 0 or count > self .nbytes):
847- count = self .nbytes
861+ if (count <= 0 or count > mem .nbytes):
862+ count = mem .nbytes
848863
849864 ERef = DPCTLQueue_Prefetch(self ._queue_ref, ptr, count)
850865 if (ERef is NULL ):
@@ -863,8 +878,8 @@ cdef class SyclQueue(_SyclQueue):
863878 else :
864879 raise TypeError (" Parameter `mem` should have type _Memory" )
865880
866- if (count <= 0 or count > self .nbytes):
867- count = self .nbytes
881+ if (count <= 0 or count > mem .nbytes):
882+ count = mem .nbytes
868883
869884 ERef = DPCTLQueue_MemAdvise(self ._queue_ref, ptr, count, advice)
870885 if (ERef is NULL ):
@@ -959,16 +974,6 @@ cdef class SyclQueue(_SyclQueue):
959974
960975 return SyclEvent._create(ERef, [])
961976
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-
972977 @property
973978 def name (self ):
974979 """ Returns the device name for the device
0 commit comments