Skip to content

Commit cb846e8

Browse files
Reworked selector string handling, using str, rather than unicode
Fixed a bug in memory operation methods of SyclQueue which went unnoticed for a long time since it was not covered by tests.
1 parent 73dfb5c commit cb846e8

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

dpctl/_sycl_queue.pyx

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -289,18 +289,13 @@ cdef class SyclQueue(_SyclQueue):
289289
status = self._init_queue_default(props)
290290
elif len_args == 1:
291291
arg = args[0]
292-
if type(arg) is unicode:
293-
string = bytes(<unicode>arg, "utf-8")
292+
if type(arg) is str:
293+
string = bytes(<str>arg, "utf-8")
294294
filter_c_str = string
295295
status = self._init_queue_from_filter_string(
296296
filter_c_str, props)
297297
elif type(arg) is _SyclQueue:
298298
status = self._init_queue_from__SyclQueue(<_SyclQueue>arg)
299-
elif isinstance(arg, unicode):
300-
string = bytes(<unicode>unicode(arg), "utf-8")
301-
filter_c_str = string
302-
status = self._init_queue_from_filter_string(
303-
filter_c_str, props)
304299
elif isinstance(arg, SyclDevice):
305300
status = self._init_queue_from_device(<SyclDevice>arg, props)
306301
elif pycapsule.PyCapsule_IsValid(arg, "SyclQueueRef"):
@@ -690,7 +685,7 @@ cdef class SyclQueue(_SyclQueue):
690685
The address of the ``DPCTLSyclQueueRef`` object used to create this
691686
:class:`dpctl.SyclQueue` cast to a ``size_t``.
692687
"""
693-
return int(<size_t>self._queue_ref)
688+
return <size_t>self._queue_ref
694689

695690
cpdef SyclEvent submit(
696691
self,
@@ -848,8 +843,8 @@ cdef class SyclQueue(_SyclQueue):
848843
else:
849844
raise TypeError("Parameter `mem` should have type _Memory")
850845

851-
if (count <=0 or count > self.nbytes):
852-
count = self.nbytes
846+
if (count <=0 or count > mem.nbytes):
847+
count = mem.nbytes
853848

854849
ERef = DPCTLQueue_Prefetch(self._queue_ref, ptr, count)
855850
if (ERef is NULL):
@@ -868,8 +863,8 @@ cdef class SyclQueue(_SyclQueue):
868863
else:
869864
raise TypeError("Parameter `mem` should have type _Memory")
870865

871-
if (count <=0 or count > self.nbytes):
872-
count = self.nbytes
866+
if (count <=0 or count > mem.nbytes):
867+
count = mem.nbytes
873868

874869
ERef = DPCTLQueue_MemAdvise(self._queue_ref, ptr, count, advice)
875870
if (ERef is NULL):

0 commit comments

Comments
 (0)