Simple memory buffer using un-managed pinned host memory when compiled with NVCC. Obviously this class is making explicit used of CUDA so replace it with your own memory allocator if you are not using CUDA.
More...
|
| | DualDeviceBuffer () |
| | Default constructor of an empty buffer.
|
| | DualDeviceBuffer (uint64_t size, int device=cudaCpuDeviceId, cudaStream_t stream=0) |
| | Constructor with a specified device and size.
|
| | DualDeviceBuffer (uint64_t size, bool host, void *stream) |
| | Constructor.
|
| | DualDeviceBuffer (uint64_t size, void *cpuData, void *gpuData) |
| | Constructor for externally managed host and device buffers.
|
| | DualDeviceBuffer (uint64_t size, void *cpuData, std::initializer_list< std::pair< int, void * > > list) |
| | Constructor for externally managed host and multiple device buffers.
|
| | DualDeviceBuffer (const DualDeviceBuffer &)=delete |
| | Disallow copy-construction.
|
| | DualDeviceBuffer (DualDeviceBuffer &&other) noexcept |
| | Move copy-constructor.
|
| | DualDeviceBuffer (const HostBuffer &buffer, int device=cudaCpuDeviceId, cudaStream_t stream=0) |
| | Copy-constructor from a HostBuffer.
|
| | ~DualDeviceBuffer () |
| | Destructor frees memory on both the host and device.
|
| DualDeviceBuffer & | operator= (const DualDeviceBuffer &)=delete |
| | Disallow copy assignment operation.
|
| DualDeviceBuffer & | operator= (DualDeviceBuffer &&other) noexcept |
| | Move copy assignment operation.
|
| void * | data () const |
| | Retuns a raw void pointer to the host/CPU buffer managed by this allocator.
|
| template<typename T> |
| T * | data (ptrdiff_t count=0, int device=cudaCpuDeviceId) const |
| | Returns an offset pointer of a specific type from the allocated host memory.
|
| void * | data (ptrdiff_t byteOffset, int device=cudaCpuDeviceId) const |
| | Returns a byte offset void pointer from the allocated host memory.
|
| void | orderAfterPriorUses (int device, cudaStream_t stream) const |
| | Order work subsequently issued on stream after every prior use of this device buffer, whichever stream those uses were issued on. The consume-side companion of recordUse: an external consumer (e.g. a zero-copy array-interface export) calls this with its own stream before reading, so it cannot observe a partially-written buffer after asynchronous uploads or recorded kernels.
|
| void | recordUse (int device, cudaStream_t stream) |
| | Record that this buffer's device data was just used on stream, so that the buffer's device frees (destructor, move-assignment, clear) are ordered after that work. Uses issued through deviceUpload/deviceDownload are recorded automatically; callers that enqueue their own kernels or copies against the raw pointer returned by deviceData() should call this afterwards. Without it, such work is only safe if it is on a blocking stream (which the free, issued on the default stream, waits on implicitly) or if the caller synchronizes before the buffer is cleared/destroyed.
|
| void * | deviceData (int device) const |
| | Retuns a raw pointer to the specified device/GPU buffer managed by this allocator.
|
| void * | deviceData () const |
| | Retuns a raw pointer to the current device/GPU buffer managed by this allocator.
|
| void | deviceUpload (int device=0, cudaStream_t stream=0, bool sync=true) |
| | Uploads buffer on the host to a specific device. If it doesn't exist it's created first.
|
| void | deviceUpload (int device, void *stream, bool sync) |
| void | deviceUpload (cudaStream_t stream, bool sync) |
| | Upload buffer from the host to ALL the existing devices, i.e. CPU -> GPU. If no device buffers exist one is created for the current device (typically 0) and subsequently populated with the host data.
|
| void | deviceUpload (void *stream, bool sync) |
| void | deviceDownload (int device=0, cudaStream_t stream=0, bool sync=true) |
| | Download data from a specified device to the host. If the host buffer des not exist it will first be allocated.
|
| void | deviceDownload (int device, void *stream, bool sync) |
| void | deviceDownload (void *stream, bool sync) |
| | Download the buffer from the current device to the host, i.e. GPU -> CPU. If the host buffer des not exist it will first be allocated.
|
| uint64_t | size () const |
| | Returns the size in bytes of the raw memory buffer managed by this allocator.
|
| uint64_t | capacity () const |
| int | bufferCount () const |
| | Returns the number of buffers that are not NULL.
|
| int | deviceCount () const |
| void | clear (cudaStream_t stream=0) |
| | De-allocate all memory managed by this allocator and set all pointers to NULL.
|
| void | clear (void *stream) |
| bool | empty () const |
| | Returns true if this allocator is empty, i.e. has no allocated memory.
|
| bool | isEmpty () const |
| | Returns true if this allocator is empty, i.e. has no allocated memory.
|
|
| static DualDeviceBuffer | create (uint64_t size, const DualDeviceBuffer *dummy, bool host, void *stream) |
| | Static factory method that return an instance of this buffer.
|
| static DualDeviceBuffer | create (uint64_t size, const DualDeviceBuffer *dummy=nullptr, int device=cudaCpuDeviceId, cudaStream_t stream=0) |
| | Static factory method that returns an instance of this buffer.
|
| static DualDeviceBuffer | create (uint64_t size, void *cpuData, void *gpuData) |
| | Static factory method that returns an instance of this buffer that wraps externally managed memory.
|
| static DualDeviceBuffer | create (uint64_t size, void *cpuData, std::initializer_list< std::pair< int, void * > > list) |
| | Static factory method that returns an instance of this buffer that wraps externally managed host and device memory.
|
| static DualDeviceBuffer | create (const HostBuffer &buffer, int device=cudaCpuDeviceId, cudaStream_t stream=0) |
| | Static factory method that returns an instance of this buffer constructed from a HostBuffer.
|
| static PtrT | createPtr (uint64_t size, const DualDeviceBuffer *=nullptr, int device=cudaCpuDeviceId, cudaStream_t stream=0) |
| | Factory methods that create a shared pointer to an DualDeviceBuffer instance.
|
| static PtrT | createPtr (uint64_t size, void *cpuData, void *gpuData) |
| | Factory methods that create a shared pointer to an DualDeviceBuffer instance.
|
| static PtrT | createPtr (uint64_t size, void *cpuData, std::initializer_list< std::pair< int, void * > > list) |
| | Factory methods that create a shared pointer to an DualDeviceBuffer instance.
|
| static PtrT | createPtr (const HostBuffer &buffer, int device=cudaCpuDeviceId, cudaStream_t stream=0) |
| | Factory methods that create a shared pointer to an DualDeviceBuffer instance.
|
Simple memory buffer using un-managed pinned host memory when compiled with NVCC. Obviously this class is making explicit used of CUDA so replace it with your own memory allocator if you are not using CUDA.
- Note
- While CUDA's pinned host memory allows for asynchronous memory copy between host and device it is significantly slower then cached (un-pinned) memory on the host.
-
This is the implementation behind the deprecated DeviceBuffer alias below, renamed so the [[deprecated]] attribute reaches only code that spells the public name: the GPU tools' signature defaults reference this implementation, so default-using callers stay warning-free until the defaults change at removal. Transitional – do not adopt this name; it is deleted together with the alias. The header keeps its long-standing name and include path for the same reason: renaming a header breaks existing includes outright, and the old path is where external code will find the alias and its migration message.