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"
31 using namespace SST::Statistics;
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(); }
291 std::vector<std::string> getSubscribedGlobalParamSets()
const {
return params.getSubscribedGlobalParamSets(); }
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 ) {
401 ConfigGraph() : nextComponentId(0)
406 statLoadLevel = STATISTICSDEFAULTLOADLEVEL;
407 statOutputs.emplace_back(STATISTICSDEFAULTOUTPUTNAME);
409 Output& o = Output::getDefaultObject();
413 size_t getNumComponents() {
return comps.data.size(); }
416 void setComponentRanks(RankInfo rank);
418 bool containsComponentInRank(RankInfo rank);
420 bool checkRanks(RankInfo ranks);
424 ComponentId_t addComponent(
const std::string& name,
const std::string& type);
427 void addGlobalParam(
const std::string& global_set,
const std::string& key,
const std::string& value);
430 void setStatisticOutput(
const std::string& name);
433 void addStatisticOutputParameter(
const std::string& param,
const std::string& value);
436 void setStatisticOutputParams(
const Params& p);
439 void setStatisticLoadLevel(uint8_t loadLevel);
441 std::vector<ConfigStatOutput>& getStatOutputs() {
return statOutputs; }
443 const ConfigStatOutput& getStatOutput(
size_t index = 0)
const {
return statOutputs[index]; }
445 long getStatLoadLevel()
const {
return statLoadLevel; }
449 ComponentId_t comp_id,
const std::string& link_name,
const std::string& port,
const std::string& latency_str,
450 bool no_cut =
false);
453 void setLinkNoCut(
const std::string& link_name);
456 void postCreationCleanup();
459 bool checkForStructuralErrors();
465 const std::map<std::string, ConfigStatGroup>& getStatGroups()
const {
return statGroups; }
466 ConfigStatGroup* getStatGroup(
const std::string& name)
468 auto found = statGroups.find(name);
469 if ( found == statGroups.end() ) {
471 std::tie(found, ok) = statGroups.emplace(name, name);
473 return &(found->second);
476 bool containsComponent(ComponentId_t
id)
const;
477 ConfigComponent* findComponent(ComponentId_t);
478 ConfigComponent* findComponentByName(
const std::string& name);
479 const ConfigComponent* findComponent(ComponentId_t)
const;
481 bool containsStatistic(StatisticId_t
id)
const;
482 ConfigStatistic* findStatistic(StatisticId_t)
const;
487 ConfigGraph* getSubGraph(uint32_t start_rank, uint32_t end_rank);
488 ConfigGraph* getSubGraph(
const std::set<uint32_t>& rank_set);
490 ConfigGraph* splitGraph(
const std::set<uint32_t>& orig_rank_set,
const std::set<uint32_t>& new_rank_set);
495 void getConnectedNoCutComps(ComponentId_t start, std::set<ComponentId_t>& group);
497 void setComponentConfigGraphPointers();
505 if ( ser.mode() == SST::Core::Serialization::serializer::UNPACK ) {
508 setComponentConfigGraphPointers();
513 friend class Simulation_impl;
514 friend class SSTSDLModelDefinition;
518 ComponentId_t nextComponentId;
520 ConfigLinkMap_t links;
521 ConfigComponentMap_t comps;
522 ConfigComponentNameMap_t compsByName;
523 std::map<std::string, ConfigStatGroup> statGroups;
525 std::map<std::string, LinkId_t> link_names;
527 std::vector<ConfigStatOutput> statOutputs;
528 uint8_t statLoadLevel;
537 const std::set<uint32_t>& oset;
538 const std::set<uint32_t>& nset;
542 ConfigGraph* original_graph, ConfigGraph* new_graph,
const std::set<uint32_t>& original_rank_set,
543 const std::set<uint32_t>& new_rank_set);
545 ConfigLink* operator()(ConfigLink* link);
546 ConfigComponent* operator()(ConfigComponent* comp);
572 inline ComponentId_t key()
const {
return id; }
579 ComponentId_t component[2];
580 SimTime_t latency[2];
593 inline LinkId_t key()
const {
return id; }
598 if ( latency[0] < latency[1] )
return latency[0];
605 os <<
" Link " <<
id << std::endl;
606 os <<
" component[0] = " << component[0] << std::endl;
607 os <<
" latency[0] = " << latency[0] << std::endl;
608 os <<
" component[1] = " << component[1] << std::endl;
609 os <<
" latency[1] = " << latency[1] << std::endl;
613 typedef SparseVectorMap<ComponentId_t, PartitionComponent*> PartitionComponentMap_t;
614 typedef SparseVectorMap<LinkId_t, PartitionLink> PartitionLinkMap_t;
626 os <<
"Printing graph" << std::endl;
627 for ( PartitionComponentMap_t::const_iterator i = comps.begin(); i != comps.end(); ++i ) {
628 (*i)->print(os,
this);
633 PartitionLinkMap_t& getLinkMap() {
return links; }
635 const PartitionLink& getLink(LinkId_t
id)
const {
return links[id]; }
637 size_t getNumComponents() {
return comps.
size(); }
642 #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:463
void print(std::ostream &os) const
Print the Link information.
Definition: configGraph.h:603
uint32_t getVerboseLevel() const
Returns object verbose level.
Definition: output.cc:109
Represents the configuration of a generic component.
Definition: configGraph.h:217
Definition: configGraph.h:616
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:575
void print(std::ostream &os) const
Print the configuration graph.
Definition: configGraph.h:624
bool no_cut
Definition: configGraph.h:57
Definition: configGraph.h:125
Definition: configGraph.h:550
std::string getPrefix() const
Returns object prefix.
Definition: output.cc:133
SimTime_t getMinLatency() const
Return the minimum latency of this link (from both sides)
Definition: configGraph.h:596
RankInfo rank
Definition: configGraph.h:228
uint16_t nextSubID
Definition: configGraph.h:240
uint8_t statLoadLevel
Definition: configGraph.h:231
Definition: serializable.h:118
LinkId_t order
Definition: configGraph.h:55
void print(std::ostream &os) const
Print the Link information.
Definition: configGraph.h:70
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
ConfigLinkMap_t & getLinkMap()
Return the map of links.
Definition: configGraph.h:485
ComponentId_t id
Definition: configGraph.h:222
Definition: rankInfo.h:21
SimTime_t getMinLatency() const
Return the minimum latency of this link (from both sides)
Definition: configGraph.h:63
SimTime_t latency[2]
Definition: configGraph.h:52
Params params
Definition: configGraph.h:230
void print(std::ostream &os) const
Print the configuration graph.
Definition: configGraph.h:393
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
Definition: configGraph.h:158
Definition: componentInfo.h:39
uint32_t getVerboseMask() const
Returns object verbose mask.
Definition: output.cc:121
ConfigGraph * graph
Definition: configGraph.h:223
ComponentId_t component[2]
Definition: configGraph.h:50
Performs Unit math in full precision.
Definition: unitAlgebra.h:106