cupy.cuda.MemoryPointer¶
-
class
cupy.cuda.
MemoryPointer
(BaseMemory mem, ptrdiff_t offset)¶ Pointer to a point on a device memory.
An instance of this class holds a reference to the original memory buffer and a pointer to a place within this buffer.
Parameters: - mem (BaseMemory) – The device memory buffer.
- offset (int) – An offset from the head of the buffer to the place this pointer refers.
Variables: Methods
-
copy_from
(self, mem, size_t size)¶ Copies a memory sequence from a (possibly different) device or host.
This function is a useful interface that selects appropriate one from
copy_from_device()
andcopy_from_host()
.Parameters: - mem (ctypes.c_void_p or cupy.cuda.MemoryPointer) – Source memory pointer.
- size (int) – Size of the sequence in bytes.
-
copy_from_async
(self, mem, size_t size, stream=None)¶ Copies a memory sequence from an arbitrary place asynchronously.
This function is a useful interface that selects appropriate one from
copy_from_device_async()
andcopy_from_host_async()
.Parameters: - mem (ctypes.c_void_p or cupy.cuda.MemoryPointer) – Source memory pointer.
- size (int) – Size of the sequence in bytes.
- stream (cupy.cuda.Stream) – CUDA stream. The default uses CUDA stream of the current context.
-
copy_from_device
(self, MemoryPointer src, size_t size)¶ Copies a memory sequence from a (possibly different) device.
Parameters: - src (cupy.cuda.MemoryPointer) – Source memory pointer.
- size (int) – Size of the sequence in bytes.
-
copy_from_device_async
(self, MemoryPointer src, size_t size, stream=None)¶ Copies a memory from a (possibly different) device asynchronously.
Parameters: - src (cupy.cuda.MemoryPointer) – Source memory pointer.
- size (int) – Size of the sequence in bytes.
- stream (cupy.cuda.Stream) – CUDA stream. The default uses CUDA stream of the current context.
-
copy_from_host
(self, mem, size_t size)¶ Copies a memory sequence from the host memory.
Parameters: - mem (ctypes.c_void_p) – Source memory pointer.
- size (int) – Size of the sequence in bytes.
-
copy_from_host_async
(self, mem, size_t size, stream=None)¶ Copies a memory sequence from the host memory asynchronously.
Parameters: - mem (ctypes.c_void_p) – Source memory pointer. It must be a pinned memory.
- size (int) – Size of the sequence in bytes.
- stream (cupy.cuda.Stream) – CUDA stream. The default uses CUDA stream of the current context.
-
copy_to_host
(self, mem, size_t size)¶ Copies a memory sequence to the host memory.
Parameters: - mem (ctypes.c_void_p) – Target memory pointer.
- size (int) – Size of the sequence in bytes.
-
copy_to_host_async
(self, mem, size_t size, stream=None)¶ Copies a memory sequence to the host memory asynchronously.
Parameters: - mem (ctypes.c_void_p) – Target memory pointer. It must be a pinned memory.
- size (int) – Size of the sequence in bytes.
- stream (cupy.cuda.Stream) – CUDA stream. The default uses CUDA stream of the current context.
-
memset
(self, int value, size_t size)¶ Fills a memory sequence by constant byte value.
Parameters:
-
memset_async
(self, int value, size_t size, stream=None)¶ Fills a memory sequence by constant byte value asynchronously.
Parameters: - value (int) – Value to fill.
- size (int) – Size of the sequence in bytes.
- stream (cupy.cuda.Stream) – CUDA stream. The default uses CUDA stream of the current context.
Attributes
-
device
¶
-
device_id
¶
-
mem
¶
-
ptr
¶