bnmf-algs
|
A wrapper template class around 3D row-major pitched memory stored in device memory (GPU memory). More...
#include <device_memory_3d.hpp>
Public Types | |
using | value_type = T |
Type of the values stored on GPU. More... | |
Public Member Functions | |
DeviceMemory3D (size_t first_dim, size_t second_dim, size_t third_dim) | |
Construct a DeviceMemory3D object responsible from the GPU memory allocated with respect to the given host matrix. More... | |
DeviceMemory3D (const DeviceMemory3D &)=delete | |
Copy constructor (deleted). More... | |
DeviceMemory3D & | operator= (const DeviceMemory3D &)=delete |
Copy assignment operator (deleted). More... | |
DeviceMemory3D (DeviceMemory3D &&other) | |
Move constructor. More... | |
DeviceMemory3D & | operator= (DeviceMemory3D &&other) |
Move assignment operator. More... | |
~DeviceMemory3D () | |
Destruct the current DeviceMemory3D object by deallocating the held GPU memory. More... | |
cudaPitchedPtr | pitched_ptr () const |
Get the cudaPitchedPtr type storing allocation parameters and the pointer to the device memory. More... | |
cudaExtent | extent () const |
Get the cudaExtent type storing the extents of the allocation. More... | |
shape< 3 > | dims () const |
Get the dimensions of this memory region in terms of elements. More... | |
A wrapper template class around 3D row-major pitched memory stored in device memory (GPU memory).
DeviceMemory3D class represents the memory of a row-major tensor stored in device memory (GPU memory). The intended use of this class is to provide an interface that can be used with CUDA functions.
DeviceMemory3D class owns the memory it allocates on the GPU, and therefore is responsible from the deallocation of the allocated GPU memory. GPU memory allocation is performed upon object construction and deallocation is performed upon object destruction.
DeviceMemory3D objects can be used with cuda::copy3D function along with HostMemory3D objects to copy memory from host/device to host/device locations. See cuda::copy3D for details about copying memory using CUDA functions.
T | Type of the values in the given memory address. |
using bnmf_algs::cuda::DeviceMemory3D< T >::value_type = T |
Type of the values stored on GPU.
|
inlineexplicit |
Construct a DeviceMemory3D object responsible from the GPU memory allocated with respect to the given host matrix.
This constructor allocates a 3D row-major pitched memory on the GPU using cudaMalloc3D function. The allocated tensor memory is in row-major order. Therefore, pitch of the GPU memory is set as the number of bytes of a single fiber of the tensor (along 3rd dimension). See cudaMalloc3D documentation to learn more about the intrinsics of the memory allocation procedure.
first_dim | First dimension of the 3D memory to allocate. |
second_dim | Second dimension of the 3D memory to allocate. |
third_dim | Third dimension of the 3D memory to allocate. Since the tensor is allocated in row-major order, allocation pitch is set as the number of bytes required to store a single fiber along the third dimension. |
|
delete |
Copy constructor (deleted).
Since DeviceMemory3D objects own the memory they own, only move operators are allowed.
|
inline |
Move constructor.
Move construct a new DeviceMemory3D object. After this constructor exits, the parameter DeviceMemory3D object does not point to any location and therefore must not be used.
other | Other DeviceMemory3D object to move from. |
|
inline |
Destruct the current DeviceMemory3D object by deallocating the held GPU memory.
This function deallocates the GPU memory held by the current DeviceMemory3D object. See cudaFree function documentation for memory deallocation intrinsics.
|
inline |
Get the dimensions of this memory region in terms of elements.
|
inline |
Get the cudaExtent type storing the extents of the allocation.
Parameters of the returned extent type is set according to a row-major tensor allocation. See cudaExtent type documentation for the parameters provided about the allocation.
|
delete |
Copy assignment operator (deleted).
Since DeviceMemory3D objects own the memory they own, only move operators are allowed.
|
inline |
Move assignment operator.
Move assign to this DeviceMemory3D object. After this constructor exits, the parameter DeviceMemor(3D object does not point to any location and therefore must not be used. Additionally, the old memory pointed by this DeviceMemory3D is freed.
other | Other DeviceMemory3D object to move from. |
|
inline |
Get the cudaPitchedPtr type storing allocation parameters and the pointer to the device memory.
Parameters of the returned pitched pointer type is set according to a row-major tensor allocation. See cudaPitchedPtr type documentation for the parameters provided about the allocation.