14 #ifndef SST_CORE_CONFIGGRAPH_H 15 #define SST_CORE_CONFIGGRAPH_H 17 #include "sst/core/params.h" 18 #include "sst/core/rankInfo.h" 19 #include "sst/core/serialization/serializable.h" 20 #include "sst/core/sparseVectorMap.h" 21 #include "sst/core/sst_types.h" 22 #include "sst/core/statapi/statbase.h" 23 #include "sst/core/statapi/statoutput.h" 24 #include "sst/core/unitAlgebra.h" 35 class Simulation_impl;
41 typedef SparseVectorMap<ComponentId_t> ComponentIdMap_t;
42 typedef std::vector<LinkId_t> LinkIdMap_t;
50 ComponentId_t component[2];
53 std::string latency_str[2];
60 inline LinkId_t key()
const {
return id; }
65 if ( latency[0] < latency[1] )
return latency[0];
70 void print(std::ostream& os)
const 72 os <<
"Link " << name <<
" (id = " <<
id <<
")" << std::endl;
73 os <<
" component[0] = " << component[0] << std::endl;
74 os <<
" port[0] = " << port[0] << std::endl;
75 os <<
" latency[0] = " << latency[0] << std::endl;
76 os <<
" component[1] = " << component[1] << std::endl;
77 os <<
" port[1] = " << port[1] << std::endl;
78 os <<
" latency[1] = " << latency[1] << std::endl;
102 friend class ConfigGraph;
103 ConfigLink(LinkId_t
id) : id(id), no_cut(false)
108 component[0] = ULONG_MAX;
109 component[1] = ULONG_MAX;
112 ConfigLink(LinkId_t
id,
const std::string& n) : id(id), no_cut(false)
118 component[0] = ULONG_MAX;
119 component[1] = ULONG_MAX;
122 void updateLatencies(TimeLord*);
133 ConfigStatistic(StatisticId_t _id,
bool _shared =
false, std::string _name =
"") :
141 inline const StatisticId_t& getId()
const {
return id; }
143 void addParameter(
const std::string& key,
const std::string& value,
bool overwrite);
153 ImplementSerializable(ConfigStatistic)
155 static constexpr StatisticId_t stat_null_id = std::numeric_limits<StatisticId_t>::max();
162 std::map<std::string, Params> statMap;
163 std::vector<ComponentId_t> components;
170 bool addComponent(ComponentId_t
id);
171 bool addStatistic(
const std::string& name,
Params& p);
172 bool setOutput(
size_t id);
173 bool setFrequency(
const std::string& freq);
180 std::pair<bool, std::string> verifyStatsAndComponents(
const ConfigGraph* graph);
188 ser& outputFrequency;
203 void addParameter(
const std::string& key,
const std::string& val) { params.
insert(key, val); }
234 std::map<std::string, StatisticId_t> enabledStatNames;
235 bool enabledAllStats;
239 std::vector<double> coords;
244 static constexpr ComponentId_t null_id = std::numeric_limits<ComponentId_t>::max();
246 inline const ComponentId_t& key()
const {
return id; }
249 void print(std::ostream& os)
const;
253 void setConfigGraphPointer(
ConfigGraph* graph_ptr);
258 statLoadLevel(STATISTICLOADLEVELUNINITIALIZED),
259 enabledAllStats(false),
264 StatisticId_t getNextStatisticID();
266 ConfigComponent* getParent()
const;
267 std::string getFullName()
const;
269 void setRank(RankInfo r);
270 void setWeight(
double w);
271 void setCoordinates(
const std::vector<double>& c);
272 void addParameter(
const std::string& key,
const std::string& value,
bool overwrite);
273 ConfigComponent* addSubComponent(
const std::string& name,
const std::string& type,
int slot);
274 ConfigComponent* findSubComponent(ComponentId_t);
275 const ConfigComponent* findSubComponent(ComponentId_t)
const;
276 ConfigComponent* findSubComponentByName(
const std::string& name);
277 ConfigStatistic* findStatistic(
const std::string& name)
const;
278 ConfigStatistic* insertStatistic(StatisticId_t
id);
279 ConfigStatistic* findStatistic(StatisticId_t)
const;
281 enableStatistic(
const std::string& statisticName,
const SST::Params& params,
bool recursively =
false);
282 ConfigStatistic* createStatistic();
283 bool reuseStatistic(
const std::string& statisticName, StatisticId_t sid);
284 void addStatisticParameter(
285 const std::string& statisticName,
const std::string& param,
const std::string& value,
bool recursively =
false);
286 void setStatisticParameters(
const std::string& statisticName,
const Params& params,
bool recursively =
false);
287 void setStatisticLoadLevel(uint8_t level,
bool recursively =
false);
289 void addGlobalParamSet(
const std::string&
set) { params.
addGlobalParamSet(
set); }
290 std::vector<std::string> getParamsLocalKeys()
const {
return params.
getLocalKeys(); }
294 std::vector<LinkId_t> allLinks()
const;
298 std::vector<LinkId_t> clearAllLinks();
311 ser& enabledStatNames;
312 ser& enabledAllStats;
314 ser& enabledAllStats;
326 std::map<StatisticId_t, ConfigStatistic> statistics;
328 ComponentId_t getNextSubComponentID();
330 friend class ConfigGraph;
333 void checkPorts()
const;
337 ComponentId_t
id,
ConfigGraph* graph,
const std::string& name,
const std::string& type,
float weight,
345 statLoadLevel(STATISTICLOADLEVELUNINITIALIZED),
346 enabledAllStats(false),
350 coords.resize(3, 0.0);
354 ComponentId_t
id,
ConfigGraph* graph, uint16_t parent_subid,
const std::string& name,
int slot_num,
355 const std::string& type,
float weight,
RankInfo rank) :
363 statLoadLevel(STATISTICLOADLEVELUNINITIALIZED),
364 enabledAllStats(false),
365 nextSubID(parent_subid),
366 nextStatID(parent_subid)
368 coords.resize(3, 0.0);
376 typedef SparseVectorMap<ComponentId_t, ConfigComponent*> ConfigComponentMap_t;
378 typedef std::map<std::string, ComponentId_t> ConfigComponentNameMap_t;
380 typedef std::map<std::string, Params*> ParamsMap_t;
382 typedef std::map<std::string, std::string> VariableMap_t;
384 class PartitionGraph;
395 os <<
"Printing graph" << std::endl;
396 for ( ConfigComponentMap_t::const_iterator i = comps.begin(); i != comps.end(); ++i ) {
406 statLoadLevel = STATISTICSDEFAULTLOADLEVEL;
407 statOutputs.emplace_back(STATISTICSDEFAULTOUTPUTNAME);
409 Output& o = Output::getDefaultObject();
413 size_t getNumComponents() {
return comps.data.size(); }
415 size_t getNumComponentsInMPIRank(uint32_t rank);
418 void setComponentRanks(RankInfo rank);
420 bool containsComponentInRank(RankInfo rank);
422 bool checkRanks(RankInfo ranks);
426 ComponentId_t addComponent(
const std::string& name,
const std::string& type);
429 void addGlobalParam(
const std::string& global_set,
const std::string& key,
const std::string& value);
432 void setStatisticOutput(
const std::string& name);
435 void addStatisticOutputParameter(
const std::string& param,
const std::string& value);
438 void setStatisticOutputParams(
const Params& p);
441 void setStatisticLoadLevel(uint8_t loadLevel);
443 std::vector<ConfigStatOutput>& getStatOutputs() {
return statOutputs; }
445 const ConfigStatOutput& getStatOutput(
size_t index = 0)
const {
return statOutputs[index]; }
447 long getStatLoadLevel()
const {
return statLoadLevel; }
451 ComponentId_t comp_id,
const std::string& link_name,
const std::string& port,
const std::string& latency_str,
452 bool no_cut =
false);
455 void setLinkNoCut(
const std::string& link_name);
458 void postCreationCleanup();
461 bool checkForStructuralErrors();
467 const std::map<std::string, ConfigStatGroup>& getStatGroups()
const {
return statGroups; }
468 ConfigStatGroup* getStatGroup(
const std::string& name)
470 auto found = statGroups.find(name);
471 if ( found == statGroups.end() ) {
473 std::tie(found, ok) = statGroups.emplace(name, name);
475 return &(found->second);
478 bool containsComponent(ComponentId_t
id)
const;
479 ConfigComponent* findComponent(ComponentId_t);
480 ConfigComponent* findComponentByName(
const std::string& name);
481 const ConfigComponent* findComponent(ComponentId_t)
const;
483 bool containsStatistic(StatisticId_t
id)
const;
484 ConfigStatistic* findStatistic(StatisticId_t)
const;
489 ConfigGraph* getSubGraph(uint32_t start_rank, uint32_t end_rank);
490 ConfigGraph* getSubGraph(
const std::set<uint32_t>& rank_set);
492 ConfigGraph* splitGraph(
const std::set<uint32_t>& orig_rank_set,
const std::set<uint32_t>& new_rank_set);
497 void getConnectedNoCutComps(ComponentId_t start, std::set<ComponentId_t>& group);
499 void setComponentConfigGraphPointers();
507 if ( ser.mode() == SST::Core::Serialization::serializer::UNPACK ) {
510 setComponentConfigGraphPointers();
515 friend class Simulation_impl;
516 friend class SSTSDLModelDefinition;
520 ComponentId_t nextComponentId;
522 ConfigLinkMap_t links;
523 ConfigComponentMap_t comps;
524 ConfigComponentNameMap_t compsByName;
525 std::map<std::string, ConfigStatGroup> statGroups;
527 std::map<std::string, LinkId_t> link_names;
529 std::vector<ConfigStatOutput> statOutputs;
530 uint8_t statLoadLevel;
539 const std::set<uint32_t>& oset;
540 const std::set<uint32_t>& nset;
544 ConfigGraph* original_graph, ConfigGraph* new_graph,
const std::set<uint32_t>& original_rank_set,
545 const std::set<uint32_t>& new_rank_set);
547 ConfigLink* operator()(ConfigLink* link);
548 ConfigComponent* operator()(ConfigComponent* comp);
574 inline ComponentId_t key()
const {
return id; }
581 ComponentId_t component[2];
582 SimTime_t latency[2];
595 inline LinkId_t key()
const {
return id; }
600 if ( latency[0] < latency[1] )
return latency[0];
607 os <<
" Link " <<
id << std::endl;
608 os <<
" component[0] = " << component[0] << std::endl;
609 os <<
" latency[0] = " << latency[0] << std::endl;
610 os <<
" component[1] = " << component[1] << std::endl;
611 os <<
" latency[1] = " << latency[1] << std::endl;
615 typedef SparseVectorMap<ComponentId_t, PartitionComponent*> PartitionComponentMap_t;
616 typedef SparseVectorMap<LinkId_t, PartitionLink> PartitionLinkMap_t;
628 os <<
"Printing graph" << std::endl;
629 for ( PartitionComponentMap_t::const_iterator i = comps.
begin(); i != comps.
end(); ++i ) {
630 (*i)->print(os,
this);
635 PartitionLinkMap_t& getLinkMap() {
return links; }
637 const PartitionLink& getLink(LinkId_t
id)
const {
return links[id]; }
639 size_t getNumComponents() {
return comps.
size(); }
644 #endif // SST_CORE_CONFIGGRAPH_H Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file...
Definition: output.h:51
int slot_num
Definition: configGraph.h:225
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:34
float weight
Definition: configGraph.h:227
StatisticId_t id
Definition: configGraph.h:128
ConfigComponentMap_t & getComponentMap()
Return the map of components.
Definition: configGraph.h:465
SimTime_t getMinLatency() const
Return the minimum latency of this link (from both sides)
Definition: configGraph.h:598
Represents the configuration of a generic component.
Definition: configGraph.h:217
Definition: configGraph.h:618
ConfigComponent(ComponentId_t id, ConfigGraph *graph, const std::string &name, const std::string &type, float weight, RankInfo rank)
Create a new Component.
Definition: configGraph.h:336
void print(std::ostream &os) const
Print the Link information.
Definition: configGraph.h:70
std::string type
Definition: configGraph.h:226
A Configuration Graph A graph representing Components and Links.
Definition: configGraph.h:389
LinkId_t id
Definition: configGraph.h:48
Definition: configGraph.h:577
bool no_cut
Definition: configGraph.h:57
Definition: configGraph.h:125
Definition: configGraph.h:552
iterator end()
Returns the end iterator to the underlying vector.
Definition: sparseVectorMap.h:188
RankInfo rank
Definition: configGraph.h:228
uint16_t nextSubID
Definition: configGraph.h:240
iterator begin()
Returns the begin iterator to the underlying vector.
Definition: sparseVectorMap.h:181
uint8_t statLoadLevel
Definition: configGraph.h:231
Definition: serializable.h:118
LinkId_t order
Definition: configGraph.h:55
size_t size()
Returns the number of items in the SparseVectorMap.
Definition: sparseVectorMap.h:266
Represents the configuration of a generic Link.
Definition: configGraph.h:45
std::string name
Definition: configGraph.h:49
std::vector< std::string > getLocalKeys() const
Get a vector of the local keys.
Definition: params.cc:421
ConfigLinkMap_t & getLinkMap()
Return the map of links.
Definition: configGraph.h:487
ComponentId_t id
Definition: configGraph.h:222
std::vector< std::string > getSubscribedGlobalParamSets() const
Get a vector of the global param sets this Params object is subscribed to.
Definition: params.cc:433
Definition: rankInfo.h:21
SimTime_t latency[2]
Definition: configGraph.h:52
SimTime_t getMinLatency() const
Return the minimum latency of this link (from both sides)
Definition: configGraph.h:63
void print(std::ostream &os) const
Print the configuration graph.
Definition: configGraph.h:393
Params params
Definition: configGraph.h:230
uint16_t nextStatID
Definition: configGraph.h:241
std::vector< LinkId_t > links
Definition: configGraph.h:229
Parameter store.
Definition: params.h:55
Definition: configGraph.h:194
std::string name
Definition: configGraph.h:224
std::vector< ConfigComponent * > subComponents
Definition: configGraph.h:238
void print(std::ostream &os) const
Print the Link information.
Definition: configGraph.h:605
void print(std::ostream &os) const
Print the configuration graph.
Definition: configGraph.h:626
Definition: configGraph.h:158
Definition: componentInfo.h:39
void addGlobalParamSet(const std::string &set)
Adds a global param set to be looked at in this Params object if the key isn't found locally...
Definition: params.cc:284
uint32_t getVerboseLevel() const
Returns object verbose level.
Definition: output.cc:113
Definition: componentInfo.h:35
ConfigGraph * graph
Definition: configGraph.h:223
uint32_t getVerboseMask() const
Returns object verbose mask.
Definition: output.cc:125
ComponentId_t component[2]
Definition: configGraph.h:50
void insert(const std::string &key, const std::string &value, bool overwrite=true)
Add a key/value pair into the param object.
Definition: params.cc:140
Performs Unit math in full precision.
Definition: unitAlgebra.h:106
std::string getPrefix() const
Returns object prefix.
Definition: output.cc:137