alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
alpaka::onAcc::cpu::detail::SharedStorage< TMinDataAlignBytes > Class Template Reference

Implementation of static block shared memory provider. More...

#include <SharedStorage.hpp>

Classes

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, totalSharedBytesm_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)

Detailed Description

template<std::size_t TMinDataAlignBytes>
class alpaka::onAcc::cpu::detail::SharedStorage< TMinDataAlignBytes >

Implementation of static block shared memory provider.

externally allocated fixed-size memory, likely provided by BlockSharedMemDynMember.

Definition at line 26 of file SharedStorage.hpp.

Constructor & Destructor Documentation

◆ SharedStorage()

template<std::size_t TMinDataAlignBytes>
alpaka::onAcc::cpu::detail::SharedStorage< TMinDataAlignBytes >::SharedStorage ( )
default

Member Function Documentation

◆ alloc()

template<std::size_t TMinDataAlignBytes>
template<typename T>
void alpaka::onAcc::cpu::detail::SharedStorage< TMinDataAlignBytes >::alloc ( size_t id) const
inline

Definition at line 43 of file SharedStorage.hpp.

◆ allocDynamic()

template<std::size_t TMinDataAlignBytes>
template<typename T>
void alpaka::onAcc::cpu::detail::SharedStorage< TMinDataAlignBytes >::allocDynamic ( size_t id,
uint32_t numBytes ) const
inline

Definition at line 60 of file SharedStorage.hpp.

◆ data()

template<std::size_t TMinDataAlignBytes>
uint8_t * alpaka::onAcc::cpu::detail::SharedStorage< TMinDataAlignBytes >::data ( ) const
inlineprivate

Definition at line 114 of file SharedStorage.hpp.

◆ getLatestVarPtr()

template<std::size_t TMinDataAlignBytes>
template<typename T>
auto alpaka::onAcc::cpu::detail::SharedStorage< TMinDataAlignBytes >::getLatestVarPtr ( ) const -> T *
inline

Get last allocated variable.

Definition at line 108 of file SharedStorage.hpp.

◆ getVarPtr()

template<std::size_t TMinDataAlignBytes>
template<typename T>
auto alpaka::onAcc::cpu::detail::SharedStorage< TMinDataAlignBytes >::getVarPtr ( size_t id) const -> T *
inline

Give the pointer to an exiting variable.

Template Parameters
Ttype of the variable
Parameters
idunique id of the variable
Returns
nullptr if variable with id not exists

Definition at line 82 of file SharedStorage.hpp.

◆ varChunkEnd()

template<std::size_t TMinDataAlignBytes>
template<typename T>
auto alpaka::onAcc::cpu::detail::SharedStorage< TMinDataAlignBytes >::varChunkEnd ( uint32_t byteOffset,
uint32_t numBytes ) const -> std::uint32_t
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.

Template Parameters
Ttype should fit into the chunk
Parameters
byteOffsetCurrent byte offset.
byteOffsetNumber of bytes to allocate, should be at least sizeof(T).
Returns
Byte offset to the end of the data chunk, relative to m_mem..

Definition at line 130 of file SharedStorage.hpp.

Member Data Documentation

◆ m_allocdBytes

template<std::size_t TMinDataAlignBytes>
std::uint32_t alpaka::onAcc::cpu::detail::SharedStorage< TMinDataAlignBytes >::m_allocdBytes = 0u
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.

◆ m_data

template<std::size_t TMinDataAlignBytes>
std::array<uint8_t, totalSharedBytes> alpaka::onAcc::cpu::detail::SharedStorage< TMinDataAlignBytes >::m_data
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.

◆ metaDataSize

template<std::size_t TMinDataAlignBytes>
std::uint32_t alpaka::onAcc::cpu::detail::SharedStorage< TMinDataAlignBytes >::metaDataSize = sizeof(MetaData)
staticconstexprprivate

Definition at line 37 of file SharedStorage.hpp.

◆ totalSharedBytes

template<std::size_t TMinDataAlignBytes>
std::uint32_t alpaka::onAcc::cpu::detail::SharedStorage< TMinDataAlignBytes >::totalSharedBytes = static_cast<std::uint32_t>( 64u << 10u)
staticconstexprprivate

Definition at line 138 of file SharedStorage.hpp.


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