12 #ifndef SST_CORE_CORE_SHAREDREGIONIMPL_H
13 #define SST_CORE_CORE_SHAREDREGIONIMPL_H
15 #include "sst/core/sst_types.h"
16 #include "sst/core/warnmacros.h"
23 #include "sst/core/sharedRegion.h"
24 #include "sst/core/output.h"
25 #include "sst/core/serialization/serializable.h"
29 class SharedRegionImpl;
38 ChangeSet(
size_t offset,
size_t length, uint8_t *data =
nullptr) : offset(offset), length(length), data(data) { }
49 ser & SST::Core::Serialization::array(data,length);
74 if ( length == 0 )
return;
76 ri->setSize(length, initByte);
81 RegionMergeInfo(
int rank,
const std::string& key,
size_t length, uint8_t initByte) :
82 rank(rank), key(key), length(length), initByte(initByte) { }
90 const std::string& getKey()
const {
return key; }
91 size_t getLength()
const {
return length; }
110 BulkMergeInfo(
int rank,
const std::string& key,
void *data,
size_t length, uint8_t initByte) :
117 bool ret = ri->getMerger()->
merge((uint8_t*)ri->getMemory(), (
const uint8_t*)data, length);
123 RegionInfo::RegionMergeInfo::serialize_order(ser);
131 ser & SST::Core::Serialization::array(data,length);
141 std::vector<ChangeSet> changeSets;
145 std::vector<ChangeSet> & changeSets) :
147 changeSets(changeSets)
151 return ri->getMerger()->
merge((uint8_t*)ri->getMemory(), ri->getSize(), changeSets);
155 RegionInfo::RegionMergeInfo::serialize_order(ser);
172 std::vector<SharedRegionImpl*> sharers;
176 std::vector<ChangeSet> changesets;
185 realSize(0), apparentSize(0), memory(nullptr),
186 shareCount(0), publishCount(0), merger(nullptr),
187 didBulk(false), initialized(false), ready(false), initByte(0)
190 bool initialize(
const std::string& key,
size_t size, uint8_t initByte_in,
SharedRegionMerger *mergeObj);
191 bool setSize(
size_t size, uint8_t initByte_in);
192 bool isInitialized()
const {
return initialized; }
193 bool isReady()
const {
return ready; }
195 SharedRegionImpl* addSharer(SharedRegionManager *manager);
196 void removeSharer(SharedRegionImpl *sri);
199 void modifyRegion(
size_t offset,
size_t length,
const void *data);
202 void updateState(
bool finalize);
204 const std::string& getKey()
const {
return myKey; }
205 void* getMemory() { didBulk =
true;
return memory; }
206 const void* getConstPtr()
const {
return memory; }
207 size_t getSize()
const {
return apparentSize; }
208 size_t getNumSharers()
const {
return shareCount; }
210 bool shouldMerge()
const {
return (
nullptr != merger); }
211 SharedRegionMerger* getMerger() {
return merger; }
215 void setProtected(
bool readOnly);
224 size_t getSize() {
return region->getSize(); }
229 published(
false), region(region)
232 bool isPublished()
const {
return published; }
233 void setPublished() { published =
true; }
234 RegionInfo* getRegion()
const {
return region; }
235 void notifySetSize() {
236 if ( deferred_pointer !=
nullptr ) {
237 deferred_pointer->setPointer(getPtr<const void*>());
238 delete deferred_pointer;
239 deferred_pointer =
nullptr;
250 std::vector<int> tgtRanks;
251 std::vector<char> sendBuffer;
254 std::map<std::string, RegionInfo> regions;
258 void modifyRegion(
SharedRegion *sr,
size_t offset,
size_t length,
const void *data)
override;
260 const void* getConstPtr(
const SharedRegion *sr)
const override;
271 virtual bool isRegionReady(
const SharedRegion*)
override;
272 virtual void shutdownSharedRegion(
SharedRegion*)
override;
274 void updateState(
bool finalize)
override;
Definition: sharedRegion.h:135
Definition: sharedRegionImpl.h:246
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:35
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:268
Definition: sharedRegionImpl.h:31
Definition: sharedRegionImpl.h:219
Utility class to define how to merge multiple pieces of shared memory regions Useful in the multi-MPI...
Definition: sharedRegion.h:34
RegionMergeInfo * getMergeInfo()
Returns the size of the data to be transferred.
Definition: sharedRegion.cc:226
Definition: serializable.h:109
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:259
Definition: sharedRegionImpl.h:59
virtual bool merge(uint8_t *target, const uint8_t *newData, size_t size)
Merge the data from 'newData' into 'target'.
Definition: sharedRegionImpl.h:138
Definition: sharedRegionImpl.h:61
Definition: sharedRegion.h:64
Definition: sharedRegionImpl.h:104