Skip to content

Commit 106c8de

Browse files
Add queue synchronization points in special methods for conversion to scalars
Also synchronize in __sycl_usm_array_interface__ attribute, to ensure that `dpctl.memory.as_usm_memory(ary).copy_to_host()` produces expected results.
1 parent be401a6 commit 106c8de

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

dpctl/tensor/_usmarray.pyx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import numpy as np
2424

2525
import dpctl
2626
import dpctl.memory as dpmem
27-
import dpctl.utils as du
2827

2928
from .._backend cimport DPCTLSyclUSMRef
3029
from .._sycl_device_factory cimport _cached_default_device
@@ -82,7 +81,7 @@ cdef class InternalUSMArrayError(Exception):
8281
cdef object _as_zero_dim_ndarray(object usm_ary):
8382
"Convert size-1 array to NumPy 0d array"
8483
mem_view = dpmem.as_usm_memory(usm_ary)
85-
du.SequentialOrderManager.wait()
84+
usm_ary.sycl_queue.wait()
8685
host_buf = mem_view.copy_to_host()
8786
view = host_buf.view(usm_ary.dtype)
8887
view.shape = tuple()
@@ -519,6 +518,8 @@ cdef class usm_ndarray:
519518
"byte_offset is not a multiple of item_size.")
520519
elem_offset = byte_offset // item_size
521520
ary_iface['offset'] = elem_offset
521+
# must wait for content of the memory to finalize
522+
self.sycl_queue.wait()
522523
return ary_iface
523524

524525
@property

0 commit comments

Comments
 (0)