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;
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), statLoadLevel(STATISTICLOADLEVELUNINITIALIZED), nextSubID(1), visited(false) { }
224 ComponentId_t getNextSubComponentID();
226 ConfigComponent* getParent()
const;
227 std::string getFullName()
const;
230 void setRank(RankInfo r);
231 void setWeight(
double w);
232 void setCoordinates(
const std::vector<double> &c);
233 void addParameter(
const std::string& key,
const std::string& value,
bool overwrite);
234 ConfigComponent* addSubComponent(ComponentId_t,
const std::string& name,
const std::string& type,
int slot);
235 ConfigComponent* findSubComponent(ComponentId_t);
236 const ConfigComponent* findSubComponent(ComponentId_t)
const;
237 ConfigComponent* findSubComponentByName(
const std::string& name);
238 void enableStatistic(
const std::string& statisticName,
bool recursively =
false);
239 void addStatisticParameter(
const std::string& statisticName,
const std::string& param,
const std::string& value,
bool recursively =
false);
240 void setStatisticParameters(
const std::string& statisticName,
const Params ¶ms,
bool recursively =
false);
241 void setStatisticLoadLevel(uint8_t level,
bool recursively =
false);
243 std::vector<LinkId_t> allLinks()
const;
256 ser & enabledStatistics;
266 friend class ConfigGraph;
269 void checkPorts() const;
272 ConfigComponent(ComponentId_t
id, ConfigGraph* graph, const std::
string& name, const std::
string& type,
float weight, RankInfo rank) :
279 statLoadLevel(STATISTICLOADLEVELUNINITIALIZED),
282 coords.resize(3, 0.0);
285 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) :
293 statLoadLevel(STATISTICLOADLEVELUNINITIALIZED),
294 nextSubID(parent_subid)
296 coords.resize(3, 0.0);
308 typedef SparseVectorMap<ComponentId_t,ConfigComponent> ConfigComponentMap_t;
310 typedef std::map<std::string,ComponentId_t> ConfigComponentNameMap_t;
312 typedef std::map<std::string,Params*> ParamsMap_t;
314 typedef std::map<std::string,std::string> VariableMap_t;
316 class PartitionGraph;
324 void print(std::ostream &os)
const {
325 os <<
"Printing graph" << std::endl;
326 for (ConfigComponentMap_t::const_iterator i = comps.begin() ; i != comps.end() ; ++i) {
332 output(
Output::getDefaultObject()),
338 statLoadLevel = STATISTICSDEFAULTLOADLEVEL;
339 statOutputs.emplace_back(STATISTICSDEFAULTOUTPUTNAME);
342 size_t getNumComponents() {
return comps.data.size(); }
345 void setComponentRanks(RankInfo rank);
347 bool containsComponentInRank(RankInfo rank);
349 bool checkRanks(RankInfo ranks);
354 ComponentId_t addComponent(
const std::string& name,
const std::string& type,
float weight, RankInfo rank);
356 ComponentId_t addComponent(
const std::string& name,
const std::string& type);
360 void setStatisticOutput(
const std::string& name);
363 void addStatisticOutputParameter(
const std::string& param,
const std::string& value);
366 void setStatisticOutputParams(
const Params& p);
369 void setStatisticLoadLevel(uint8_t loadLevel);
372 void enableStatisticForComponentName(
const std::string& ComponentName,
const std::string& statisticName,
bool recursive =
false);
373 void enableStatisticForComponentType(
const std::string& ComponentType,
const std::string& statisticName,
bool recursive =
false);
376 void addStatisticParameterForComponentName(
const std::string& ComponentName,
const std::string& statisticName,
const std::string& param,
const std::string& value,
bool recursively);
377 void addStatisticParameterForComponentType(
const std::string& ComponentType,
const std::string& statisticName,
const std::string& param,
const std::string& value,
bool recursively);
378 void setStatisticLoadLevelForComponentType(
const std::string& compType, uint8_t level,
bool recursively =
false);
380 std::vector<ConfigStatOutput>& getStatOutputs() {
return statOutputs;}
381 const ConfigStatOutput& getStatOutput(
size_t index = 0)
const {
return statOutputs[index];}
382 long getStatLoadLevel()
const {
return statLoadLevel;}
385 void addLink(ComponentId_t comp_id,
const std::string& link_name,
const std::string& port,
const std::string& latency_str,
bool no_cut =
false);
388 void setLinkNoCut(
const std::string& link_name);
391 void postCreationCleanup();
394 bool checkForStructuralErrors();
402 const std::map<std::string, ConfigStatGroup>& getStatGroups()
const {
return statGroups; }
403 ConfigStatGroup* getStatGroup(
const std::string& name) {
404 auto found = statGroups.find(name);
405 if ( found == statGroups.end() ) {
407 std::tie(found, ok) = statGroups.emplace(name, name);
409 return &(found->second);
412 bool containsComponent(ComponentId_t
id)
const;
413 ConfigComponent* findComponent(ComponentId_t);
414 ConfigComponent* findComponentByName(
const std::string& name);
415 const ConfigComponent* findComponent(ComponentId_t)
const;
422 ConfigGraph* getSubGraph(uint32_t start_rank, uint32_t end_rank);
423 ConfigGraph* getSubGraph(
const std::set<uint32_t>& rank_set);
440 friend class Simulation;
441 friend class SSTSDLModelDefinition;
445 ComponentId_t nextComponentId;
447 ConfigLinkMap_t links;
448 ConfigComponentMap_t comps;
449 ConfigComponentNameMap_t compsByName;
450 std::map<std::string, ConfigStatGroup> statGroups;
452 std::map<std::string,LinkId_t> link_names;
454 std::vector<ConfigStatOutput> statOutputs;
455 uint8_t statLoadLevel;
480 rank(
RankInfo(RankInfo::UNASSIGNED, 0))
486 inline ComponentId_t key()
const {
return id; }
493 ComponentId_t component[2];
494 SimTime_t latency[2];
506 inline LinkId_t key()
const {
return id; }
510 if ( latency[0] < latency[1] )
return latency[0];
514 void print(std::ostream &os)
const {
515 os <<
" Link " <<
id << std::endl;
516 os <<
" component[0] = " << component[0] << std::endl;
517 os <<
" latency[0] = " << latency[0] << std::endl;
518 os <<
" component[1] = " << component[1] << std::endl;
519 os <<
" latency[1] = " << latency[1] << std::endl;
523 typedef SparseVectorMap<ComponentId_t,PartitionComponent> PartitionComponentMap_t;
524 typedef SparseVectorMap<LinkId_t,PartitionLink> PartitionLinkMap_t;
533 void print(std::ostream &os)
const {
534 os <<
"Printing graph" << std::endl;
535 for (PartitionComponentMap_t::const_iterator i = comps.begin() ; i != comps.end() ; ++i) {
543 PartitionLinkMap_t& getLinkMap() {
547 const PartitionLink& getLink(LinkId_t
id)
const {
551 size_t getNumComponents() {
return comps.size(); }
557 #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: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:398
void print(std::ostream &os) const
Print the Link information.
Definition: configGraph.h:514
Represents the configuration of a generic component.
Definition: configGraph.h:193
Definition: configGraph.h:526
std::string type
Definition: configGraph.h:199
A Configuration Graph A graph representing Components and Links.
Definition: configGraph.h:321
LinkId_t id
Definition: configGraph.h:51
Definition: configGraph.h:490
void print(std::ostream &os) const
Print the configuration graph.
Definition: configGraph.h:533
bool no_cut
Definition: configGraph.h:58
std::vector< Statistics::StatisticInfo > enabledStatistics
Definition: configGraph.h:205
Definition: configGraph.h:462
SimTime_t getMinLatency() const
Return the minimum latency of this link (from both sides)
Definition: configGraph.h:509
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:418
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:324
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