![]() |
alpaka
Abstraction Library for Parallel Kernel Acceleration
|
Implementation of static block shared memory provider. More...
#include <SharedStorage.hpp>
Classes | |
| struct | MetaData |
Public Member Functions | |
| SharedStorage ()=default | |
| template<typename T> | |
| void | alloc (size_t id) const |
| template<typename T> | |
| void | allocDynamic (size_t id, uint32_t numBytes) const |
| template<typename T> | |
| auto | getLatestVarPtr () const -> T * |
| Get last allocated variable. | |
| template<typename T> | |
| auto | getVarPtr (size_t id) const -> T * |
| Give the pointer to an exiting variable. | |
Private Member Functions | |
| uint8_t * | data () const |
| template<typename T> | |
| auto | varChunkEnd (uint32_t byteOffset, uint32_t numBytes) const -> std::uint32_t |
| Byte offset to the end of the memory chunk. | |
Private Attributes | |
| std::uint32_t | m_allocdBytes = 0u |
| Offset in bytes relative to m_mem to next free data area. The last aligned before the free area is always a meta data header. | |
| std::array< uint8_t, totalSharedBytes > | m_data |
| Memory layout |Header|Padding|Variable|Padding|Header|....uninitialized Data .... Size of padding can be zero if data after padding is already aligned. | |
Static Private Attributes | |
| static constexpr std::uint32_t | metaDataSize = sizeof(MetaData) |
| static constexpr std::uint32_t | totalSharedBytes = static_cast<std::uint32_t>( 64u << 10u) |
Implementation of static block shared memory provider.
externally allocated fixed-size memory, likely provided by BlockSharedMemDynMember.
Definition at line 26 of file SharedStorage.hpp.
|
default |
|
inline |
Definition at line 43 of file SharedStorage.hpp.
|
inline |
Definition at line 60 of file SharedStorage.hpp.
|
inlineprivate |
Definition at line 114 of file SharedStorage.hpp.
|
inline |
Get last allocated variable.
Definition at line 108 of file SharedStorage.hpp.
|
inline |
Give the pointer to an exiting variable.
| T | type of the variable |
| id | unique id of the variable |
Definition at line 82 of file SharedStorage.hpp.
|
inlineprivate |
Byte offset to the end of the memory chunk.
Calculate bytes required to store a type with a aligned starting address in m_mem. Start offset to the origin of the user data chunk can be calculated with result - sizeof(T). The padding is always before the origin of the user data chunk and can be zero byte.
| T | type should fit into the chunk |
| byteOffset | Current byte offset. |
| byteOffset | Number of bytes to allocate, should be at least sizeof(T). |
Definition at line 130 of file SharedStorage.hpp.
|
mutableprivate |
Offset in bytes relative to m_mem to next free data area. The last aligned before the free area is always a meta data header.
Definition at line 147 of file SharedStorage.hpp.
|
mutableprivate |
Memory layout |Header|Padding|Variable|Padding|Header|....uninitialized Data .... Size of padding can be zero if data after padding is already aligned.
Definition at line 143 of file SharedStorage.hpp.
|
staticconstexprprivate |
Definition at line 37 of file SharedStorage.hpp.
|
staticconstexprprivate |
Definition at line 138 of file SharedStorage.hpp.