def copy_to_host(self, mem, size): """Copies a memory sequence to the host memory. Args: mem (ctypes.c_void_p): Target memory pointer. size (int): Size of the sequence in bytes. """ if size > 0: runtime.memcpy(mem, self.ptr, size, runtime.memcpyDeviceToHost)
def copy_from_host(self, mem, size): """Copies a memory sequence from the host memory. Args: mem (ctypes.c_void_p): Source memory pointer. size (int): Size of the sequence in bytes. """ if size > 0: runtime.memcpy(self.ptr, mem, size, runtime.memcpyHostToDevice)
def copy_from_device(self, src, size): """Copies a memory sequence from the same device. Args: src (cupy.cuda.MemoryPointer): Source memory pointer. size (int): Size of the sequence in bytes. """ if size > 0: runtime.memcpy(self.ptr, src.ptr, size, runtime.memcpyDeviceToDevice)