Description
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.
Originally posted by @oleksandr-pavlyk in #70 (comment)
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.
Originally posted by @oleksandr-pavlyk in #70 (comment)