SIRIUS 7.5.0
Electronic structure library and applications
|
Memory management functions and classes. More...
Go to the source code of this file.
Classes | |
struct | sirius::sddk::is_complex< T > |
Check is the type is a complex number; by default it is not. More... | |
struct | sirius::sddk::is_complex< std::complex< T > > |
Check is the type is a complex number: for std::complex<T> it is true. More... | |
class | sirius::sddk::memory_t_deleter_base |
Base class for smart pointer deleters. More... | |
class | sirius::sddk::memory_t_deleter_base::memory_t_deleter_base_impl |
class | sirius::sddk::memory_t_deleter |
Deleter for the allocated memory pointer of a given type. More... | |
class | sirius::sddk::memory_t_deleter::memory_t_deleter_impl |
class | sirius::sddk::memory_pool_deleter |
Deleter for the allocated memory pointer from a given memory pool. More... | |
class | sirius::sddk::memory_pool_deleter::memory_pool_deleter_impl |
class | sirius::sddk::memory_pool |
class | sirius::sddk::mdarray_index_descriptor |
Index descriptor of mdarray. More... | |
class | sirius::sddk::mdarray< T, N > |
Multidimensional array with the column-major (Fortran) order. More... | |
Namespaces | |
module | sirius |
Namespace of the SIRIUS library. | |
Macros | |
#define | mdarray_assert(condition__) |
Typedefs | |
template<typename T > | |
using | sirius::sddk::matrix = mdarray< T, 2 > |
Enumerations | |
enum class | sirius::sddk::memory_t : unsigned int { none = 0b0000 , host = 0b0001 , host_pinned = 0b0011 , device = 0b1000 , managed = 0b1101 } |
Memory types where the code can store data. More... | |
enum class | sirius::sddk::device_t { CPU = 0 , GPU = 1 } |
Type of the main processing unit. More... | |
Functions | |
bool | sirius::sddk::is_host_memory (memory_t mem__) |
Check if this is a valid host memory (memory, accessible by the host). More... | |
bool | sirius::sddk::is_device_memory (memory_t mem__) |
Check if this is a valid device memory (memory, accessible by the device). More... | |
memory_t | sirius::sddk::get_memory_t (std::string name__) |
Get a memory type from a string. More... | |
device_t | sirius::sddk::get_device_t (memory_t mem__) |
Get type of device by memory type. More... | |
device_t | sirius::sddk::get_device_t (std::string name__) |
Get device type from the string. More... | |
template<typename T > | |
T * | sirius::sddk::allocate (size_t n__, memory_t M__) |
Allocate n elements in a specified memory. More... | |
void | sirius::sddk::deallocate (void *ptr__, memory_t M__) |
Deallocate pointer of a given memory type. More... | |
template<typename T , typename F > | |
void | sirius::sddk::copy (memory_t from_mem__, T const *from_ptr__, memory_t to_mem__, F *to_ptr__, size_t n__) |
Copy between different memory types. More... | |
template<typename T > | |
void | sirius::sddk::copy (memory_t from_mem__, T const *from_ptr__, memory_t to_mem__, T *to_ptr__, size_t n__) |
template<typename T > | |
std::unique_ptr< T, memory_t_deleter_base > | sirius::sddk::get_unique_ptr (size_t n__, memory_t M__) |
Allocate n elements and return a unique pointer. More... | |
sddk::memory_pool & | sirius::sddk::get_memory_pool (sddk::memory_t M__) |
Return a memory pool. More... | |
template<typename T , int N> | |
std::ostream & | sirius::sddk::operator<< (std::ostream &out, mdarray< T, N > const &v) |
Serialize to std::ostream. More... | |
template<typename T , typename F , int N> | |
void | sirius::sddk::copy (mdarray< F, N > const &src__, mdarray< T, N > &dest__) |
Copy content of the array to another array of identical size but different precision. More... | |
template<typename T , int N> | |
void | sirius::sddk::copy (mdarray< T, N > const &src__, mdarray< T, N > &dest__) |
Copy content of the array to another array of identical size. More... | |
template<typename T , int N> | |
void | sirius::sddk::auto_copy (mdarray< T, N > &dst, const mdarray< T, N > &src) |
Copy all memory present on destination. More... | |
template<typename T , int N> | |
void | sirius::sddk::auto_copy (mdarray< T, N > &dst, const mdarray< T, N > &src, device_t device) |
Copy memory specified by device from src to dst. More... | |
template<class numeric_t , std::size_t... Ts> | |
auto | sirius::sddk::_empty_like_inner (std::index_sequence< Ts... > &seq, std::size_t(&dims)[sizeof...(Ts)], memory_pool *mempool) |
template<typename T , int N> | |
auto | sirius::sddk::empty_like (const mdarray< T, N > &src) |
template<typename T , int N> | |
auto | sirius::sddk::empty_like (const mdarray< T, N > &src, memory_pool &mempool) |
Memory management functions and classes.
Definition in file memory.hpp.
#define mdarray_assert | ( | condition__ | ) |
Definition at line 536 of file memory.hpp.
using sirius::sddk::matrix = typedef mdarray<T, 2> |
Definition at line 1434 of file memory.hpp.
|
strong |
Memory types where the code can store data.
All memory types can be divided into two (possibly overlapping) groups: accessible by the CPU and accessible by the device.
Enumerator | |
---|---|
none | Nothing. |
host | Host memory. |
host_pinned | Pinned host memory. This is host memory + extra bit flag. |
device | Device memory. |
managed | Managed memory (accessible from both host and device). |
Definition at line 70 of file memory.hpp.
|
strong |
Type of the main processing unit.
List the processing units on which the code can run.
Enumerator | |
---|---|
CPU | CPU device. |
GPU | GPU device (with CUDA programming model). |
Definition at line 119 of file memory.hpp.
|
inline |
Check if this is a valid host memory (memory, accessible by the host).
Definition at line 86 of file memory.hpp.
|
inline |
Check if this is a valid device memory (memory, accessible by the device).
Definition at line 93 of file memory.hpp.
|
inline |
Get a memory type from a string.
Definition at line 100 of file memory.hpp.
|
inline |
Get type of device by memory type.
Definition at line 130 of file memory.hpp.
|
inline |
Get device type from the string.
Definition at line 149 of file memory.hpp.
|
inline |
Allocate n elements in a specified memory.
Allocate a memory block of the memory_t type. Return a nullptr if this memory is not available, otherwise return a pointer to an allocated block.
Definition at line 167 of file memory.hpp.
|
inline |
Deallocate pointer of a given memory type.
Definition at line 198 of file memory.hpp.
|
inline |
Copy between different memory types.
Definition at line 229 of file memory.hpp.
|
inline |
Definition at line 243 of file memory.hpp.
|
inline |
Allocate n elements and return a unique pointer.
Definition at line 345 of file memory.hpp.
sddk::memory_pool & sirius::sddk::get_memory_pool | ( | sddk::memory_t | M__ | ) |
Return a memory pool.
A memory pool is created when this function called for the first time.
Definition at line 10 of file memory.cpp.
std::ostream & sirius::sddk::operator<< | ( | std::ostream & | out, |
mdarray< T, N > const & | v | ||
) |
Serialize to std::ostream.
Definition at line 1438 of file memory.hpp.
|
inline |
Copy content of the array to another array of identical size but different precision.
Definition at line 1453 of file memory.hpp.
|
inline |
Copy content of the array to another array of identical size.
For example:
Definition at line 1480 of file memory.hpp.
void sirius::sddk::auto_copy | ( | mdarray< T, N > & | dst, |
const mdarray< T, N > & | src | ||
) |
Copy all memory present on destination.
Definition at line 1498 of file memory.hpp.
void sirius::sddk::auto_copy | ( | mdarray< T, N > & | dst, |
const mdarray< T, N > & | src, | ||
device_t | device | ||
) |
Copy memory specified by device from src to dst.
Definition at line 1516 of file memory.hpp.
auto sirius::sddk::_empty_like_inner | ( | std::index_sequence< Ts... > & | seq, |
std::size_t(&) | dims[sizeof...(Ts)], | ||
memory_pool * | mempool | ||
) |
Definition at line 1536 of file memory.hpp.
auto sirius::sddk::empty_like | ( | const mdarray< T, N > & | src | ) |
Definition at line 1550 of file memory.hpp.
auto sirius::sddk::empty_like | ( | const mdarray< T, N > & | src, |
memory_pool & | mempool | ||
) |
Definition at line 1562 of file memory.hpp.