|
FEAT 3
Finite Element Analysis Toolbox
|
Memory namespace containing functions and classes related to memory management. More...
Classes | |
| class | AccessException |
| Memory access exception. More... | |
| class | AllocException |
| Memory allocation exception. More... | |
| class | Arbiter |
| Memory arbiter class. More... | |
| class | Block |
| Memory Arbiter memory block class. More... | |
| class | Manager |
| Memory management interface class. More... | |
| class | MemoryException |
| Memory related exception base class. More... | |
| class | RangeException |
| Memory range exception. More... | |
| class | TypedView |
| Typed memory view class. More... | |
| class | View |
| Raw memory view class. More... | |
Enumerations | |
| enum class | Access : std::uint32_t { none = 0 , read = 0x1 , write = 0x2 , read_write = 0x3 , overlap = 0x4 } |
| Memory access enumeration. More... | |
| enum class | Init : std::uint32_t { dont_care = 0 , uninitialized = 1 , format_to_zero = 2 , format_to_one = 3 } |
| Memory initialization enumeration. More... | |
| enum class | Location : std::uint32_t { none = 0 , main = 0x0001 , cuda = 0x0002 } |
| Memory location enumeration. More... | |
Functions | |
| void * | alloc_cuda (std::size_t bytes) |
| Allocate a memory block in cuda heap memory. More... | |
| void * | alloc_cuda_async (std::size_t bytes, const Util::StreamWrapper &stream=Util::StreamWrapper{}) |
| Allocates stream ordered memory block in cuda heap memory. More... | |
| void * | alloc_main (std::size_t bytes) |
| Allocate a memory block in main heap memory. More... | |
| template<typename T_ > | |
| void | convert_cuda (T_ *dst, const T_ *src, const Index count) |
| overload for Tdst_ = Tsrc_; performs a memcopy internally More... | |
| template<typename Tdst_ , typename Tsrc_ > | |
| void | convert_cuda (Tdst_ *dst, const Tsrc_ *src, const Index count) |
| Converts the elements of an array into element of another array of a different data type. More... | |
| template<typename T_ > | |
| void | convert_main (T_ *dst, const T_ *src, const Index count) |
| overload for Tdst_ = Tsrc_; performs a memcopy internally More... | |
| template<typename Tdst_ , typename Tsrc_ > | |
| void | convert_main (Tdst_ *dst, const Tsrc_ *src, const Index count) |
| Converts the elements of an array into element of another array of a different data type. More... | |
| template<typename T_ > | |
| void | format_cuda (T_ *dst, const T_ &value, const Index count) |
| Sets all entries of a cuda memory array to a given value. More... | |
| template<typename T_ > | |
| void | format_main (T_ *dst, const T_ &value, const Index count) |
| Sets all entries of a main memory array to a given value. More... | |
| void | free_cuda (void *ptr) |
| Frees a memory block in cuda heap memory allocated by alloc_cuda. More... | |
| void | free_cuda_async (void *ptr, const Util::StreamWrapper &stream=Util::StreamWrapper{}) |
| Frees a memory block in cuda heap memory allocated by alloc_cuda. More... | |
| void | free_main (void *ptr) |
| Frees a memory block in main heap memory allocated by alloc_main. More... | |
| void | memcopy_cuda (void *dst, const void *src, std::size_t bytes, const Util::StreamWrapper &stream=Util::StreamWrapper{}) |
| Copies a region of a cuda memory block into another cuda memory block. More... | |
| void | memcopy_cuda_to_main (void *dst, const void *src, std::size_t bytes) |
| Copies a region of a cuda memory block into a main memory block. More... | |
| void | memcopy_main (void *dst, const void *src, std::size_t bytes) |
| Copies a region of a main memory block into another main memory block. More... | |
| void | memcopy_main_to_cuda (void *dst, const void *src, std::size_t bytes, const Util::StreamWrapper &stream=Util::StreamWrapper{}) |
| Copies a region of a main memory block into a cuda memory block. More... | |
| void | memset_cuda (void *ptr, int value, std::size_t bytes, const Util::StreamWrapper &stream=Util::StreamWrapper{}) |
| Formats all bytes of a memory block in cuda memory to a given value. More... | |
| void | memset_main (void *ptr, int value, std::size_t bytes) |
| Formats all bytes of a memory block in main memory to a given value. More... | |
| void | memset_random_main (void *ptr, std::size_t bytes, std::uint64_t seed=0u) |
| Formats all bytes of a memory block in main memory to random values. More... | |
Memory namespace containing functions and classes related to memory management.
|
strong |
Memory access enumeration.
This enum is used by the Memory::Arbiter class and its related classes to specify the access rights requested/granted to a view of a memory block.
See Memory Access Rights for more details.
| Enumerator | |
|---|---|
| none | no access |
| read | read-only access |
| write | write-only access (see attention note above) |
| read_write | read-write access |
| overlap | explicitly allow overlapping writes (see Overlapping Memory Views) |
Definition at line 97 of file memory_arbiter.hpp.
|
strong |
Memory initialization enumeration.
This enum is used by the Memory::Arbiter class and its related classes to specify how newly allocated memory arrays are to be initialized.
See Allocation and Initialization for more information.
| Enumerator | |
|---|---|
| dont_care | don't care |
| uninitialized | leave memory uninitialized |
| format_to_zero | allocate and format all bits to zero |
| format_to_one | allocate and format all bits to one |
Definition at line 137 of file memory_arbiter.hpp.
|
strong |
Memory location enumeration.
This enum is used by the Memory::Arbiter class and its related classes to specify the locations of a memory block and views that are mapped to it.
See Memory Locations for more information.
| Enumerator | |
|---|---|
| none | no or unknown or unspecified location |
| main | main memory |
| cuda | cuda memory |
Definition at line 37 of file memory_arbiter.hpp.
| void * FEAT::Memory::alloc_cuda | ( | std::size_t | bytes | ) |
Allocate a memory block in cuda heap memory.
This is effectively a wrapper around ::cudaMalloc.
| [in] | bytes | The size of the memory block in bytes. |
nullptr, if the memory allocation failed. | void * FEAT::Memory::alloc_cuda_async | ( | std::size_t | bytes, |
| const Util::StreamWrapper & | stream = Util::StreamWrapper{} |
||
| ) |
Allocates stream ordered memory block in cuda heap memory.
This is effectively a wrapper around ::cudaMallocAsync. Note, async capabilities are not available on all devices, so this falls back to standard cudaMalloc if its not available. You can query the availability with the Util function cuda_get_async...
| [in] | bytes | The size of the memory block in bytes. |
nullptr, if the memory allocation failed. | void * FEAT::Memory::alloc_main | ( | std::size_t | bytes | ) |
Allocate a memory block in main heap memory.
This is effectively a wrapper around ::malloc.
| [in] | bytes | The size of the memory block in bytes. |
nullptr, if the memory allocation failed. Definition at line 19 of file memory_aux_main.cpp.
|
inline |
overload for Tdst_ = Tsrc_; performs a memcopy internally
Definition at line 320 of file memory_aux.hpp.
References memcopy_cuda().
| void FEAT::Memory::convert_cuda | ( | Tdst_ * | dst, |
| const Tsrc_ * | src, | ||
| const Index | count | ||
| ) |
Converts the elements of an array into element of another array of a different data type.
| Tdst_ | Specifies the underlying type of the destination array. |
| Tsrc_ | Specifies the underlying type of the source array; must be convertible to Tdst_. |
| [in,out] | dst | A device pointer to the cuda memory block that receives the converted elements; must not be nullptr if count > 0. |
| [in] | src | A device pointer to the cuda memory block that contains the source array; must not be nullptr if count > 0. |
| [in] | count | The number of arrays to be converted from *src to *dst |
Referenced by FEAT::Memory::TypedView< T_ >::convert_from().
|
inline |
overload for Tdst_ = Tsrc_; performs a memcopy internally
Definition at line 99 of file memory_aux.hpp.
References memcopy_main().
Referenced by FEAT::Memory::TypedView< T_ >::convert_from().
|
inline |
Converts the elements of an array into element of another array of a different data type.
| [in,out] | dst | A pointer to the main memory block that receives the converted elements; must not be nullptr if count > 0. |
| [in] | src | A pointer to the main memory block that contains the source array; must not be nullptr if count > 0. |
| [in] | count | The number of arrays to be converted from *src to *dst |
Definition at line 121 of file memory_aux.hpp.
| void FEAT::Memory::format_cuda | ( | T_ * | dst, |
| const T_ & | value, | ||
| const Index | count | ||
| ) |
Sets all entries of a cuda memory array to a given value.
| [out] | dst | A transient pointer to the cuda memory array whose elements are to be formatted |
| [in] | value | A transient reference to the value that is to be copied to the array elements |
| [in] | count | The number of elements in the array dst |
Referenced by FEAT::Memory::TypedView< T_ >::format().
|
inline |
Sets all entries of a main memory array to a given value.
| [out] | dst | A transient pointer to the main memory array whose elements are to be formatted |
| [in] | value | A transient reference to the value that is to be copied to the array elements |
| [in] | count | The number of elements in the array dst |
Definition at line 154 of file memory_aux.hpp.
References FEAT::value, and XASSERT.
Referenced by FEAT::Memory::TypedView< T_ >::format().
| void FEAT::Memory::free_cuda | ( | void * | ptr | ) |
Frees a memory block in cuda heap memory allocated by alloc_cuda.
This is effectively a wrapper around ::cudaFree.
| [in] | ptr | A pointer to the cuda memory block that is to be freed; must not be nullptr. |
| void FEAT::Memory::free_cuda_async | ( | void * | ptr, |
| const Util::StreamWrapper & | stream = Util::StreamWrapper{} |
||
| ) |
Frees a memory block in cuda heap memory allocated by alloc_cuda.
This is effectively a wrapper around ::cudaFree.
| [in] | ptr | A pointer to the cuda memory block that is to be freed; must not be nullptr. |
| void FEAT::Memory::free_main | ( | void * | ptr | ) |
Frees a memory block in main heap memory allocated by alloc_main.
This is effectively a wrapper around ::free.
| [in] | ptr | A pointer to the main memory block that is to be freed; must not be nullptr. |
Definition at line 26 of file memory_aux_main.cpp.
| void FEAT::Memory::memcopy_cuda | ( | void * | dst, |
| const void * | src, | ||
| std::size_t | bytes, | ||
| const Util::StreamWrapper & | stream = Util::StreamWrapper{} |
||
| ) |
Copies a region of a cuda memory block into another cuda memory block.
This is effectively a wrapper around ::cudaMemcpy for cudaMemcpyDeviceToDevice.
| [in,out] | dst | A device pointer to the cuda memory block that receives the copy; must not be nullptr if bytes > 0. |
| [in] | src | A device pointer to the cuda memory block that acts as the source for the copy; must not be nullptr if bytes > 0. |
| [in] | bytes | The number of bytes to be copied from *src to *dst |
Referenced by convert_cuda(), and FEAT::Memory::View::copy_raw_from().
| void FEAT::Memory::memcopy_cuda_to_main | ( | void * | dst, |
| const void * | src, | ||
| std::size_t | bytes | ||
| ) |
Copies a region of a cuda memory block into a main memory block.
This is effectively a wrapper around ::cudaMemcpy for cudaMemcpyDeviceToHost.
| [in,out] | dst | A host pointer to the main memory block that receives the copy; must not be nullptr if bytes > 0. |
| [in] | src | A device pointer to the cuda memory block that acts as the source for the copy; must not be nullptr if bytes > 0. |
| [in] | bytes | The number of bytes to be copied from *src to *dst |
Referenced by FEAT::Memory::View::copy_raw_from().
| void FEAT::Memory::memcopy_main | ( | void * | dst, |
| const void * | src, | ||
| std::size_t | bytes | ||
| ) |
Copies a region of a main memory block into another main memory block.
This is effectively a wrapper around ::memcpy.
| [in,out] | dst | A pointer to the main memory block that receives the copy; must not be nullptr if bytes > 0. |
| [in] | src | A pointer to the main memory block that acts as the source for the copy; must not be nullptr if bytes > 0. |
| [in] | bytes | The number of bytes to be copied from *src to *dst |
Definition at line 71 of file memory_aux_main.cpp.
References XASSERT, and XASSERTM.
Referenced by FEAT::Solver::VoxelAmaVanka< Matrix_, Filter_, pol_threading_, macro_type_ >::_alloc_device(), FEAT::LAFEM::Container< DT_, IT_ >::_serialize(), convert_main(), FEAT::Memory::View::copy_raw_from(), FEAT::LAFEM::Arch::TransposeDense::exec_generic_impl(), FEAT::Adjacency::ColoringDataHandler::fill_color(), FEAT::LAFEM::SparseMatrixBCSR< DT_, IT_, block_height_, block_width_ >::permute(), and FEAT::LAFEM::SparseMatrixCSR< DT_, IT_ >::permute().
| void FEAT::Memory::memcopy_main_to_cuda | ( | void * | dst, |
| const void * | src, | ||
| std::size_t | bytes, | ||
| const Util::StreamWrapper & | stream = Util::StreamWrapper{} |
||
| ) |
Copies a region of a main memory block into a cuda memory block.
This is effectively a wrapper around ::cudaMemcpy for cudaMemcpyHostToDevice.
| [in,out] | dst | A device pointer to the cuda memory block that receives the copy; must not be nullptr if bytes > 0. |
| [in] | src | A host pointer to the main memory block that acts as the source for the copy; must not be nullptr if bytes > 0. |
| [in] | bytes | The number of bytes to be copied from *src to *dst |
Referenced by FEAT::Memory::View::copy_raw_from().
| void FEAT::Memory::memset_cuda | ( | void * | ptr, |
| int | value, | ||
| std::size_t | bytes, | ||
| const Util::StreamWrapper & | stream = Util::StreamWrapper{} |
||
| ) |
Formats all bytes of a memory block in cuda memory to a given value.
This is effectively a wrapper around ::cudaMemset.
| [in,out] | ptr | A device pointer to the cuda memory block that is to be formatted; must not be nullptr if bytes > 0. |
| [in] | value | The value that all bytes are to be set to. Set this to 0 to format all bits to 0 and set it to 0xFF (= 255) to format all bits to 1. |
| [in] | bytes | The size of the memory block in bytes. |
Referenced by FEAT::Memory::View::format_to_one(), and FEAT::Memory::View::format_to_zero().
| void FEAT::Memory::memset_main | ( | void * | ptr, |
| int | value, | ||
| std::size_t | bytes | ||
| ) |
Formats all bytes of a memory block in main memory to a given value.
This is effectively a wrapper around ::memset.
| [in,out] | ptr | A pointer to the main memory block that is to be formatted; must not be nullptr if bytes > 0. |
| [in] | value | The value that all bytes are to be set to. Set this to 0 to format all bits to 0 and set it to 0xFF (= 255) to format all bits to 1. |
| [in] | bytes | The size of the memory block in bytes. |
Definition at line 32 of file memory_aux_main.cpp.
References FEAT::value, and XASSERT.
Referenced by FEAT::Solver::VoxelAmaVanka< Matrix_, Filter_, pol_threading_, macro_type_ >::_alloc_device(), FEAT::Solver::Vanka< LAFEM::SaddlePointMatrix< MatrixA_, MatrixB_, MatrixD_ >, Filter_ >::_factor_diag(), FEAT::Solver::Vanka< LAFEM::SaddlePointMatrix< MatrixA_, MatrixB_, MatrixD_ >, Filter_ >::_factor_full(), FEAT::Memory::View::format_to_one(), FEAT::Memory::View::format_to_zero(), and FEAT::Global::AlgDofPartiSystem< LocalMatrix_, LocalFilter_, Mirror_ >::upload_matrix_numeric().
| void FEAT::Memory::memset_random_main | ( | void * | ptr, |
| std::size_t | bytes, | ||
| std::uint64_t | seed = 0u |
||
| ) |
Formats all bytes of a memory block in main memory to random values.
| [in,out] | ptr | A pointer to the main memory block that is to be formatted; must not be nullptr if bytes > 0. |
| [in] | bytes | The size of the memory block in bytes. |
| [in] | seed | The seed for the RNG. If set to zero, then the address stored in ptr is used as the seed. |
Definition at line 42 of file memory_aux_main.cpp.
References FEAT::Random::next(), and XASSERT.