SIRIUS 7.5.0
Electronic structure library and applications
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
sirius::sddk::mdarray< T, N > Class Template Reference

Multidimensional array with the column-major (Fortran) order. More...

#include <memory.hpp>

Public Types

using index_type = mdarray_index_descriptor::index_type
 

Public Member Functions

 mdarray ()
 Default constructor. More...
 
 ~mdarray ()
 Destructor. More...
 
 mdarray (std::array< mdarray_index_descriptor, N > const dims__, memory_t memory__=memory_t::host, std::string label__="")
 N-dimensional array with index bounds. More...
 
 mdarray (mdarray_index_descriptor const &d0, memory_t memory__=memory_t::host, std::string label__="")
 1D array with memory allocation. More...
 
 mdarray (mdarray_index_descriptor const &d0, memory_pool &mp__, std::string label__="")
 1D array with memory pool allocation. More...
 
 mdarray (T *ptr__, mdarray_index_descriptor const &d0, std::string label__="")
 1D array with host pointer wrapper. More...
 
 mdarray (T *ptr__, T *ptr_device__, mdarray_index_descriptor const &d0, std::string label__="")
 1D array with host and device pointer wrapper. More...
 
 mdarray (mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, memory_t memory__=memory_t::host, std::string label__="")
 2D array with memory allocation. More...
 
 mdarray (mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, mdarray_index_descriptor const &d2, memory_t memory__=memory_t::host, std::string label__="")
 3D array with memory allocation. More...
 
 mdarray (mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, mdarray_index_descriptor const &d2, mdarray_index_descriptor const &d3, memory_t memory__=memory_t::host, std::string label__="")
 4D array with memory allocation. More...
 
 mdarray (mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, mdarray_index_descriptor const &d2, mdarray_index_descriptor const &d3, mdarray_index_descriptor const &d4, memory_t memory__=memory_t::host, std::string label__="")
 5D array with memory allocation. More...
 
 mdarray (mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, mdarray_index_descriptor const &d2, mdarray_index_descriptor const &d3, mdarray_index_descriptor const &d4, mdarray_index_descriptor const &d5, memory_t memory__=memory_t::host, std::string label__="")
 6D array with memory allocation. More...
 
 mdarray (T *ptr__, mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, std::string label__="")
 Wrap a pointer into 2D array. More...
 
 mdarray (T *ptr__, T *ptr_device__, mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, std::string label__="")
 
 mdarray (mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, memory_pool &mp__, std::string label__="")
 2D array with memory pool allocation. More...
 
 mdarray (T *ptr__, mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, mdarray_index_descriptor const &d2, std::string label__="")
 
 mdarray (T *ptr__, T *ptr_device__, mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, mdarray_index_descriptor const &d2, std::string label__="")
 
 mdarray (mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, mdarray_index_descriptor const &d2, memory_pool &mp__, std::string label__="")
 3D array with memory pool allocation. More...
 
 mdarray (T *ptr__, mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, mdarray_index_descriptor const &d2, mdarray_index_descriptor const &d3, std::string label__="")
 
 mdarray (T *ptr__, mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, mdarray_index_descriptor const &d2, mdarray_index_descriptor const &d3, mdarray_index_descriptor const &d4, std::string label__="")
 
 mdarray (T *ptr__, mdarray_index_descriptor const &d0, mdarray_index_descriptor const &d1, mdarray_index_descriptor const &d2, mdarray_index_descriptor const &d3, mdarray_index_descriptor const &d4, mdarray_index_descriptor const &d5, std::string label__="")
 
 mdarray (mdarray< T, N > &&src)
 Move constructor. More...
 
mdarray< T, N > & operator= (mdarray< T, N > &&src)
 Move assignment operator. More...
 
mdarray< T, N > & allocate (memory_t memory__)
 Allocate memory for array. More...
 
mdarray< T, N > & allocate (memory_pool &mp__)
 Allocate memory from the pool. More...
 
void deallocate (memory_t memory__)
 Deallocate host or device memory. More...
 
template<typename... Args>
T const & operator() (Args... args) const
 Access operator() for the elements of multidimensional array. More...
 
template<typename... Args>
T & operator() (Args... args)
 Access operator() for the elements of multidimensional array. More...
 
