Skip to content

Commit 653870b

Browse files
Merge pull request #1591 from IntelPython/memory-copy-via-host-get-rid-of-one-wait
2 parents 5f08828 + f56f128 commit 653870b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

dpctl/memory/_memory.pyx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ from dpctl._backend cimport ( # noqa: E211
4747
DPCTLQueue_Delete,
4848
DPCTLQueue_GetContext,
4949
DPCTLQueue_Memcpy,
50+
DPCTLQueue_MemcpyWithEvents,
5051
DPCTLQueue_Memset,
5152
DPCTLSyclContextRef,
5253
DPCTLSyclDeviceRef,
@@ -100,6 +101,7 @@ cdef void copy_via_host(void *dest_ptr, SyclQueue dest_queue,
100101
# could also have used bytearray(nbytes)
101102
cdef unsigned char[::1] host_buf = np.empty((nbytes,), dtype="|u1")
102103
cdef DPCTLSyclEventRef E1Ref = NULL
104+
cdef DPCTLSyclEventRef *depEvs = [NULL,]
103105
cdef DPCTLSyclEventRef E2Ref = NULL
104106

105107
E1Ref = DPCTLQueue_Memcpy(
@@ -108,16 +110,17 @@ cdef void copy_via_host(void *dest_ptr, SyclQueue dest_queue,
108110
src_ptr,
109111
nbytes
110112
)
111-
with nogil: DPCTLEvent_Wait(E1Ref)
112-
113-
E2Ref = DPCTLQueue_Memcpy(
113+
depEvs[0] = E1Ref
114+
E2Ref = DPCTLQueue_MemcpyWithEvents(
114115
dest_queue.get_queue_ref(),
115116
dest_ptr,
116117
<void *>&host_buf[0],
117-
nbytes
118+
nbytes,
119+
depEvs,
120+
1
118121
)
119-
with nogil: DPCTLEvent_Wait(E2Ref)
120122
DPCTLEvent_Delete(E1Ref)
123+
with nogil: DPCTLEvent_Wait(E2Ref)
121124
DPCTLEvent_Delete(E2Ref)
122125

123126

@@ -224,7 +227,6 @@ cdef class _Memory:
224227
self.memory_ptr = other_buf.p
225228
self.nbytes = other_buf.nbytes
226229
self.queue = other_buf.queue
227-
# self.writable = other_buf.writable
228230
self.refobj = other
229231
else:
230232
raise ValueError(

0 commit comments

Comments
 (0)