SIRIUS 7.5.0
Electronic structure library and applications
|
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... | |
T | checksum_w (size_t idx0__, size_t size__) const |
Compute weighted checksum. More... | |
T | checksum (size_t idx0__, size_t size__) const |
Compute checksum. More... | |
T | 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_base > | unique_ptr_ {nullptr} |
Unique pointer to the allocated memory. More... | |
T * | raw_ptr_ {nullptr} |
Raw pointer. More... | |
std::unique_ptr< T, memory_t_deleter_base > | unique_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... | |
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:
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.
using sirius::sddk::mdarray< T, N >::index_type = mdarray_index_descriptor::index_type |
Definition at line 662 of file memory.hpp.
|
inline |
Default constructor.
Definition at line 785 of file memory.hpp.
|
inline |
Destructor.
Definition at line 790 of file memory.hpp.
|
inline |
N-dimensional array with index bounds.
Definition at line 797 of file memory.hpp.
|
inline |
1D array with memory allocation.
Definition at line 811 of file memory.hpp.
|
inline |
1D array with memory pool allocation.
Definition at line 821 of file memory.hpp.
|
inline |
1D array with host pointer wrapper.
Definition at line 831 of file memory.hpp.
|
inline |
1D array with host and device pointer wrapper.
Definition at line 841 of file memory.hpp.
|
inline |
2D array with memory allocation.
Definition at line 859 of file memory.hpp.
|
inline |
3D array with memory allocation.
Definition at line 870 of file memory.hpp.
|
inline |
4D array with memory allocation.
Definition at line 881 of file memory.hpp.
|
inline |
5D array with memory allocation.
Definition at line 892 of file memory.hpp.
|
inline |
6D array with memory allocation.
Definition at line 904 of file memory.hpp.
|
inline |
Wrap a pointer into 2D array.
Definition at line 916 of file memory.hpp.
|
inline |
Definition at line 925 of file memory.hpp.
|
inline |
2D array with memory pool allocation.
Definition at line 939 of file memory.hpp.
|
inline |
Definition at line 949 of file memory.hpp.
|
inline |
Definition at line 959 of file memory.hpp.
|
inline |
3D array with memory pool allocation.
Definition at line 973 of file memory.hpp.
|
inline |
Definition at line 983 of file memory.hpp.
|
inline |
Definition at line 993 of file memory.hpp.
|
inline |
Definition at line 1004 of file memory.hpp.
|
inline |
Move constructor.
Definition at line 1016 of file memory.hpp.
|
inlineprivate |
Initialize the offsets used to compute the index of the elements.
Definition at line 687 of file memory.hpp.
|
inlineprivate |
Return linear index in the range [0, size) by the N-dimensional indices (i0, i1, ...)
Definition at line 702 of file memory.hpp.
|
inlineprivate |
Return cosnt pointer to an element at a given index.
Definition at line 722 of file memory.hpp.
|
inlineprivate |
Return pointer to an element at a given index.
Definition at line 752 of file memory.hpp.
|
inlineprivate |
Definition at line 758 of file memory.hpp.
|
inlineprivate |
Definition at line 768 of file memory.hpp.
|
inline |
Move assignment operator.
Definition at line 1036 of file memory.hpp.
|
inline |
Allocate memory for array.
Definition at line 1057 of file memory.hpp.
|
inline |
Allocate memory from the pool.
Definition at line 1081 of file memory.hpp.
|
inline |
Deallocate host or device memory.
Definition at line 1104 of file memory.hpp.
|
inline |
Access operator() for the elements of multidimensional array.
Definition at line 1124 of file memory.hpp.
|
inline |
Access operator() for the elements of multidimensional array.
Definition at line 1132 of file memory.hpp.
|
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.
|
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.
|
inline |
Definition at line 1151 of file memory.hpp.
|
inline |
Definition at line 1157 of file memory.hpp.
|
inline |
Return pointer to the beginning of array.
Definition at line 1163 of file memory.hpp.
|
inline |
Return pointer to the beginning of array.
Definition at line 1169 of file memory.hpp.
|
inline |
Definition at line 1174 of file memory.hpp.
|
inline |
Definition at line 1180 of file memory.hpp.
|
inline |
Definition at line 1186 of file memory.hpp.
|
inline |
Definition at line 1196 of file memory.hpp.
|
inline |
Return total size (number of elements) of the array.
Definition at line 1207 of file memory.hpp.
|
inline |
Return size of particular dimension.
Definition at line 1219 of file memory.hpp.
|
inline |
Return a descriptor of a dimension.
Definition at line 1226 of file memory.hpp.
|
inline |
Return leading dimension size.
Definition at line 1233 of file memory.hpp.
|
inline |
Compute hash of the array.
Example: std::printf("hash(h) : %16llX\n", h.hash());
Definition at line 1242 of file memory.hpp.
|
inline |
Compute weighted checksum.
Definition at line 1252 of file memory.hpp.
|
inline |
Compute checksum.
Definition at line 1262 of file memory.hpp.
|
inline |
Definition at line 1271 of file memory.hpp.
|
inline |
Definition at line 1276 of file memory.hpp.
|
inline |
Definition at line 1281 of file memory.hpp.
|
inline |
Definition at line 1286 of file memory.hpp.
|
inline |
Definition at line 1291 of file memory.hpp.
|
inline |
Zero n elements starting from idx0.
Definition at line 1316 of file memory.hpp.
|
inline |
Zero the entire array.
Definition at line 1333 of file memory.hpp.
|
inline |
Copy n elements starting from idx0 from one memory type to another.
Definition at line 1339 of file memory.hpp.
|
inline |
Copy entire array from one memory type to another.
Definition at line 1376 of file memory.hpp.
|
inline |
Check if device pointer is available.
Definition at line 1382 of file memory.hpp.
|
inline |
Definition at line 1391 of file memory.hpp.
|
inline |
Definition at line 1396 of file memory.hpp.
|
inline |
Definition at line 1401 of file memory.hpp.
|
inline |
Definition at line 1409 of file memory.hpp.
|
inline |
Definition at line 1419 of file memory.hpp.
|
private |
Optional array label.
Definition at line 666 of file memory.hpp.
|
private |
Unique pointer to the allocated memory.
Definition at line 669 of file memory.hpp.
|
private |
Raw pointer.
Definition at line 672 of file memory.hpp.
|
private |
Unique pointer to the allocated GPU memory.
Definition at line 675 of file memory.hpp.
|
private |
Raw pointer to GPU memory.
Definition at line 678 of file memory.hpp.
|
private |
Array dimensions.
Definition at line 681 of file memory.hpp.
|
private |
List of offsets to compute the element location by dimension indices.
Definition at line 684 of file memory.hpp.