T const & operator[] (size_t const idx__) const
 Access operator[] for the elements of multidimensional array using a linear index in the range [0, size). More...
 
T & operator[] (size_t const idx__)
 Access operator[] for the elements of multidimensional array using a linear index in the range [0, size). More...
 
template<typename... Args>
T const * at (memory_t mem__, Args... args) const
 
template<typename... Args>
T * at (memory_t mem__, Args... args)
 
T const * at (memory_t mem__) const
 Return pointer to the beginning of array. More...
 
T * at (memory_t mem__)
 Return pointer to the beginning of array. More...
 
T * host_data ()
 
const T * host_data () const
 
T * device_data ()
 
const T * device_data () const
 
size_t size () const
 Return total size (number of elements) of the array. More...
 
size_t size (int i) const
 Return size of particular dimension. More...
 
mdarray_index_descriptor dim (int i) const
 Return a descriptor of a dimension. More...
 
uint32_t ld () const
 Return leading dimension size. More...
 
uint64_t hash (uint64_t h__=5381) const
 Compute hash of the array. More...
 
checksum_w (size_t idx0__, size_t size__) const
 Compute weighted checksum. More...
 
checksum (size_t idx0__, size_t size__) const
 Compute checksum. More...
 
checksum () const
 
T * begin ()
 
T const * begin () const
 
T * end ()
 
T const * end () const
 
void zero (memory_t mem__, size_t idx0__, size_t n__)
 Zero n elements starting from idx0. More...
 
void zero (memory_t mem__=memory_t::host)
 Zero the entire array. More...
 
void copy_to (memory_t mem__, size_t idx0__, size_t n__, acc::stream_id sid=acc::stream_id(-1))
 Copy n elements starting from idx0 from one memory type to another. More...
 
void copy_to (memory_t mem__, acc::stream_id sid=acc::stream_id(-1))
 Copy entire array from one memory type to another. More...
 
bool on_device () const
 Check if device pointer is available. More...
 
auto label () const
 
bool on_host () const
 
mdarray< T, N > & operator= (std::function< T(void)> f__)
 
mdarray< T, N > & operator= (std::function< T(index_type)> f__)
 
mdarray< T, N > & operator= (std::function< T(index_type, index_type)> f__)
 

Private Member Functions

void init_dimensions (std::array< mdarray_index_descriptor, N > const dims__)
 Initialize the offsets used to compute the index of the elements. More...
 
template<typename... Args>
index_type idx (Args... args) const
 Return linear index in the range [0, size) by the N-dimensional indices (i0, i1, ...) More...
 
template<bool check_assert = true>
T const * at_idx (memory_t mem__, index_type const idx__) const
 Return cosnt pointer to an element at a given index. More...
 
template<bool check_assert = true>
T * at_idx (memory_t mem__, index_type const idx__)
 Return pointer to an element at a given index. More...
 
void call_constructor ()
 
void call_destructor ()
 
 mdarray (mdarray< T, N > const &src)=delete
 Copy constructor is forbidden.
 
mdarray< T, N > & operator= (mdarray< T, N > const &src)=delete
 Assignment operator is forbidden.
 

Private Attributes

std::string label_
 Optional array label. More...
 
std::unique_ptr< T, memory_t_deleter_baseunique_ptr_ {nullptr}
 Unique pointer to the allocated memory. More...
 
T * raw_ptr_ {nullptr}
 Raw pointer. More...
 
std::unique_ptr< T, memory_t_deleter_baseunique_ptr_device_ {nullptr}
 Unique pointer to the allocated GPU memory. More...
 
T * raw_ptr_device_ {nullptr}
 Raw pointer to GPU memory. More...
 
std::array< mdarray_index_descriptor, N > dims_
 Array dimensions. More...
 
std::array< index_type, N > offsets_
 List of offsets to compute the element location by dimension indices. More...
 

Detailed Description

template<typename T, int N>
class sirius::sddk::mdarray< T, N >

Multidimensional array with the column-major (Fortran) order.

The implementation supports two memory pointers: one is accessible by CPU and second is accessible by a device. The following constructors are implemented:

