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];
58 inline LinkId_t key()
const {
return id; }
63 if ( latency[0] < latency[1] )
return latency[0];
68 void print(std::ostream& os)
const
70 os <<
"Link " << name <<
" (id = " <<
id <<
")" << std::endl;
71 os <<
" component[0] = " << component[0] << std::endl;
72 os <<
" port[0] = " << port[0] << std::endl;
73 os <<
" latency[0] = " << latency[0] << std::endl;
74 os <<
" component[1] = " << component[1] << std::endl;
75 os <<
" port[1] = " << port[1] << std::endl;
76 os <<
" latency[1] = " << latency[1] << std::endl;
98 friend class ConfigGraph;
99 ConfigLink(LinkId_t
id) :
id(
id), no_cut(false)
104 component[0] = ULONG_MAX;
105 component[1] = ULONG_MAX;
108 ConfigLink(LinkId_t
id,
const std::string& n) : id(id), no_cut(false)
114 component[0] = ULONG_MAX;
115 component[1] = ULONG_MAX;
118 void updateLatencies(TimeLord*);
129 ConfigStatistic(StatisticId_t _id,
bool _shared =
false, std::string _name =
"") :
137 inline const StatisticId_t& getId()
const {
return id; }
139 void addParameter(
const std::string& key,
const std::string& value,
bool overwrite);
149 ImplementSerializable(ConfigStatistic)
151 static constexpr StatisticId_t stat_null_id = std::numeric_limits<StatisticId_t>::max();
158 std::map<std::string, Params> statMap;
159 std::vector<ComponentId_t> components;
166 bool addComponent(ComponentId_t
id);
167 bool addStatistic(
const std::string& name,
Params& p);
168 bool setOutput(
size_t id);
169 bool setFrequency(
const std::string& freq);
176 std::pair<bool, std::string> verifyStatsAndComponents(
const ConfigGraph* graph);
184 ser& outputFrequency;
199 void addParameter(
const std::string& key,
const std::string& val) { params.insert(key, val); }
230 std::map<std::string, StatisticId_t> enabledStatNames;
231 bool enabledAllStats;
235 std::vector<double> coords;
240 static constexpr ComponentId_t null_id = std::numeric_limits<ComponentId_t>::max();
242 inline const ComponentId_t& key()
const {
return id; }
245 void print(std::ostream& os)
const;
253 statLoadLevel(STATISTICLOADLEVELUNINITIALIZED),
254 enabledAllStats(false),
259 ComponentId_t getNextSubComponentID();
260 StatisticId_t getNextStatisticID();
262 ConfigComponent* getParent()
const;
263 std::string getFullName()
const;
265 void setRank(RankInfo r);
266 void setWeight(
double w);
267 void setCoordinates(
const std::vector<double>& c);
268 void addParameter(
const std::string& key,
const std::string& value,
bool overwrite);
269 ConfigComponent* addSubComponent(ComponentId_t,
const std::string& name,
const std::string& type,
int slot);
270 ConfigComponent* findSubComponent(ComponentId_t);
271 const ConfigComponent* findSubComponent(ComponentId_t)
const;
272 ConfigComponent* findSubComponentByName(
const std::string& name);
273 ConfigStatistic* findStatistic(
const std::string& name)
const;
274 ConfigStatistic* insertStatistic(StatisticId_t
id);
275 ConfigStatistic* findStatistic(StatisticId_t)
const;
277 enableStatistic(
const std::string& statisticName,
const SST::Params& params,
bool recursively =
false);
278 ConfigStatistic* createStatistic();
279 bool reuseStatistic(
const std::string& statisticName, StatisticId_t sid);
280 void addStatisticParameter(
281 const std::string& statisticName,
const std::string& param,
const std::string& value,
bool recursively =
false);
282 void setStatisticParameters(
const std::string& statisticName,
const Params& params,
bool recursively =
false);
283 void setStatisticLoadLevel(uint8_t level,
bool recursively =
false);
285 void addGlobalParamSet(
const std::string& set) { params.addGlobalParamSet(set); }
287 std::vector<LinkId_t> allLinks()
const;
300 ser& enabledStatNames;
301 ser& enabledAllStats;
303 ser& enabledAllStats;
314 std::map<StatisticId_t, ConfigStatistic> statistics;
316 friend class ConfigGraph;
319 void checkPorts() const;
323 ComponentId_t
id, ConfigGraph* graph, const std::
string& name, const std::
string& type,
float weight,
331 statLoadLevel(STATISTICLOADLEVELUNINITIALIZED),
332 enabledAllStats(false),
336 coords.resize(3, 0.0);
340 ComponentId_t
id, ConfigGraph* graph, uint16_t parent_subid,
const std::string& name,
int slot_num,
341 const std::string& type,
float weight, RankInfo rank) :
349 statLoadLevel(STATISTICLOADLEVELUNINITIALIZED),
350 enabledAllStats(false),
351 nextSubID(parent_subid),
352 nextStatID(parent_subid)
354 coords.resize(3, 0.0);
362 typedef SparseVectorMap<ComponentId_t, ConfigComponent*> ConfigComponentMap_t;
364 typedef std::map<std::string, ComponentId_t> ConfigComponentNameMap_t;
366 typedef std::map<std::string, Params*> ParamsMap_t;
368 typedef std::map<std::string, std::string> VariableMap_t;
370 class PartitionGraph;
381 os <<
"Printing graph" << std::endl;
382 for ( ConfigComponentMap_t::const_iterator i = comps.begin(); i != comps.end(); ++i ) {
387 ConfigGraph() : output(
Output::getDefaultObject()), nextComponentId(0)
392 statLoadLevel = STATISTICSDEFAULTLOADLEVEL;
393 statOutputs.emplace_back(STATISTICSDEFAULTOUTPUTNAME);
396 size_t getNumComponents() {
return comps.data.size(); }
399 void setComponentRanks(RankInfo rank);
401 bool containsComponentInRank(RankInfo rank);
403 bool checkRanks(RankInfo ranks);
407 ComponentId_t addComponent(
const std::string& name,
const std::string& type,
float weight, RankInfo rank);
409 ComponentId_t addComponent(
const std::string& name,
const std::string& type);
412 void addGlobalParam(
const std::string& global_set,
const std::string& key,
const std::string& value);
415 void setStatisticOutput(
const std::string& name);
418 void addStatisticOutputParameter(
const std::string& param,
const std::string& value);
421 void setStatisticOutputParams(
const Params& p);
424 void setStatisticLoadLevel(uint8_t loadLevel);
426 std::vector<ConfigStatOutput>& getStatOutputs() {
return statOutputs; }
428 const ConfigStatOutput& getStatOutput(
size_t index = 0)
const {
return statOutputs[index]; }
430 long getStatLoadLevel()
const {
return statLoadLevel; }
434 ComponentId_t comp_id,
const std::string& link_name,
const std::string& port,
const std::string& latency_str,
435 bool no_cut =
false);
438 void setLinkNoCut(
const std::string& link_name);
441 void postCreationCleanup();
444 bool checkForStructuralErrors();
450 const std::map<std::string, ConfigStatGroup>& getStatGroups()
const {
return statGroups; }
451 ConfigStatGroup* getStatGroup(
const std::string& name)
453 auto found = statGroups.find(name);
454 if ( found == statGroups.end() ) {
456 std::tie(found, ok) = statGroups.emplace(name, name);
458 return &(found->second);
461 bool containsComponent(ComponentId_t
id)
const;
462 ConfigComponent* findComponent(ComponentId_t);
463 ConfigComponent* findComponentByName(
const std::string& name);
464 const ConfigComponent* findComponent(ComponentId_t)
const;
466 bool containsStatistic(StatisticId_t
id)
const;
467 ConfigStatistic* findStatistic(StatisticId_t)
const;
472 ConfigGraph* getSubGraph(uint32_t start_rank, uint32_t end_rank);
473 ConfigGraph* getSubGraph(
const std::set<uint32_t>& rank_set);
478 void getConnectedNoCutComps(ComponentId_t start, std::set<ComponentId_t>& group);
490 friend class Simulation_impl;
491 friend class SSTSDLModelDefinition;
495 ComponentId_t nextComponentId;
497 ConfigLinkMap_t links;
498 ConfigComponentMap_t comps;
499 ConfigComponentNameMap_t compsByName;
500 std::map<std::string, ConfigStatGroup> statGroups;
502 std::map<std::string, LinkId_t> link_names;
504 std::vector<ConfigStatOutput> statOutputs;
505 uint8_t statLoadLevel;
532 inline ComponentId_t key()
const {
return id; }
539 ComponentId_t component[2];
540 SimTime_t latency[2];
553 inline LinkId_t key()
const {
return id; }
558 if ( latency[0] < latency[1] )
return latency[0];
565 os <<
" Link " <<
id << std::endl;
566 os <<
" component[0] = " << component[0] << std::endl;
567 os <<
" latency[0] = " << latency[0] << std::endl;
568 os <<
" component[1] = " << component[1] << std::endl;
569 os <<
" latency[1] = " << latency[1] << std::endl;
573 typedef SparseVectorMap<ComponentId_t, PartitionComponent*> PartitionComponentMap_t;
574 typedef SparseVectorMap<LinkId_t, PartitionLink> PartitionLinkMap_t;
586 os <<
"Printing graph" << std::endl;
587 for ( PartitionComponentMap_t::const_iterator i = comps.begin(); i != comps.end(); ++i ) {
588 (*i)->print(os,
this);
593 PartitionLinkMap_t& getLinkMap() {
return links; }
595 const PartitionLink& getLink(LinkId_t
id)
const {
return links[id]; }
597 size_t getNumComponents() {
return comps.
size(); }
602 #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:221
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:223
StatisticId_t id
Definition: configGraph.h:124
ConfigComponentMap_t & getComponentMap()
Return the map of components.
Definition: configGraph.h:448
void print(std::ostream &os) const
Print the Link information.
Definition: configGraph.h:563
Represents the configuration of a generic component.
Definition: configGraph.h:213
Definition: configGraph.h:576
std::string type
Definition: configGraph.h:222
A Configuration Graph A graph representing Components and Links.
Definition: configGraph.h:375
LinkId_t id
Definition: configGraph.h:48
Definition: configGraph.h:535
void print(std::ostream &os) const
Print the configuration graph.
Definition: configGraph.h:584
bool no_cut
Definition: configGraph.h:55
Definition: configGraph.h:121
Definition: configGraph.h:510
SimTime_t getMinLatency() const
Return the minimum latency of this link (from both sides)
Definition: configGraph.h:556
RankInfo rank
Definition: configGraph.h:224
uint16_t nextSubID
Definition: configGraph.h:236
uint8_t statLoadLevel
Definition: configGraph.h:227
Definition: serializable.h:118
void print(std::ostream &os) const
Print the Link information.
Definition: configGraph.h:68
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:470
ComponentId_t id
Definition: configGraph.h:218
Definition: rankInfo.h:21
SimTime_t getMinLatency() const
Return the minimum latency of this link (from both sides)
Definition: configGraph.h:61
SimTime_t latency[2]
Definition: configGraph.h:52
Params params
Definition: configGraph.h:226
void print(std::ostream &os) const
Print the configuration graph.
Definition: configGraph.h:379
uint16_t nextStatID
Definition: configGraph.h:238
std::vector< LinkId_t > links
Definition: configGraph.h:225
Parameter store.
Definition: params.h:43
Definition: configGraph.h:190
std::string name
Definition: configGraph.h:220
std::vector< ConfigComponent * > subComponents
Definition: configGraph.h:234
Definition: configGraph.h:154
Definition: componentInfo.h:39
int current_ref
Definition: configGraph.h:54
ConfigGraph * graph
Definition: configGraph.h:219
ComponentId_t component[2]
Definition: configGraph.h:50
Performs Unit math in full precision.
Definition: unitAlgebra.h:106