12 #ifndef SST_CORE_CORE_SHAREDREGIONIMPL_H
13 #define SST_CORE_CORE_SHAREDREGIONIMPL_H
15 #include "sst/core/output.h"
16 #include "sst/core/serialization/serializable.h"
17 #include "sst/core/sharedRegion.h"
18 #include "sst/core/sst_types.h"
19 #include "sst/core/warnmacros.h"
28 class SharedRegionImpl;
38 ChangeSet(
size_t offset,
size_t length, uint8_t* data =
nullptr) :
54 ser& SST::Core::Serialization::array(data, length);
79 if ( length == 0 )
return;
81 ri->setSize(length, initByte);
86 RegionMergeInfo(
int rank,
const std::string& key,
size_t length, uint8_t initByte) :
99 const std::string& getKey()
const {
return key; }
100 size_t getLength()
const {
return length; }
120 BulkMergeInfo(
int rank,
const std::string& key,
void* data,
size_t length, uint8_t initByte) :
128 bool ret = ri->getMerger()->
merge((uint8_t*)ri->getMemory(), (
const uint8_t*)data, length);
135 RegionInfo::RegionMergeInfo::serialize_order(ser);
143 ser& SST::Core::Serialization::array(data, length);
154 std::vector<ChangeSet> changeSets;
159 int rank,
const std::string& key,
size_t length, uint8_t initByte, std::vector<ChangeSet>& changeSets) :
161 changeSets(changeSets)
166 return ri->getMerger()->
merge((uint8_t*)ri->getMemory(), ri->getSize(), changeSets);
171 RegionInfo::RegionMergeInfo::serialize_order(ser);
187 std::vector<SharedRegionImpl*> sharers;
191 std::vector<ChangeSet> changesets;
212 bool initialize(
const std::string& key,
size_t size, uint8_t initByte_in,
SharedRegionMerger* mergeObj);
213 bool setSize(
size_t size, uint8_t initByte_in);
214 bool isInitialized()
const {
return initialized; }
215 bool isReady()
const {
return ready; }
217 SharedRegionImpl* addSharer(SharedRegionManager* manager);
218 void removeSharer(SharedRegionImpl* sri);
220 void modifyRegion(
size_t offset,
size_t length,
const void* data);
223 void updateState(
bool finalize);
225 const std::string& getKey()
const {
return myKey; }
231 const void* getConstPtr()
const {
return memory; }
232 size_t getSize()
const {
return apparentSize; }
233 size_t getNumSharers()
const {
return shareCount; }
235 bool shouldMerge()
const {
return (
nullptr != merger); }
236 SharedRegionMerger* getMerger() {
return merger; }
240 void setProtected(
bool readOnly);
249 size_t getSize() {
return region->getSize(); }
258 bool isPublished()
const {
return published; }
259 void setPublished() { published =
true; }
260 RegionInfo* getRegion()
const {
return region; }
263 if ( deferred_pointer !=
nullptr ) {
264 deferred_pointer->setPointer(getPtr<const void*>());
265 delete deferred_pointer;
266 deferred_pointer =
nullptr;
277 std::vector<int> tgtRanks;
278 std::vector<char> sendBuffer;
281 std::map<std::string, RegionInfo> regions;
285 void modifyRegion(
SharedRegion* sr,
size_t offset,
size_t length,
const void* data)
override;
287 const void* getConstPtr(
const SharedRegion* sr)
const override;
296 const std::string& key,
size_t size,
SharedRegionMerger* merger =
nullptr, uint8_t initByte = 0)
override;
299 virtual bool isRegionReady(
const SharedRegion*)
override;
300 virtual void shutdownSharedRegion(
SharedRegion*)
override;
302 void updateState(
bool finalize)
override;
307 #endif // SST_CORE_CORE_SHAREDREGIONIMPL_H
Definition: sharedRegion.h:133
Definition: sharedRegionImpl.h:271
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:34
virtual SharedRegion * getGlobalSharedRegion(const std::string &key, size_t size, SharedRegionMerger *merger=nullptr, uint8_t initByte=0) override
Create a SharedRegion that will be shared with elements on the all ranks.
Definition: sharedRegion.cc:265
Definition: sharedRegionImpl.h:30
Definition: sharedRegionImpl.h:243
Utility class to define how to merge multiple pieces of shared memory regions Useful in the multi-MPI...
Definition: sharedRegion.h:35
RegionMergeInfo * getMergeInfo()
Returns the size of the data to be transferred.
Definition: sharedRegion.cc:230
Definition: serializable.h:118
virtual SharedRegion * getLocalSharedRegion(const std::string &key, size_t size, uint8_t initByte=0) override
Create a SharedRegion that will only be shared with elements on the current rank. ...
Definition: sharedRegion.cc:254
Definition: sharedRegionImpl.h:61
virtual bool merge(uint8_t *target, const uint8_t *newData, size_t size)
Merge the data from 'newData' into 'target'.
Definition: sharedRegionImpl.h:150
Definition: sharedRegionImpl.h:64
Definition: sharedRegion.h:63
Definition: sharedRegionImpl.h:113