// wrap a host memory pointer and create 2D array 10 x 20.
mdarray<T, 2>(ptr, 10, 20);
// wrap a host and device pointers
mdarray<T, 2>(ptr, ptr_d, 10, 20);
// wrap a device pointers only
mdarray<T, 2>(nullptr, ptr_d, 10, 20);
// create 10 x 20 2D array in main memory
mdarray<T, 2>(10, 20);
// create 10 x 20 2D array in device memory
mdarray<T, 2>(10, 20, memory_t::device);
// create from the pool memory (pool of any memory type is allowed)
memory_pool mp(memory_t::host);
mdarray<T, 2>(mp, 10, 20);

The pointers can be wrapped only in constructor. Memory allocation can be done by a separate call to .allocate() method.

Definition at line 659 of file memory.hpp.

Member Typedef Documentation

◆ index_type

template<typename T , int N>
using sirius::sddk::mdarray< T, N >::index_type = mdarray_index_descriptor::index_type

Definition at line 662 of file memory.hpp.

Constructor & Destructor Documentation

◆ mdarray() [1/21]

template<typename T , int N>
sirius::sddk::mdarray< T, N >::mdarray ( )
inline

Default constructor.

Definition at line 785 of file memory.hpp.

◆ ~mdarray()

template<typename T , int N>
sirius::sddk::mdarray< T, N >::~mdarray ( )
inline

Destructor.

Definition at line 790 of file memory.hpp.

◆ mdarray() [2/21]

template<typename T , int N>
sirius::sddk::mdarray< T, N >::mdarray ( std::array< mdarray_index_descriptor, N > const  dims__,
memory_t  memory__ = memory_t::host,
std::string  label__ = "" 
)
inline

N-dimensional array with index bounds.

Definition at line 797 of file memory.hpp.

◆ mdarray() [3/21]

template<typename T , int N>
sirius::sddk::mdarray< T, N >::mdarray ( mdarray_index_descriptor const &  d0,
memory_t  memory__ = memory_t::host,
std::string  label__ = "" 
)
inline

1D array with memory allocation.

Definition at line 811 of file memory.hpp.

◆ mdarray() [4/21]

template<typename T , int N>
sirius::sddk::mdarray< T, N >::mdarray ( mdarray_index_descriptor const &  d0,
memory_pool mp__,
std::string  label__ = "" 
)
inline

1D array with memory pool allocation.

Definition at line 821 of file memory.hpp.

◆ mdarray() [5/21]

template<typename T , int N>
sirius::sddk::mdarray< T, N >::mdarray ( T *  ptr__,
mdarray_index_descriptor const &  d0,
std::string  label__ = "" 
)
inline

1D array with host pointer wrapper.

Definition at line 831 of file memory.hpp.

◆ mdarray() [6/21]

template<typename T , int N>
sirius::sddk::mdarray< T, N >::mdarray ( T *  ptr__,
T *  ptr_device__,
mdarray_index_descriptor const &  d0,
std::string  label__ = "" 
)
inline

1D array with host and device pointer wrapper.

Definition at line 841 of file memory.hpp.

◆ mdarray() [7/21]

template<typename T , int N>
sirius::sddk::mdarray< T, N >::mdarray ( mdarray_index_descriptor const &  d0,
mdarray_index_descriptor const &  d1,
memory_t  memory__ = memory_t::host,
std::string  label__ = "" 
)
inline

2D array with memory allocation.

Definition at line 859 of file memory.hpp.

◆ mdarray() [8/21]

template<typename T , int N>
sirius::sddk::mdarray< T, N >::mdarray ( mdarray_index_descriptor const &  d0,
mdarray_index_descriptor const &  d1,
mdarray_index_descriptor const &  d2,
memory_t  memory__ = memory_t::host,
std::string  label__ = "" 
)
inline

3D array with memory allocation.

Definition at line 870 of file memory.hpp.

◆ mdarray() [9/21]

template<typename T , int N>
sirius::sddk::mdarray< T, N >::mdarray ( mdarray_index_descriptor const &  d0,
mdarray_index_descriptor const &  d1,
mdarray_index_descriptor const &  d2,
mdarray_index_descriptor const &  d3,
memory_t  memory__ = memory_t::host,
std::string  label__ = "" 
)
inline

4D array with memory allocation.

Definition at line 881 of file memory.hpp.

◆ mdarray() [10/21]

template<typename T , int N>
sirius::sddk::mdarray< T, N >::mdarray ( mdarray_index_descriptor const &  d0,
mdarray_index_descriptor const &  d1,
mdarray_index_descriptor const &  d2,
mdarray_index_descriptor const &  d3,
mdarray_index_descriptor const &  d4,
memory_t  memory__ = memory_t::host,
std::string  label__ = "" 
)
inline

5D array with memory allocation.

Definition at line 892 of file memory.hpp.

◆ mdarray() [11/21]

template<typename T , int N>
sirius::sddk::mdarray< T, N >::mdarray ( mdarray_index_descriptor const &  d0,
mdarray_index_descriptor const &  d1,
mdarray_index_descriptor const &  d2,
mdarray_index_descriptor const &  d3,
mdarray_index_descriptor const &  d4,
mdarray_index_descriptor const &  d5,
memory_t  memory__ = memory_t::host,
std::string  label__ = "" 
)
inline

6D array with memory allocation.

Definition at line 904 of file memory.hpp.

◆ mdarray() [12/21]

template<typename T , int N>
sirius::sddk::mdarray< T, N >::mdarray ( T *  ptr__,
mdarray_index_descriptor const &  d0,
mdarray_index_descriptor const &  d1,
std::string  label__ = "" 
)
inline

Wrap a pointer into 2D array.

Definition at line 916 of file memory.hpp.

◆ mdarray() [13/21]

template<typename T , int N>
sirius::sddk::mdarray< T, N >::mdarray ( T *  ptr__,
T *  ptr_device__,
mdarray_index_descriptor const &  d0,
mdarray_index_descriptor const &  d1,
std::string  label__ = "" 
)
inline

Definition at line 925 of file memory.hpp.

◆ mdarray() [14/21]

template<typename T , int N>
sirius::sddk::mdarray< T, N >::mdarray ( mdarray_index_descriptor const &  d0,
mdarray_index_descriptor const &  d1,
memory_pool mp__,
std::string  label__ = "" 
)
inline

2D array with memory pool allocation.

Definition at line 939 of file memory.hpp.

◆ mdarray() [15/21]

template<typename T , int N>
sirius::sddk::mdarray< T, N >::mdarray ( T *  ptr__,
mdarray_index_descriptor const &  d0,
mdarray_index_descriptor const &  d1,
mdarray_index_descriptor const &  d2,
std::string  label__ = "" 
)
inline

Definition at line 949 of file memory.hpp.

◆ mdarray() [16/21]

template<typename T , int N>
sirius::sddk::mdarray< T, N >::mdarray ( T *  ptr__,
T *  ptr_device__,
mdarray_index_descriptor const &  d0,
mdarray_index_descriptor const &  d1,
mdarray_index_descriptor const &  d2,
std::string  label__ = "" 
)
inline

Definition at line 959 of file memory.hpp.

◆ mdarray() [17/21]

template<typename T , int N>
sirius::sddk::mdarray< T, N >::mdarray ( mdarray_index_descriptor const &  d0,
mdarray_index_descriptor const &  d1,
mdarray_index_descriptor const &  d2,
memory_pool mp__,
std::string  label__ = "" 
)
inline

3D array with memory pool allocation.

Definition at line 973 of file memory.hpp.

◆ mdarray() [18/21]

template<typename T , int N>
sirius::sddk::mdarray< T, N >::mdarray ( T *  ptr__,
mdarray_index_descriptor const &  d0,
mdarray_index_descriptor const &  d1,
mdarray_index_descriptor const &  d2,
mdarray_index_descriptor const &  d3,
std::string  label__ = "" 
)
inline

Definition at line 983 of file memory.hpp.

◆ mdarray() [19/21]

template<typename T , int N>
sirius::sddk::mdarray< T, N >::mdarray ( T *  ptr__,
mdarray_index_descriptor const &  d0,
mdarray_index_descriptor const &  d1,
mdarray_index_descriptor const &  d2,
mdarray_index_descriptor const &  d3,
mdarray_index_descriptor const &  d4,
std::string  label__ = "" 
)
inline

Definition at line 993 of file memory.hpp.

◆ mdarray() [20/21]

template<typename T , int N>
sirius::sddk::mdarray< T, N >::mdarray ( T *  ptr__,
mdarray_index_descriptor const &  d0,
mdarray_index_descriptor const &  d1,
mdarray_index_descriptor const &  d2,
mdarray_index_descriptor const &  d3,
mdarray_index_descriptor const &  d4,
mdarray_index_descriptor const &  d5,
std::string  label__ = "" 
)
inline

Definition at line 1004 of file memory.hpp.

◆ mdarray() [21/21]

template<typename T , int N>
sirius::sddk::mdarray< T, N >::mdarray ( mdarray< T, N > &&  src)
inline

Move constructor.

Definition at line 1016 of file memory.hpp.

Member Function Documentation

◆ init_dimensions()

template<typename T , int N>
void sirius::sddk::mdarray< T, N >::init_dimensions ( std::array< mdarray_index_descriptor, N > const  dims__)
inlineprivate

Initialize the offsets used to compute the index of the elements.

Definition at line 687 of file memory.hpp.

◆ idx()

template<typename T , int N>
template<typename... Args>
index_type sirius::sddk::mdarray< T, N >::idx ( Args...  args) const
inlineprivate

Return linear index in the range [0, size) by the N-dimensional indices (i0, i1, ...)

Definition at line 702 of file memory.hpp.

◆ at_idx() [1/2]

template<typename T , int N>
template<bool check_assert = true>
T const * sirius::sddk::mdarray< T, N >::at_idx ( memory_t  mem__,
index_type const  idx__ 
) const
inlineprivate

Return cosnt pointer to an element at a given index.

Definition at line 722 of file memory.hpp.

◆ at_idx() [2/2]

template<typename T , int N>
template<bool check_assert = true>
T * sirius::sddk::mdarray< T, N >::at_idx ( memory_t  mem__,
index_type const  idx__ 
)
inlineprivate

Return pointer to an element at a given index.

Definition at line 752 of file memory.hpp.

◆ call_constructor()

template<typename T , int N>
void sirius::sddk::mdarray< T, N >::call_constructor ( )
inlineprivate

Definition at line 758 of file memory.hpp.

◆ call_destructor()

template<typename T , int N>
void sirius::sddk::mdarray< T, N >::call_destructor ( )
inlineprivate

Definition at line 768 of file memory.hpp.

◆ operator=() [1/4]

template<typename T , int N>
mdarray< T, N > & sirius::sddk::mdarray< T, N >::operator= ( mdarray< T, N > &&  src)
inline

Move assignment operator.

Definition at line 1036 of file memory.hpp.

◆ allocate() [1/2]

template<typename T , int N>
mdarray< T, N > & sirius::sddk::mdarray< T, N >::allocate ( memory_t  memory__)
inline

Allocate memory for array.

Definition at line 1057 of file memory.hpp.

◆ allocate() [2/2]

template<typename T , int N>
mdarray< T, N > & sirius::sddk::mdarray< T, N >::allocate ( memory_pool mp__)
inline

Allocate memory from the pool.

Definition at line 1081 of file memory.hpp.

◆ deallocate()

template<typename T , int N>
void sirius::sddk::mdarray< T, N >::deallocate ( memory_t  memory__)
inline

Deallocate host or device memory.

Definition at line 1104 of file memory.hpp.

◆ operator()() [1/2]

template<typename T , int N>
template<typename... Args>
T const & sirius::sddk::mdarray< T, N >::operator() ( Args...  args) const
inline

Access operator() for the elements of multidimensional array.

Definition at line 1124 of file memory.hpp.

◆ operator()() [2/2]

template<typename T , int N>
template<typename... Args>
T & sirius::sddk::mdarray< T, N >::operator() ( Args...  args)
inline

Access operator() for the elements of multidimensional array.

Definition at line 1132 of file memory.hpp.

◆ operator[]() [1/2]

template<typename T , int N>
T const & sirius::sddk::mdarray< T, N >::operator[] ( size_t const  idx__) const
inline

Access operator[] for the elements of multidimensional array using a linear index in the range [0, size).

Definition at line 1138 of file memory.hpp.

◆ operator[]() [2/2]

template<typename T , int N>
T & sirius::sddk::mdarray< T, N >::operator[] ( size_t const  idx__)
inline

Access operator[] for the elements of multidimensional array using a linear index in the range [0, size).

Definition at line 1145 of file memory.hpp.

◆ at() [1/4]

template<typename T , int N>
template<typename... Args>
T const * sirius::sddk::mdarray< T, N >::at ( memory_t  mem__,
Args...  args 
) const
inline

Definition at line 1151 of file memory.hpp.

◆ at() [2/4]

template<typename T , int N>
template<typename... Args>
T * sirius::sddk::mdarray< T, N >::at ( memory_t  mem__,
Args...  args 
)
inline

Definition at line 1157 of file memory.hpp.

◆ at() [3/4]

template<typename T , int N>
T const * sirius::sddk::mdarray< T, N >::at ( memory_t  mem__) const
inline

Return pointer to the beginning of array.

Definition at line 1163 of file memory.hpp.

◆ at() [4/4]

template<typename T , int N>
T * sirius::sddk::mdarray< T, N >::at ( memory_t  mem__)
inline

Return pointer to the beginning of array.

Definition at line 1169 of file memory.hpp.

◆ host_data() [1/2]

template<typename T , int N>
T * sirius::sddk::mdarray< T, N >::host_data ( )
inline

Definition at line 1174 of file memory.hpp.

◆ host_data() [2/2]

template<typename T , int N>
const T * sirius::sddk::mdarray< T, N >::host_data ( ) const
inline

Definition at line 1180 of file memory.hpp.

◆ device_data() [1/2]

template<typename T , int N>
T * sirius::sddk::mdarray< T, N >::device_data ( )
inline

Definition at line 1186 of file memory.hpp.

◆ device_data() [2/2]

template<typename T , int N>
const T * sirius::sddk::mdarray< T, N >::device_data ( ) const
inline

Definition at line 1196 of file memory.hpp.

◆ size() [1/2]

template<typename T , int N>
size_t sirius::sddk::mdarray< T, N >::size ( ) const
inline

Return total size (number of elements) of the array.

Definition at line 1207 of file memory.hpp.

◆ size() [2/2]

template<typename T , int N>
size_t sirius::sddk::mdarray< T, N >::size ( int  i) const
inline

Return size of particular dimension.

Definition at line 1219 of file memory.hpp.

◆ dim()

template<typename T , int N>
mdarray_index_descriptor sirius::sddk::mdarray< T, N >::dim ( int  i) const
inline

Return a descriptor of a dimension.

Definition at line 1226 of file memory.hpp.

◆ ld()

template<typename T , int N>
uint32_t sirius::sddk::mdarray< T, N >::ld ( ) const
inline

Return leading dimension size.

Definition at line 1233 of file memory.hpp.

◆ hash()

template<typename T , int N>
uint64_t sirius::sddk::mdarray< T, N >::hash ( uint64_t  h__ = 5381) const
inline

Compute hash of the array.

Example: std::printf("hash(h) : %16llX\n", h.hash());

Definition at line 1242 of file memory.hpp.

◆ checksum_w()

template<typename T , int N>
T sirius::sddk::mdarray< T, N >::checksum_w ( size_t  idx0__,
size_t  size__ 
) const
inline

Compute weighted checksum.

Definition at line 1252 of file memory.hpp.

◆ checksum() [1/2]

template<typename T , int N>
T sirius::sddk::mdarray< T, N >::checksum ( size_t  idx0__,
size_t  size__ 
) const
inline

Compute checksum.

Definition at line 1262 of file memory.hpp.

◆ checksum() [2/2]

template<typename T , int N>
T sirius::sddk::mdarray< T, N >::checksum ( ) const
inline

Definition at line 1271 of file memory.hpp.

◆ begin() [1/2]

template<typename T , int N>
T * sirius::sddk::mdarray< T, N >::begin ( )
inline

Definition at line 1276 of file memory.hpp.

◆ begin() [2/2]

template<typename T , int N>
T const * sirius::sddk::mdarray< T, N >::begin ( ) const
inline

Definition at line 1281 of file memory.hpp.

◆ end() [1/2]

template<typename T , int N>
T * sirius::sddk::mdarray< T, N >::end ( )
inline

Definition at line 1286 of file memory.hpp.

◆ end() [2/2]

template<typename T , int N>
T const * sirius::sddk::mdarray< T, N >::end ( ) const
inline

Definition at line 1291 of file memory.hpp.

◆ zero() [1/2]

template<typename T , int N>
void sirius::sddk::mdarray< T, N >::zero ( memory_t  mem__,
size_t  idx0__,
size_t  n__ 
)
inline

Zero n elements starting from idx0.

Definition at line 1316 of file memory.hpp.

◆ zero() [2/2]

template<typename T , int N>
void sirius::sddk::mdarray< T, N >::zero ( memory_t  mem__ = memory_t::host)
inline

Zero the entire array.

Definition at line 1333 of file memory.hpp.

◆ copy_to() [1/2]

template<typename T , int N>
void sirius::sddk::mdarray< T, N >::copy_to ( memory_t  mem__,
size_t  idx0__,
size_t  n__,
acc::stream_id  sid = acc::stream_id(-1) 
)
inline

Copy n elements starting from idx0 from one memory type to another.

Definition at line 1339 of file memory.hpp.

◆ copy_to() [2/2]

template<typename T , int N>
void sirius::sddk::mdarray< T, N >::copy_to ( memory_t  mem__,
acc::stream_id  sid = acc::stream_id(-1) 
)
inline

Copy entire array from one memory type to another.

Definition at line 1376 of file memory.hpp.

◆ on_device()

template<typename T , int N>
bool sirius::sddk::mdarray< T, N >::on_device ( ) const
inline

Check if device pointer is available.

Definition at line 1382 of file memory.hpp.

◆ label()

template<typename T , int N>
auto sirius::sddk::mdarray< T, N >::label ( ) const
inline

Definition at line 1391 of file memory.hpp.

◆ on_host()

template<typename T , int N>
bool sirius::sddk::mdarray< T, N >::on_host ( ) const
inline

Definition at line 1396 of file memory.hpp.

◆ operator=() [2/4]

template<typename T , int N>
mdarray< T, N > & sirius::sddk::mdarray< T, N >::operator= ( std::function< T(void)>  f__)
inline

Definition at line 1401 of file memory.hpp.

◆ operator=() [3/4]

template<typename T , int N>
mdarray< T, N > & sirius::sddk::mdarray< T, N >::operator= ( std::function< T(index_type)>  f__)
inline

Definition at line 1409 of file memory.hpp.

◆ operator=() [4/4]

template<typename T , int N>
mdarray< T, N > & sirius::sddk::mdarray< T, N >::operator= ( std::function< T(index_type, index_type)>  f__)
inline

Definition at line 1419 of file memory.hpp.

Member Data Documentation

◆ label_

template<typename T , int N>
std::string sirius::sddk::mdarray< T, N >::label_
private

Optional array label.

Definition at line 666 of file memory.hpp.

◆ unique_ptr_

template<typename T , int N>
std::unique_ptr<T, memory_t_deleter_base> sirius::sddk::mdarray< T, N >::unique_ptr_ {nullptr}
private

Unique pointer to the allocated memory.

Definition at line 669 of file memory.hpp.

◆ raw_ptr_

template<typename T , int N>
T* sirius::sddk::mdarray< T, N >::raw_ptr_ {nullptr}
private

Raw pointer.

Definition at line 672 of file memory.hpp.

◆ unique_ptr_device_

template<typename T , int N>
std::unique_ptr<T, memory_t_deleter_base> sirius::sddk::mdarray< T, N >::unique_ptr_device_ {nullptr}
private

Unique pointer to the allocated GPU memory.

Definition at line 675 of file memory.hpp.

◆ raw_ptr_device_

template<typename T , int N>
T* sirius::sddk::mdarray< T, N >::raw_ptr_device_ {nullptr}
private

Raw pointer to GPU memory.

Definition at line 678 of file memory.hpp.

◆ dims_

template<typename T , int N>
std::array<mdarray_index_descriptor, N> sirius::sddk::mdarray< T, N >::dims_
private

Array dimensions.

Definition at line 681 of file memory.hpp.

◆ offsets_

template<typename T , int N>
std::array<index_type, N> sirius::sddk::mdarray< T, N >::offsets_
private

List of offsets to compute the element location by dimension indices.

Definition at line 684 of file memory.hpp.


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