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>
35 using namespace SST::Statistics;
46 typedef SparseVectorMap<ComponentId_t> ComponentIdMap_t;
47 typedef std::vector<LinkId_t> LinkIdMap_t;
55 ComponentId_t component[2];
58 std::string latency_str[2];
63 inline LinkId_t key()
const {
return id; }
67 if ( latency[0] < latency[1] )
return latency[0];
72 void print(std::ostream &os)
const {
73 os <<
"Link " << name <<
" (id = " <<
id <<
")" << std::endl;
74 os <<
" component[0] = " << component[0] << std::endl;
75 os <<
" port[0] = " << port[0] << std::endl;
76 os <<
" latency[0] = " << latency[0] << std::endl;
77 os <<
" component[1] = " << component[1] << std::endl;
78 os <<
" port[1] = " << port[1] << std::endl;
79 os <<
" latency[1] = " << latency[1] << std::endl;
100 friend class ConfigGraph;
101 ConfigLink(LinkId_t
id) :
108 component[0] = ULONG_MAX;
109 component[1] = ULONG_MAX;
112 ConfigLink(LinkId_t
id,
const std::string &n) :
120 component[0] = ULONG_MAX;
121 component[1] = ULONG_MAX;
124 void updateLatencies(TimeLord*);
134 std::map<std::string, Params> statMap;
135 std::vector<ComponentId_t> components;
143 bool addComponent(ComponentId_t
id);
144 bool addStatistic(
const std::string &name,
Params &p);
145 bool setOutput(
size_t id);
146 bool setFrequency(
const std::string &freq);
153 std::pair<bool, std::string> verifyStatsAndComponents(
const ConfigGraph* graph);
162 ser & outputFrequency;
179 void addParameter(
const std::string &key,
const std::string &val) {
180 params.insert(key, val);
208 std::vector<double> coords;
211 static constexpr ComponentId_t null_id = std::numeric_limits<ComponentId_t>::max();
213 inline const ComponentId_t& key()
const {
return id; }
216 void print(std::ostream &os)
const;
222 ConfigComponent() : id(null_id) {}
224 void setRank(RankInfo r);
225 void setWeight(
double w);
226 void setCoordinates(
const std::vector<double> &c);
227 void addParameter(
const std::string &key,
const std::string &value,
bool overwrite);
228 ConfigComponent* addSubComponent(ComponentId_t,
const std::string &name,
const std::string &type,
int slot);
229 ConfigComponent* findSubComponent(ComponentId_t);
230 const ConfigComponent* findSubComponent(ComponentId_t)
const;
231 void enableStatistic(
const std::string &statisticName,
bool recursively =
false);
232 void addStatisticParameter(
const std::string &statisticName,
const std::string ¶m,
const std::string &value,
bool recursively =
false);
233 void setStatisticParameters(
const std::string &statisticName,
const Params ¶ms,
bool recursively =
false);
235 std::vector<LinkId_t> allLinks()
const;
247 ser & enabledStatistics;
255 friend class ConfigGraph;
257 ConfigComponent(ComponentId_t
id, std::
string name, std::
string type,
float weight, RankInfo rank) :
264 coords.resize(3, 0.0);
267 ConfigComponent(ComponentId_t
id, std::string name,
int slot_num, std::string type,
float weight, RankInfo rank) :
275 coords.resize(3, 0.0);
287 typedef SparseVectorMap<ComponentId_t,ConfigComponent> ConfigComponentMap_t;
289 typedef std::map<std::string,Params*> ParamsMap_t;
291 typedef std::map<std::string,std::string> VariableMap_t;
293 class PartitionGraph;
301 void print(std::ostream &os)
const {
302 os <<
"Printing graph" << std::endl;
303 for (ConfigComponentMap_t::const_iterator i = comps.begin() ; i != comps.end() ; ++i) {
312 statLoadLevel = STATISTICSDEFAULTLOADLEVEL;
313 statOutputs.emplace_back(STATISTICSDEFAULTOUTPUTNAME);
316 size_t getNumComponents() {
return comps.data.size(); }
319 void setComponentRanks(RankInfo rank);
321 bool containsComponentInRank(RankInfo rank);
323 bool checkRanks(RankInfo ranks);
328 ComponentId_t addComponent(ComponentId_t
id, std::string name, std::string type,
float weight, RankInfo rank);
330 ComponentId_t addComponent(ComponentId_t
id, std::string name, std::string type);
334 void setStatisticOutput(
const std::string &name);
337 void addStatisticOutputParameter(
const std::string ¶m,
const std::string &value);
340 void setStatisticOutputParams(
const Params& p);
343 void setStatisticLoadLevel(uint8_t loadLevel);
346 void enableStatisticForComponentName(std::string ComponentName, std::string statisticName);
347 void enableStatisticForComponentType(std::string ComponentType, std::string statisticName);
350 void addStatisticParameterForComponentName(
const std::string &ComponentName,
const std::string &statisticName,
const std::string ¶m,
const std::string &value);
351 void addStatisticParameterForComponentType(
const std::string &ComponentType,
const std::string &statisticName,
const std::string ¶m,
const std::string &value);
353 std::vector<ConfigStatOutput>& getStatOutputs() {
return statOutputs;}
354 const ConfigStatOutput& getStatOutput(
size_t index = 0)
const {
return statOutputs[index];}
355 long getStatLoadLevel()
const {
return statLoadLevel;}
358 void addLink(ComponentId_t comp_id, std::string link_name, std::string port, std::string latency_str,
bool no_cut =
false);
361 void setLinkNoCut(std::string link_name);
364 void postCreationCleanup();
367 bool checkForStructuralErrors();
375 const std::map<std::string, ConfigStatGroup>& getStatGroups()
const {
return statGroups; }
376 ConfigStatGroup* getStatGroup(
const std::string &name) {
377 auto found = statGroups.find(name);
378 if ( found == statGroups.end() ) {
380 std::tie(found, ok) = statGroups.emplace(name, name);
382 return &(found->second);
385 bool containsComponent(ComponentId_t
id)
const;
386 ConfigComponent* findComponent(ComponentId_t);
387 const ConfigComponent* findComponent(ComponentId_t)
const;
394 ConfigGraph* getSubGraph(uint32_t start_rank, uint32_t end_rank);
395 ConfigGraph* getSubGraph(
const std::set<uint32_t>& rank_set);
412 friend class Simulation;
413 friend class SSTSDLModelDefinition;
415 ConfigLinkMap_t links;
416 ConfigComponentMap_t comps;
417 std::map<std::string, ConfigStatGroup> statGroups;
420 std::map<std::string,LinkId_t> link_names;
422 std::vector<ConfigStatOutput> statOutputs;
423 uint8_t statLoadLevel;
448 rank(
RankInfo(RankInfo::UNASSIGNED, 0))
454 inline ComponentId_t key()
const {
return id; }
461 ComponentId_t component[2];
462 SimTime_t latency[2];
474 inline LinkId_t key()
const {
return id; }
478 if ( latency[0] < latency[1] )
return latency[0];
482 void print(std::ostream &os)
const {
483 os <<
" Link " <<
id << std::endl;
484 os <<
" component[0] = " << component[0] << std::endl;
485 os <<
" latency[0] = " << latency[0] << std::endl;
486 os <<
" component[1] = " << component[1] << std::endl;
487 os <<
" latency[1] = " << latency[1] << std::endl;
491 typedef SparseVectorMap<ComponentId_t,PartitionComponent> PartitionComponentMap_t;
492 typedef SparseVectorMap<LinkId_t,PartitionLink> PartitionLinkMap_t;
501 void print(std::ostream &os)
const {
502 os <<
"Printing graph" << std::endl;
503 for (PartitionComponentMap_t::const_iterator i = comps.begin() ; i != comps.end() ; ++i) {
511 PartitionLinkMap_t& getLinkMap() {
515 const PartitionLink& getLink(LinkId_t
id)
const {
519 size_t getNumComponents() {
return comps.size(); }
525 #endif // SST_CORE_CONFIGGRAPH_H
int slot_num
Definition: configGraph.h:200
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:202
ConfigComponentMap_t & getComponentMap()
Return the map of components.
Definition: configGraph.h:371
void print(std::ostream &os) const
Print the Link information.
Definition: configGraph.h:482
Represents the configuration of a generic component.
Definition: configGraph.h:195
Definition: configGraph.h:494
std::string type
Definition: configGraph.h:201
A Configuration Graph A graph representing Components and Links.
Definition: configGraph.h:298
LinkId_t id
Definition: configGraph.h:53
Definition: configGraph.h:458
void print(std::ostream &os) const
Print the configuration graph.
Definition: configGraph.h:501
bool no_cut
Definition: configGraph.h:60
std::vector< Statistics::StatisticInfo > enabledStatistics
Definition: configGraph.h:206
Definition: configGraph.h:430
SimTime_t getMinLatency() const
Return the minimum latency of this link (from both sides)
Definition: configGraph.h:477
RankInfo rank
Definition: configGraph.h:203
uint16_t nextSubID
Definition: configGraph.h:209
Definition: serializable.h:110
void print(std::ostream &os) const
Print the Link information.
Definition: configGraph.h:72
Represents the configuration of a generic Link.
Definition: configGraph.h:51
std::string name
Definition: configGraph.h:54
ConfigLinkMap_t & getLinkMap()
Return the map of links.
Definition: configGraph.h:390
ComponentId_t id
Definition: configGraph.h:197
Definition: rankInfo.h:21
SimTime_t getMinLatency() const
Return the minimum latency of this link (from both sides)
Definition: configGraph.h:66
SimTime_t latency[2]
Definition: configGraph.h:57
Params params
Definition: configGraph.h:205
void print(std::ostream &os) const
Print the configuration graph.
Definition: configGraph.h:301
std::vector< LinkId_t > links
Definition: configGraph.h:204
Parameter store.
Definition: params.h:45
Definition: configGraph.h:170
std::string name
Definition: configGraph.h:199
Definition: configGraph.h:131
int current_ref
Definition: configGraph.h:59
ConfigComponent * ulitmate_parent
Definition: configGraph.h:198
std::vector< ConfigComponent > subComponents
Definition: configGraph.h:207
ComponentId_t component[2]
Definition: configGraph.h:55
Performs Unit math in full precision.
Definition: unitAlgebra.h:104