Skip to content

Add wrapper for SYCL queue::memcpy(). #70

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 6 commits into from
Sep 30, 2020

Conversation

PokhodenkoSA
Copy link
Contributor

@PokhodenkoSA PokhodenkoSA commented Sep 26, 2020

No description provided.

@@ -63,3 +63,4 @@ cdef class SyclQueue:
cpdef SyclContext get_sycl_context (self)
cpdef SyclDevice get_sycl_device (self)
cdef DPPLSyclQueueRef get_queue_ref (self)
cpdef memcpy (self, dest, src, int count)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean cdef ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For c part of cpdef to be efficient, dest and src need have type declarations. Looks like they can only be Memory objects.

The method does not use self at all, so should it be a static method of the class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method uses self in code DPPLQueue_memcpy(self.queue_ptr, c_dest, c_src, count).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it would be better to not expose memcpy as a stand-alone symbol, but rather make it two method copyto and copyfrom of Memory object. That way it could copy to/from another Memory object, or host memory of any object that supports a buffer protocol.

@oleksandr-pavlyk
Copy link
Contributor

The q.memcpy assumes pointers are either host pointers or USM pointers accessible in the context associated with the queue.

It would make sense for SyclQueue.memcpy to raise an exception if this is not the case.

But we still need a way to copy data from one Memory instance to another even if their memory reside in different SYCL contexts. So we could have Memory.copyto(src) and Memory.to_memoryview().

copyto would copy from src or type Memory using host as an intermediary if needed, or from src being Python's object exposing buffer interface.

Memory.to_memoryview() will create host memory, copy content of Memory to host memory and return the result as Python's memoryview object created from the host memory pointer.

@PokhodenkoSA
Copy link
Contributor Author

@oleksandr-pavlyk Additional features will be inpmelemted in another PR. The issue for it: #76

@diptorupd
Copy link
Contributor

@oleksandr-pavlyk @PokhodenkoSA With the remaining enhancement being tracked in #76 can we merge this as it stands right now?

@PokhodenkoSA
Copy link
Contributor Author

Lets merge it.

@PokhodenkoSA PokhodenkoSA merged commit 95047ab into IntelPython:master Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants