bnmf-algs
Public Types | Public Member Functions | List of all members
bnmf_algs::cuda::HostMemory3D< T > Class Template Reference

A wrapper template class around a row-major 3D tensor stored in main memory (host memory). More...

#include <host_memory_3d.hpp>

Public Types

using value_type = T
 Type of the values stored in main memory. More...
 

Public Member Functions

 HostMemory3D (T *data, size_t first_dim, size_t second_dim, size_t third_dim)
 Construct a HostMemory3D class around the memory given by the pointer and the dimensions of a 3D row-major tensor. More...
 
cudaPitchedPtr pitched_ptr () const
 Get the cudaPitchedPtr type storing allocation parameters and the pointer to the host 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...
 

Detailed Description

template<typename T>
class bnmf_algs::cuda::HostMemory3D< T >

A wrapper template class around a row-major 3D tensor stored in main memory (host memory).

HostMemory3D class represents the memory of a row-major 3D tensor type stored in main memory (host memory). The intended use of this class is to provide an interface that can be used with CUDA functions.

HostMemory3D class does not own the memory it is given. Therefore, no allocation, copying or memory freeing is performed. The only use case of HostMemory3D is to provide a unified interface with DeviceMemory3D so that the two classes can be used interchangeably by cuda::copy3D function. See cuda::copy3D for details about copying 3D memory using CUDA functions from host/device to host/device memory.

If the pointer pointing to the memory is const, then the type of this class must be marked as const to prevent illegal mutating code from accessing the memory. For example,

const tensord<3> tensor(2, 3, 4);
// mark T as const so that the instantiations of the template functions
// and the member pointers are marked as const.
HostMemory3D<const double> host_memory(tensor.data(), 2, 3, 4);
Template Parameters
TType of the values in the given memory address.

Member Typedef Documentation

template<typename T>
using bnmf_algs::cuda::HostMemory3D< T >::value_type = T

Type of the values stored in main memory.

Constructor & Destructor Documentation

template<typename T>
bnmf_algs::cuda::HostMemory3D< T >::HostMemory3D ( T *  data,
size_t  first_dim,
size_t  second_dim,
size_t  third_dim 
)
inlineexplicit

Construct a HostMemory3D class around the memory given by the pointer and the dimensions of a 3D row-major tensor.

The memory given by pointer is assumed to reside in main memory. Therefore, this function does not perform any memory allocation on main memory or GPU device.

Parameters
dataAddress of the beginning of the memory storing the row-major 3D tensor.
first_dimFirst dimension of the tensor. Since the given tensor memory is row-major, this is the dimension whose index changes the slowest when traversing the contiguous memory pointed by pointer parameter data.
second_dimSecond dimension of the tensor.
third_dimThird dimension of the tensor. Since the given tensor memory is row-major, this is the dimension whose index changse the fastest when traversing the contiguous memory pointed by pointer parameter data.

Member Function Documentation

template<typename T>
shape<3> bnmf_algs::cuda::HostMemory3D< T >::dims ( ) const
inline

Get the dimensions of this memory region in terms of elements.

Returns
A bnmf_algs::shape object of the form {first_dim, second_dim, third_dim}.
template<typename T>
cudaExtent bnmf_algs::cuda::HostMemory3D< T >::extent ( ) const
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.

Returns
cudaExtent type storing the extents of the allocation.
template<typename T>
cudaPitchedPtr bnmf_algs::cuda::HostMemory3D< T >::pitched_ptr ( ) const
inline

Get the cudaPitchedPtr type storing allocation parameters and the pointer to the host 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.

Returns
cudaPitchedPtr type storing allocation parameters and the pointer itself.

The documentation for this class was generated from the following file: