Skip to content

Used DPCTLQueue_MemoryWithEvent to order copy operations #1591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions dpctl/memory/_memory.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ from dpctl._backend cimport ( # noqa: E211
DPCTLQueue_Delete,
DPCTLQueue_GetContext,
DPCTLQueue_Memcpy,
DPCTLQueue_MemcpyWithEvents,
DPCTLQueue_Memset,
DPCTLSyclContextRef,
DPCTLSyclDeviceRef,
Expand Down Expand Up @@ -100,6 +101,7 @@ cdef void copy_via_host(void *dest_ptr, SyclQueue dest_queue,
# could also have used bytearray(nbytes)
cdef unsigned char[::1] host_buf = np.empty((nbytes,), dtype="|u1")
cdef DPCTLSyclEventRef E1Ref = NULL
cdef DPCTLSyclEventRef *depEvs = [NULL,]
cdef DPCTLSyclEventRef E2Ref = NULL

E1Ref = DPCTLQueue_Memcpy(
Expand All @@ -108,16 +110,17 @@ cdef void copy_via_host(void *dest_ptr, SyclQueue dest_queue,
src_ptr,
nbytes
)
with nogil: DPCTLEvent_Wait(E1Ref)

E2Ref = DPCTLQueue_Memcpy(
depEvs[0] = E1Ref
E2Ref = DPCTLQueue_MemcpyWithEvents(
dest_queue.get_queue_ref(),
dest_ptr,
<void *>&host_buf[0],
nbytes
nbytes,
depEvs,
1
)
with nogil: DPCTLEvent_Wait(E2Ref)
DPCTLEvent_Delete(E1Ref)
with nogil: DPCTLEvent_Wait(E2Ref)
DPCTLEvent_Delete(E2Ref)


Expand Down Expand Up @@ -224,7 +227,6 @@ cdef class _Memory:
self.memory_ptr = other_buf.p
self.nbytes = other_buf.nbytes
self.queue = other_buf.queue
# self.writable = other_buf.writable
self.refobj = other
else:
raise ValueError(
Expand Down