Skip to content

Commit ec0ec42

Browse files
Used DPCTLQueue_MemoryWithEvent to order copy operations
This eliminates one call to `DPCTLEvent_Wait`.
1 parent 5f08828 commit ec0ec42

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

dpctl/memory/_memory.pyx

Lines changed: 7 additions & 5 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[1] = {NULL}
103105
cdef DPCTLSyclEventRef E2Ref = NULL
104106

105107
E1Ref = DPCTLQueue_Memcpy(
@@ -108,13 +110,14 @@ 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
)
119122
with nogil: DPCTLEvent_Wait(E2Ref)
120123
DPCTLEvent_Delete(E1Ref)
@@ -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)