Memory
class Memory
The Memory class is an internal utility for InputChannel and OutputChannel to provide static shared memory.
Types
| Name | Description |
|---|---|
| MetaData | @brief The MetaData class is s class for transporting meta data related to data tokens on pipelined processing interfaces. |
Functions
| Name | Description |
|---|---|
| read | Read the contents of a single Hash out of the cache. |
| read | Read the contents of a single Hash out of the cache. |
| write | Write the contents of a single Hash into the cache. |
| assureAllDataIsCopied | Ensure that the data of given chunk is not shared with anyone else, i.e. copy data if needed. channelIdx : chunkIdx : |
| getMetaData | Return a vector of MetaData objects for the data tokens in the bucket identified by channelIdx and chunkIdx. |
Function Details
assureAllDataIsCopied
static void assureAllDataIsCopied(const size_t channelIdx, const size_t chunkIdx)
Ensure that the data of given chunk is not shared with anyone else, i.e. copy data if needed.
channelIdx
:
chunkIdx
:
getMetaData
static const std::vector<Memory::MetaData>& getMetaData(const size_t channelIdx, const size_t chunkIdx)
Return a vector of MetaData objects for the data tokens in the bucket identified by channelIdx and chunkIdx.
channelIdx
:
chunkIdx
:
Return :
read
static void read(karabo::data::Hash& data, const size_t dataIdx, const size_t channelIdx, const size_t chunkIdx)
Read the contents of a single Hash out of the cache. The passed in Hash will be cleared first.
data
:
dataIdx
:
channelIdx
:
chunkIdx
:
static DataPointer read(const size_t dataIdx, const size_t channelIdx, const size_t chunkIdx)
Read the contents of a single Hash out of the cache. A pointer tag_of a newly created Hash will be returned.
dataIdx
:
channelIdx
:
chunkIdx
:
write
static void write(const karabo::data::Hash& data, const size_t channelIdx, const size_t chunkIdx, const MetaData& metaData, bool copyAllData = true)
Write the contents of a single Hash into the cache. The Hash will be serialized before control is returned to the caller. Note that the data of an NDArray inside the Hash will not be copied, i.e. the Memory internal buffer will point to the same memory as the NDArray, except if copyAllData = true. it is safe to mutate the Hash after writing it.
data
: input
channelIdx
: where to store the serialised data
chunkIdx
: where to store the serialised data
metaData
: of the data
copyAllData
: defines whether all data (incl. NDArray data) is copied into the internal buffer
(default: true)