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

A wrapper template class around a contiguous array of T types laid out in main memory (host memory). More...

#include <host_memory_1d.hpp>

Public Types

using value_type = T
 Type of the values stored in the memory sequence wrapped around the current HostMemory1D object. More...
 

Public Member Functions

 HostMemory1D (T *data, size_t num_elems)
 Construct a HostMemory1D class around the memory given by address and number of elements. More...
 
T * data () const
 Get the address of the memory sequence wrapped with the current HostMemory1D object. More...
 
size_t bytes () const
 Get the number of bytes of the memory sequence wrapped with the current HostMemory1D object. More...
 
shape< 1 > dims () const
 Get the dimensions of this memory region in terms of elements. More...
 

Detailed Description

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

A wrapper template class around a contiguous array of T types laid out in main memory (host memory).

HostMemory1D class represents the memory for a contiguous sequence of T values in host memory. The intended use of this class is to provide an interface that can be used with CUDA functions.

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

Template Parameters
TType of the values in the given memory address.

Member Typedef Documentation

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

Type of the values stored in the memory sequence wrapped around the current HostMemory1D object.

Constructor & Destructor Documentation

template<typename T >
bnmf_algs::cuda::HostMemory1D< T >::HostMemory1D ( T *  data,
size_t  num_elems 
)
inline

Construct a HostMemory1D class around the memory given by address and number of elements.

The given memory address is assumed to reside in host memory (main memory). Therefore, this function does not perform any memory allocation on main memory or GPU device.

Parameters
dataBeginning address of the sequence of T values.
num_elemsNumber of T values in the sequence starting at parameter data.

Member Function Documentation

template<typename T >
size_t bnmf_algs::cuda::HostMemory1D< T >::bytes ( ) const
inline

Get the number of bytes of the memory sequence wrapped with the current HostMemory1D object.

Returns
Number of bytes of the memory sequence.
template<typename T >
T* bnmf_algs::cuda::HostMemory1D< T >::data ( ) const
inline

Get the address of the memory sequence wrapped with the current HostMemory1D object.

Returns
Beginning address of the memory sequence wrapped with the current HostMemory1D object.
template<typename T >
shape<1> bnmf_algs::cuda::HostMemory1D< T >::dims ( ) const
inline

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

Returns
A bnmf_algs::shape representing the dimension.

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