14 #ifndef SST_CORE_CONFIGGRAPH_H
15 #define SST_CORE_CONFIGGRAPH_H
17 #include "sst/core/sst_types.h"
24 #include "sst/core/sparseVectorMap.h"
25 #include "sst/core/params.h"
26 #include "sst/core/statapi/statbase.h"
27 #include "sst/core/statapi/statoutput.h"
28 #include "sst/core/rankInfo.h"
29 #include "sst/core/unitAlgebra.h"
31 #include "sst/core/serialization/serializable.h"
33 using namespace SST::Statistics;
38 class Simulation_impl;
44 typedef SparseVectorMap<ComponentId_t> ComponentIdMap_t;
45 typedef std::vector<LinkId_t> LinkIdMap_t;
53 ComponentId_t component[2];
56 std::string latency_str[2];
61 inline LinkId_t key()
const {
return id; }
65 if ( latency[0] < latency[1] )
return latency[0];
70 void print(std::ostream &os)
const {
71 os <<
"Link " << name <<
" (id = " <<
id <<
")" << std::endl;
72 os <<
" component[0] = " << component[0] << std::endl;
73 os <<
" port[0] = " << port[0] << std::endl;
74 os <<
" latency[0] = " << latency[0] << std::endl;
75 os <<
" component[1] = " << component[1] << std::endl;
76 os <<
" port[1] = " << port[1] << std::endl;
77 os <<
" latency[1] = " << latency[1] << std::endl;
98 friend class ConfigGraph;
99 ConfigLink(LinkId_t
id) :
106 component[0] = ULONG_MAX;
107 component[1] = ULONG_MAX;
110 ConfigLink(LinkId_t
id,
const std::string& n) :
118 component[0] = ULONG_MAX;
119 component[1] = ULONG_MAX;
122 void updateLatencies(TimeLord*);
134 ConfigStatistic(StatisticId_t _id,
bool _shared =
false, std::string _name =
"")
135 : id(_id), shared(_shared), name(_name) {}
139 inline const StatisticId_t& getId()
const {
return id; }
141 void addParameter(
const std::string& key,
const std::string& value,
bool overwrite);
150 ImplementSerializable(ConfigStatistic)
152 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;
167 bool addComponent(ComponentId_t
id);
168 bool addStatistic(
const std::string& name,
Params &p);
169 bool setOutput(
size_t id);
170 bool setFrequency(
const std::string& freq);
177 std::pair<bool, std::string> verifyStatsAndComponents(
const ConfigGraph* graph);
186 ser & outputFrequency;
203 void addParameter(
const std::string& key,
const std::string& val) {
204 params.insert(key, val);
235 std::map<std::string, StatisticId_t> enabledStatNames;
236 bool enabledAllStats;
240 std::vector<double> coords;
245 static constexpr ComponentId_t null_id = std::numeric_limits<ComponentId_t>::max();
247 inline const ComponentId_t& key()
const {
return id; }
250 void print(std::ostream &os)
const;
257 : id(null_id), statLoadLevel(STATISTICLOADLEVELUNINITIALIZED), enabledAllStats(false), nextSubID(1),
261 ComponentId_t getNextSubComponentID();
262 StatisticId_t getNextStatisticID();
264 ConfigComponent* getParent()
const;
265 std::string getFullName()
const;
267 void setRank(RankInfo r);
268 void setWeight(
double w);
269 void setCoordinates(
const std::vector<double> &c);
270 void addParameter(
const std::string& key,
const std::string& value,
bool overwrite);
271 ConfigComponent* addSubComponent(ComponentId_t,
const std::string& name,
const std::string& type,
int slot);
272 ConfigComponent* findSubComponent(ComponentId_t);
273 const ConfigComponent* findSubComponent(ComponentId_t)
const;
274 ConfigComponent* findSubComponentByName(
const std::string& name);
275 ConfigStatistic* findStatistic(
const std::string& name)
const;
276 ConfigStatistic* insertStatistic(StatisticId_t
id);
277 ConfigStatistic* findStatistic(StatisticId_t)
const;
278 ConfigStatistic* enableStatistic(
const std::string& statisticName,
const SST::Params& params,
279 bool recursively =
false);
280 ConfigStatistic* createStatistic();
281 bool reuseStatistic(
const std::string& statisticName, StatisticId_t sid);
282 void addStatisticParameter(
const std::string& statisticName,
const std::string& param,
const std::string& value,
bool recursively =
false);
283 void setStatisticParameters(
const std::string& statisticName,
const Params ¶ms,
bool recursively =
false);
284 void setStatisticLoadLevel(uint8_t level,
bool recursively =
false);
286 void addGlobalParamSet(
const std::string& set) {
287 params.addGlobalParamSet(set); }
289 std::vector<LinkId_t> allLinks()
const;
301 ser & enabledStatNames;
302 ser & enabledAllStats;
304 ser & enabledAllStats;
315 std::map<StatisticId_t, ConfigStatistic> statistics;
317 friend class ConfigGraph;
320 void checkPorts() const;
323 ConfigComponent(ComponentId_t
id, ConfigGraph* graph, const std::
string& name, const std::
string& type,
324 float weight, RankInfo rank)
325 :
id(
id), graph(graph), name(name), type(type), weight(weight), rank(rank),
326 statLoadLevel(STATISTICLOADLEVELUNINITIALIZED), enabledAllStats(false), nextSubID(1), nextStatID(1) {
327 coords.resize(3, 0.0);
330 ConfigComponent(ComponentId_t
id, ConfigGraph* graph, uint16_t parent_subid,
const std::string& name,
int slot_num,
331 const std::string& type,
float weight, RankInfo rank)
332 : id(id), graph(graph), name(name), slot_num(slot_num), type(type), weight(weight), rank(rank),
333 statLoadLevel(STATISTICLOADLEVELUNINITIALIZED), enabledAllStats(false), nextSubID(parent_subid),
334 nextStatID(parent_subid) {
335 coords.resize(3, 0.0);
345 typedef SparseVectorMap<ComponentId_t,ConfigComponent*> ConfigComponentMap_t;
347 typedef std::map<std::string,ComponentId_t> ConfigComponentNameMap_t;
349 typedef std::map<std::string,Params*> ParamsMap_t;
351 typedef std::map<std::string,std::string> VariableMap_t;
353 class PartitionGraph;
361 void print(std::ostream &os)
const {
362 os <<
"Printing graph" << std::endl;
363 for (ConfigComponentMap_t::const_iterator i = comps.begin() ; i != comps.end() ; ++i) {
369 output(
Output::getDefaultObject()),
375 statLoadLevel = STATISTICSDEFAULTLOADLEVEL;
376 statOutputs.emplace_back(STATISTICSDEFAULTOUTPUTNAME);
379 size_t getNumComponents() {
return comps.data.size(); }
382 void setComponentRanks(RankInfo rank);
384 bool containsComponentInRank(RankInfo rank);
386 bool checkRanks(RankInfo ranks);
391 ComponentId_t addComponent(
const std::string& name,
const std::string& type,
float weight, RankInfo rank);
393 ComponentId_t addComponent(
const std::string& name,
const std::string& type);
396 void addGlobalParam(
const std::string& global_set,
const std::string& key,
const std::string& value);
399 void setStatisticOutput(
const std::string& name);
402 void addStatisticOutputParameter(
const std::string& param,
const std::string& value);
405 void setStatisticOutputParams(
const Params& p);
408 void setStatisticLoadLevel(uint8_t loadLevel);
410 std::vector<ConfigStatOutput>& getStatOutputs() {
return statOutputs;}
412 const ConfigStatOutput& getStatOutput(
size_t index = 0)
const {
return statOutputs[index];}
414 long getStatLoadLevel()
const {
return statLoadLevel;}
417 void addLink(ComponentId_t comp_id,
const std::string& link_name,
const std::string& port,
const std::string& latency_str,
bool no_cut =
false);
420 void setLinkNoCut(
const std::string& link_name);
423 void postCreationCleanup();
426 bool checkForStructuralErrors();
434 const std::map<std::string, ConfigStatGroup>& getStatGroups()
const {
return statGroups; }
435 ConfigStatGroup* getStatGroup(
const std::string& name) {
436 auto found = statGroups.find(name);
437 if ( found == statGroups.end() ) {
439 std::tie(found, ok) = statGroups.emplace(name, name);
441 return &(found->second);
444 bool containsComponent(ComponentId_t
id)
const;
445 ConfigComponent* findComponent(ComponentId_t);
446 ConfigComponent* findComponentByName(
const std::string& name);
447 const ConfigComponent* findComponent(ComponentId_t)
const;
449 bool containsStatistic(StatisticId_t
id)
const;
450 ConfigStatistic* findStatistic(StatisticId_t)
const;
457 ConfigGraph* getSubGraph(uint32_t start_rank, uint32_t end_rank);
458 ConfigGraph* getSubGraph(
const std::set<uint32_t>& rank_set);
463 void getConnectedNoCutComps(ComponentId_t start, std::set<ComponentId_t>& group);
475 friend class Simulation_impl;
476 friend class SSTSDLModelDefinition;
480 ComponentId_t nextComponentId;
482 ConfigLinkMap_t links;
483 ConfigComponentMap_t comps;
484 ConfigComponentNameMap_t compsByName;
485 std::map<std::string, ConfigStatGroup> statGroups;
487 std::map<std::string,LinkId_t> link_names;
489 std::vector<ConfigStatOutput> statOutputs;
490 uint8_t statLoadLevel;
515 rank(
RankInfo(RankInfo::UNASSIGNED, 0))
521 inline ComponentId_t key()
const {
return id; }
528 ComponentId_t component[2];
529 SimTime_t latency[2];
541 inline LinkId_t key()
const {
return id; }
545 if ( latency[0] < latency[1] )
return latency[0];
549 void print(std::ostream &os)
const {
550 os <<
" Link " <<
id << std::endl;
551 os <<
" component[0] = " << component[0] << std::endl;
552 os <<
" latency[0] = " << latency[0] << std::endl;
553 os <<
" component[1] = " << component[1] << std::endl;
554 os <<
" latency[1] = " << latency[1] << std::endl;
558 typedef SparseVectorMap<ComponentId_t,PartitionComponent*> PartitionComponentMap_t;
559 typedef SparseVectorMap<LinkId_t,PartitionLink> PartitionLinkMap_t;
568 void print(std::ostream &os)
const {
569 os <<
"Printing graph" << std::endl;
570 for (PartitionComponentMap_t::const_iterator i = comps.begin() ; i != comps.end() ; ++i) {
571 (*i)->print(os,
this);
578 PartitionLinkMap_t& getLinkMap() {
582 const PartitionLink& getLink(LinkId_t
id)
const {
586 size_t getNumComponents() {
return comps.
size(); }
592 #endif // SST_CORE_CONFIGGRAPH_H
Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file...
Definition: output.h:54
int slot_num
Definition: configGraph.h:226
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:35
float weight
Definition: configGraph.h:228
StatisticId_t id
Definition: configGraph.h:129
ConfigComponentMap_t & getComponentMap()
Return the map of components.
Definition: configGraph.h:430
void print(std::ostream &os) const
Print the Link information.
Definition: configGraph.h:549
Represents the configuration of a generic component.
Definition: configGraph.h:219
Definition: configGraph.h:561
std::string type
Definition: configGraph.h:227
A Configuration Graph A graph representing Components and Links.
Definition: configGraph.h:358
LinkId_t id
Definition: configGraph.h:51
Definition: configGraph.h:525
void print(std::ostream &os) const
Print the configuration graph.
Definition: configGraph.h:568
bool no_cut
Definition: configGraph.h:58
Definition: configGraph.h:127
Definition: configGraph.h:497
SimTime_t getMinLatency() const
Return the minimum latency of this link (from both sides)
Definition: configGraph.h:544
RankInfo rank
Definition: configGraph.h:229
uint16_t nextSubID
Definition: configGraph.h:241
uint8_t statLoadLevel
Definition: configGraph.h:232
Definition: serializable.h:109
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:265
Represents the configuration of a generic Link.
Definition: configGraph.h:49
std::string name
Definition: configGraph.h:52
ConfigLinkMap_t & getLinkMap()
Return the map of links.
Definition: configGraph.h:453
ComponentId_t id
Definition: configGraph.h:223
Definition: rankInfo.h:21
SimTime_t getMinLatency() const
Return the minimum latency of this link (from both sides)
Definition: configGraph.h:64
SimTime_t latency[2]
Definition: configGraph.h:55
Params params
Definition: configGraph.h:231
void print(std::ostream &os) const
Print the configuration graph.
Definition: configGraph.h:361
uint16_t nextStatID
Definition: configGraph.h:243
std::vector< LinkId_t > links
Definition: configGraph.h:230
Parameter store.
Definition: params.h:44
Definition: configGraph.h:194
std::string name
Definition: configGraph.h:225
std::vector< ConfigComponent * > subComponents
Definition: configGraph.h:239
Definition: configGraph.h:155
Definition: componentInfo.h:40
int current_ref
Definition: configGraph.h:57
ConfigGraph * graph
Definition: configGraph.h:224
ComponentId_t component[2]
Definition: configGraph.h:53
Performs Unit math in full precision.
Definition: unitAlgebra.h:107