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;
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*);
132 std::map<std::string, Params> statMap;
133 std::vector<ComponentId_t> components;
141 bool addComponent(ComponentId_t
id);
142 bool addStatistic(
const std::string& name,
Params &p);
143 bool setOutput(
size_t id);
144 bool setFrequency(
const std::string& freq);
151 std::pair<bool, std::string> verifyStatsAndComponents(
const ConfigGraph* graph);
160 ser & outputFrequency;
177 void addParameter(
const std::string& key,
const std::string& val) {
178 params.insert(key, val);
207 std::vector<double> coords;
210 static constexpr ComponentId_t null_id = std::numeric_limits<ComponentId_t>::max();
212 inline const ComponentId_t& key()
const {
return id; }
215 void print(std::ostream &os)
const;
221 ConfigComponent() : id(null_id), statLoadLevel(STATISTICLOADLEVELUNINITIALIZED), nextSubID(1) { }
223 ComponentId_t getNextSubComponentID();
225 ConfigComponent* getParent()
const;
226 std::string getFullName()
const;
229 void setRank(RankInfo r);
230 void setWeight(
double w);
231 void setCoordinates(
const std::vector<double> &c);
232 void addParameter(
const std::string& key,
const std::string& value,
bool overwrite);
233 ConfigComponent* addSubComponent(ComponentId_t,
const std::string& name,
const std::string& type,
int slot);
234 ConfigComponent* findSubComponent(ComponentId_t);
235 const ConfigComponent* findSubComponent(ComponentId_t)
const;
236 ConfigComponent* findSubComponentByName(
const std::string& name);
237 void enableStatistic(
const std::string& statisticName,
bool recursively =
false);
238 void addStatisticParameter(
const std::string& statisticName,
const std::string& param,
const std::string& value,
bool recursively =
false);
239 void setStatisticParameters(
const std::string& statisticName,
const Params ¶ms,
bool recursively =
false);
240 void setStatisticLoadLevel(uint8_t level,
bool recursively =
false);
242 std::vector<LinkId_t> allLinks()
const;
255 ser & enabledStatistics;
265 friend class ConfigGraph;
267 ConfigComponent(ComponentId_t
id, ConfigGraph* graph, const std::
string& name, const std::
string& type,
float weight, RankInfo rank) :
274 statLoadLevel(STATISTICLOADLEVELUNINITIALIZED),
277 coords.resize(3, 0.0);
280 ConfigComponent(ComponentId_t
id, ConfigGraph* graph, uint16_t parent_subid,
const std::string& name,
int slot_num,
const std::string& type,
float weight, RankInfo rank) :
288 statLoadLevel(STATISTICLOADLEVELUNINITIALIZED),
289 nextSubID(parent_subid)
291 coords.resize(3, 0.0);
303 typedef SparseVectorMap<ComponentId_t,ConfigComponent> ConfigComponentMap_t;
307 typedef std::map<std::string,Params*> ParamsMap_t;
309 typedef std::map<std::string,std::string> VariableMap_t;
311 class PartitionGraph;
319 void print(std::ostream &os)
const {
320 os <<
"Printing graph" << std::endl;
321 for (ConfigComponentMap_t::const_iterator i = comps.begin() ; i != comps.end() ; ++i) {
330 statLoadLevel = STATISTICSDEFAULTLOADLEVEL;
331 statOutputs.emplace_back(STATISTICSDEFAULTOUTPUTNAME);
334 size_t getNumComponents() {
return comps.data.size(); }
337 void setComponentRanks(RankInfo rank);
339 bool containsComponentInRank(RankInfo rank);
341 bool checkRanks(RankInfo ranks);
346 ComponentId_t addComponent(ComponentId_t
id,
const std::string& name,
const std::string& type,
float weight, RankInfo rank);
348 ComponentId_t addComponent(ComponentId_t
id,
const std::string& name,
const std::string& type);
352 void setStatisticOutput(
const std::string& name);
355 void addStatisticOutputParameter(
const std::string& param,
const std::string& value);
358 void setStatisticOutputParams(
const Params& p);
361 void setStatisticLoadLevel(uint8_t loadLevel);
364 void enableStatisticForComponentName(
const std::string& ComponentName,
const std::string& statisticName,
bool recursive =
false);
365 void enableStatisticForComponentType(
const std::string& ComponentType,
const std::string& statisticName,
bool recursive =
false);
368 void addStatisticParameterForComponentName(
const std::string& ComponentName,
const std::string& statisticName,
const std::string& param,
const std::string& value,
bool recursively);
369 void addStatisticParameterForComponentType(
const std::string& ComponentType,
const std::string& statisticName,
const std::string& param,
const std::string& value,
bool recursively);
370 void setStatisticLoadLevelForComponentType(
const std::string& compType, uint8_t level,
bool recursively =
false);
372 std::vector<ConfigStatOutput>& getStatOutputs() {
return statOutputs;}
373 const ConfigStatOutput& getStatOutput(
size_t index = 0)
const {
return statOutputs[index];}
374 long getStatLoadLevel()
const {
return statLoadLevel;}
377 void addLink(ComponentId_t comp_id,
const std::string& link_name,
const std::string& port,
const std::string& latency_str,
bool no_cut =
false);
380 void setLinkNoCut(
const std::string& link_name);
383 void postCreationCleanup();
386 bool checkForStructuralErrors();
394 const std::map<std::string, ConfigStatGroup>& getStatGroups()
const {
return statGroups; }
395 ConfigStatGroup* getStatGroup(
const std::string& name) {
396 auto found = statGroups.find(name);
397 if ( found == statGroups.end() ) {
399 std::tie(found, ok) = statGroups.emplace(name, name);
401 return &(found->second);
404 bool containsComponent(ComponentId_t
id)
const;
405 ConfigComponent* findComponent(ComponentId_t);
406 const ConfigComponent* findComponent(ComponentId_t)
const;
413 ConfigGraph* getSubGraph(uint32_t start_rank, uint32_t end_rank);
414 ConfigGraph* getSubGraph(
const std::set<uint32_t>& rank_set);
431 friend class Simulation;
432 friend class SSTSDLModelDefinition;
434 ConfigLinkMap_t links;
435 ConfigComponentMap_t comps;
437 std::map<std::string, ConfigStatGroup> statGroups;
440 std::map<std::string,LinkId_t> link_names;
442 std::vector<ConfigStatOutput> statOutputs;
443 uint8_t statLoadLevel;
468 rank(
RankInfo(RankInfo::UNASSIGNED, 0))
474 inline ComponentId_t key()
const {
return id; }
481 ComponentId_t component[2];
482 SimTime_t latency[2];
494 inline LinkId_t key()
const {
return id; }
498 if ( latency[0] < latency[1] )
return latency[0];
502 void print(std::ostream &os)
const {
503 os <<
" Link " <<
id << std::endl;
504 os <<
" component[0] = " << component[0] << std::endl;
505 os <<
" latency[0] = " << latency[0] << std::endl;
506 os <<
" component[1] = " << component[1] << std::endl;
507 os <<
" latency[1] = " << latency[1] << std::endl;
511 typedef SparseVectorMap<ComponentId_t,PartitionComponent> PartitionComponentMap_t;
512 typedef SparseVectorMap<LinkId_t,PartitionLink> PartitionLinkMap_t;
521 void print(std::ostream &os)
const {
522 os <<
"Printing graph" << std::endl;
523 for (PartitionComponentMap_t::const_iterator i = comps.begin() ; i != comps.end() ; ++i) {
531 PartitionLinkMap_t& getLinkMap() {
535 const PartitionLink& getLink(LinkId_t
id)
const {
539 size_t getNumComponents() {
return comps.size(); }
545 #endif // SST_CORE_CONFIGGRAPH_H
int slot_num
Definition: configGraph.h:198
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:200
ConfigComponentMap_t & getComponentMap()
Return the map of components.
Definition: configGraph.h:390
void print(std::ostream &os) const
Print the Link information.
Definition: configGraph.h:502
Represents the configuration of a generic component.
Definition: configGraph.h:193
Definition: configGraph.h:514
std::string type
Definition: configGraph.h:199
A Configuration Graph A graph representing Components and Links.
Definition: configGraph.h:316
LinkId_t id
Definition: configGraph.h:51
Definition: configGraph.h:478
void print(std::ostream &os) const
Print the configuration graph.
Definition: configGraph.h:521
bool no_cut
Definition: configGraph.h:58
std::vector< Statistics::StatisticInfo > enabledStatistics
Definition: configGraph.h:205
Definition: configGraph.h:450
SimTime_t getMinLatency() const
Return the minimum latency of this link (from both sides)
Definition: configGraph.h:497
RankInfo rank
Definition: configGraph.h:201
uint16_t nextSubID
Definition: configGraph.h:208
uint8_t statLoadLevel
Definition: configGraph.h:204
Definition: serializable.h:109
void print(std::ostream &os) const
Print the Link information.
Definition: configGraph.h:70
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:409
ComponentId_t id
Definition: configGraph.h:195
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:203
void print(std::ostream &os) const
Print the configuration graph.
Definition: configGraph.h:319
std::vector< LinkId_t > links
Definition: configGraph.h:202
Parameter store.
Definition: params.h:44
Definition: configGraph.h:168
std::string name
Definition: configGraph.h:197
Definition: configGraph.h:129
int current_ref
Definition: configGraph.h:57
ConfigGraph * graph
Definition: configGraph.h:196
std::vector< ConfigComponent > subComponents
Definition: configGraph.h:206
ComponentId_t component[2]
Definition: configGraph.h:53
Performs Unit math in full precision.
Definition: unitAlgebra.h:107