bnmf-algs
host_memory_1d.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include "defs.hpp"
4 #include <cstddef>
5 
6 namespace bnmf_algs {
7 namespace cuda {
25 template <typename T> class HostMemory1D {
26  public:
31  using value_type = T;
32 
45  HostMemory1D(T* data, size_t num_elems)
46  : m_dims(shape<1>{num_elems}), m_data(data){};
47 
55  T* data() const { return m_data; }
56 
63  size_t bytes() const { return m_dims[0] * sizeof(T); }
64 
70  shape<1> dims() const { return m_dims; }
71 
72  private:
76  shape<1> m_dims;
80  T* m_data;
81 };
82 } // namespace cuda
83 } // namespace bnmf_algs
A wrapper template class around a contiguous array of T types laid out in main memory (host memory)...
Definition: host_memory_1d.hpp:25
size_t bytes() const
Get the number of bytes of the memory sequence wrapped with the current HostMemory1D object...
Definition: host_memory_1d.hpp:63
shape< 1 > dims() const
Get the dimensions of this memory region in terms of elements.
Definition: host_memory_1d.hpp:70
HostMemory1D(T *data, size_t num_elems)
Construct a HostMemory1D class around the memory given by address and number of elements.
Definition: host_memory_1d.hpp:45
Eigen::array< size_t, N > shape
Shape of vectors, matrices, tensors, etc.
Definition: defs.hpp:66
T value_type
Type of the values stored in the memory sequence wrapped around the current HostMemory1D object...
Definition: host_memory_1d.hpp:31
Main namespace for bnmf-algs library.
Definition: alloc_model_funcs.hpp:12
T * data() const
Get the address of the memory sequence wrapped with the current HostMemory1D object.
Definition: host_memory_1d.hpp:55