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"
31using namespace SST::Statistics;
42typedef std::vector<LinkId_t> LinkIdMap_t;
60 inline LinkId_t key()
const {
return id; }
70 void print(std::ostream& os)
const
72 os <<
"Link " <<
name <<
" (id = " <<
id <<
")" << std::endl;
73 os <<
" component[0] = " <<
component[0] << std::endl;
74 os <<
" port[0] = " <<
port[0] << std::endl;
75 os <<
" latency[0] = " <<
latency[0] << std::endl;
76 os <<
" component[1] = " <<
component[1] << std::endl;
77 os <<
" port[1] = " <<
port[1] << std::endl;
78 os <<
" latency[1] = " <<
latency[1] << std::endl;
133 ConfigStatistic(StatisticId_t _id,
bool _shared =
false, std::string _name =
"") :
141 inline const StatisticId_t& getId()
const {
return id; }
143 void addParameter(
const std::string& key,
const std::string& value,
bool overwrite);
155 static constexpr StatisticId_t stat_null_id = std::numeric_limits<StatisticId_t>::max();
162 std::map<std::string, Params> statMap;
163 std::vector<ComponentId_t> components;
170 bool addComponent(ComponentId_t
id);
171 bool addStatistic(
const std::string& name,
Params& p);
172 bool setOutput(
size_t id);
173 bool setFrequency(
const std::string& freq);
188 ser& outputFrequency;
203 void addParameter(
const std::string& key,
const std::string& val) { params.
insert(key, val); }
234 std::map<std::string, StatisticId_t> enabledStatNames;
235 bool enabledAllStats;
239 std::vector<double> coords;
244 static constexpr ComponentId_t
null_id = std::numeric_limits<ComponentId_t>::max();
246 inline const ComponentId_t& key()
const {
return id; }
249 void print(std::ostream& os)
const;
253 void setConfigGraphPointer(
ConfigGraph* graph_ptr);
259 enabledAllStats(false),
264 StatisticId_t getNextStatisticID();
267 std::string getFullName()
const;
270 void setWeight(
double w);
271 void setCoordinates(
const std::vector<double>& c);
272 void addParameter(
const std::string& key,
const std::string& value,
bool overwrite);
281 enableStatistic(
const std::string& statisticName,
const SST::Params&
params,
bool recursively =
false);
283 bool reuseStatistic(
const std::string& statisticName, StatisticId_t sid);
284 void addStatisticParameter(
285 const std::string& statisticName,
const std::string& param,
const std::string& value,
bool recursively =
false);
286 void setStatisticParameters(
const std::string& statisticName,
const Params&
params,
bool recursively =
false);
287 void setStatisticLoadLevel(uint8_t level,
bool recursively =
false);
294 std::vector<LinkId_t> allLinks()
const;
298 std::vector<LinkId_t> clearAllLinks();
311 ser& enabledStatNames;
312 ser& enabledAllStats;
314 ser& enabledAllStats;
326 std::map<StatisticId_t, ConfigStatistic> statistics;
328 ComponentId_t getNextSubComponentID();
346 enabledAllStats(false),
350 coords.resize(3, 0.0);
364 enabledAllStats(false),
368 coords.resize(3, 0.0);
378typedef std::map<std::string, ComponentId_t> ConfigComponentNameMap_t;
380typedef std::map<std::string, Params*> ParamsMap_t;
382typedef std::map<std::string, std::string> VariableMap_t;
395 os <<
"Printing graph" << std::endl;
396 for ( ConfigComponentMap_t::const_iterator i = comps.
begin(); i != comps.
end(); ++i ) {
406 statLoadLevel = STATISTICSDEFAULTLOADLEVEL;
407 statOutputs.emplace_back(STATISTICSDEFAULTOUTPUTNAME);
409 Output& o = Output::getDefaultObject();
413 size_t getNumComponents() {
return comps.data.size(); }
415 size_t getNumComponentsInMPIRank(uint32_t rank);
426 ComponentId_t
addComponent(
const std::string& name,
const std::string& type);
429 void addGlobalParam(
const std::string& global_set,
const std::string& key,
const std::string& value);
443 std::vector<ConfigStatOutput>& getStatOutputs() {
return statOutputs; }
445 const ConfigStatOutput& getStatOutput(
size_t index = 0)
const {
return statOutputs[index]; }
447 long getStatLoadLevel()
const {
return statLoadLevel; }
451 ComponentId_t comp_id,
const std::string& link_name,
const std::string& port,
const std::string& latency_str,
452 bool no_cut =
false);
467 const std::map<std::string, ConfigStatGroup>& getStatGroups()
const {
return statGroups; }
470 auto found = statGroups.find(name);
471 if ( found == statGroups.end() ) {
473 std::tie(found, ok) = statGroups.emplace(name, name);
475 return &(found->second);
478 bool containsComponent(ComponentId_t
id)
const;
483 bool containsStatistic(StatisticId_t
id)
const;
489 ConfigGraph* getSubGraph(uint32_t start_rank, uint32_t end_rank);
490 ConfigGraph* getSubGraph(
const std::set<uint32_t>& rank_set);
492 ConfigGraph* splitGraph(
const std::set<uint32_t>& orig_rank_set,
const std::set<uint32_t>& new_rank_set);
497 void getConnectedNoCutComps(ComponentId_t start, std::set<ComponentId_t>& group);
499 void setComponentConfigGraphPointers();
507 if ( ser.mode() == SST::Core::Serialization::serializer::UNPACK ) {
510 setComponentConfigGraphPointers();
516 friend class SSTSDLModelDefinition;
520 ComponentId_t nextComponentId;
524 ConfigComponentNameMap_t compsByName;
525 std::map<std::string, ConfigStatGroup> statGroups;
527 std::map<std::string, LinkId_t> link_names;
529 std::vector<ConfigStatOutput> statOutputs;
530 uint8_t statLoadLevel;
539 const std::set<uint32_t>& oset;
540 const std::set<uint32_t>& nset;
545 const std::set<uint32_t>& new_rank_set);
574 inline ComponentId_t key()
const {
return id; }
581 ComponentId_t component[2];
582 SimTime_t latency[2];
595 inline LinkId_t key()
const {
return id; }
600 if ( latency[0] < latency[1] )
return latency[0];
607 os <<
" Link " <<
id << std::endl;
608 os <<
" component[0] = " << component[0] << std::endl;
609 os <<
" latency[0] = " << latency[0] << std::endl;
610 os <<
" component[1] = " << component[1] << std::endl;
611 os <<
" latency[1] = " << latency[1] << std::endl;
628 os <<
"Printing graph" << std::endl;
629 for ( PartitionComponentMap_t::const_iterator i = comps.
begin(); i != comps.
end(); ++i ) {
630 (*i)->print(os,
this);
637 const PartitionLink& getLink(LinkId_t
id)
const {
return links[id]; }
639 size_t getNumComponents() {
return comps.
size(); }
Definition: componentInfo.h:40
Represents the configuration of a generic component.
Definition: configGraph.h:218
static constexpr ComponentId_t null_id
Definition: configGraph.h:244
float weight
Definition: configGraph.h:227
std::vector< LinkId_t > links
Definition: configGraph.h:229
std::vector< ConfigComponent * > subComponents
Definition: configGraph.h:238
int slot_num
Definition: configGraph.h:225
std::string name
Definition: configGraph.h:224
uint16_t nextSubID
Definition: configGraph.h:240
std::string type
Definition: configGraph.h:226
uint16_t nextStatID
Definition: configGraph.h:241
ComponentId_t id
Definition: configGraph.h:222
void print(std::ostream &os) const
Print Component information.
Definition: configGraph.cc:171
Params params
Definition: configGraph.h:230
ConfigGraph * graph
Definition: configGraph.h:223
ConfigComponent(ComponentId_t id, ConfigGraph *graph, const std::string &name, const std::string &type, float weight, RankInfo rank)
Create a new Component.
Definition: configGraph.h:336
void checkPorts() const
Checks to make sure port names are valid and that a port isn't used twice.
Definition: configGraph.cc:623
uint8_t statLoadLevel
Definition: configGraph.h:231
RankInfo rank
Definition: configGraph.h:228
A Configuration Graph A graph representing Components and Links.
Definition: configGraph.h:390
void setStatisticLoadLevel(uint8_t loadLevel)
Set the statistic system load level.
Definition: configGraph.cc:802
ComponentId_t addComponent(const std::string &name, const std::string &type)
Create a new component.
Definition: configGraph.cc:763
void setLinkNoCut(const std::string &link_name)
Set a Link to be no-cut.
Definition: configGraph.cc:853
ConfigComponentMap_t & getComponentMap()
Return the map of components.
Definition: configGraph.h:465
bool checkForStructuralErrors()
Check the graph for Structural errors.
Definition: configGraph.cc:725
void postCreationCleanup()
Perform any post-creation cleanup processes.
Definition: configGraph.cc:707
void addGlobalParam(const std::string &global_set, const std::string &key, const std::string &value)
Add a parameter to a global param set.
Definition: configGraph.cc:778
bool checkRanks(RankInfo ranks)
Verify that all components have valid Ranks assigned.
Definition: configGraph.cc:695
bool containsComponentInRank(RankInfo rank)
Checks to see if rank contains at least one component.
Definition: configGraph.cc:686
void setStatisticOutputParams(const Params &p)
Set a set of parameter to the statistic output module.
Definition: configGraph.cc:790
void addStatisticOutputParameter(const std::string ¶m, const std::string &value)
Add parameter to the statistic output module.
Definition: configGraph.cc:796
void addLink(ComponentId_t comp_id, const std::string &link_name, const std::string &port, const std::string &latency_str, bool no_cut=false)
Add a Link to a Component on a given Port.
Definition: configGraph.cc:808
ConfigLinkMap_t & getLinkMap()
Return the map of links.
Definition: configGraph.h:487
void setComponentRanks(RankInfo rank)
Helper function to set all the ranks to the same value.
Definition: configGraph.cc:678
void print(std::ostream &os) const
Print the configuration graph.
Definition: configGraph.h:393
void setStatisticOutput(const std::string &name)
Set the statistic output module.
Definition: configGraph.cc:784
Represents the configuration of a generic Link.
Definition: configGraph.h:46
std::string port[2]
Definition: configGraph.h:51
std::string latency_str[2]
Definition: configGraph.h:53
std::string name
Definition: configGraph.h:49
SimTime_t latency[2]
Definition: configGraph.h:52
LinkId_t id
Definition: configGraph.h:48
ComponentId_t component[2]
Definition: configGraph.h:50
bool no_cut
Definition: configGraph.h:57
LinkId_t order
Definition: configGraph.h:55
SimTime_t getMinLatency() const
Return the minimum latency of this link (from both sides)
Definition: configGraph.h:63
void print(std::ostream &os) const
Print the Link information.
Definition: configGraph.h:70
Definition: configGraph.h:159
std::pair< bool, std::string > verifyStatsAndComponents(const ConfigGraph *graph)
Checks to make sure that all components in the group support all of the statistics as configured in t...
Definition: configGraph.cc:146
Definition: configGraph.h:195
Definition: configGraph.h:126
StatisticId_t id
Definition: configGraph.h:128
Class to contain SST Simulation Configuration variables.
Definition: config.h:30
Definition: serializable.h:119
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:35
Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file.
Definition: output.h:52
uint32_t getVerboseLevel() const
Returns object verbose level.
Definition: output.cc:109
std::string getPrefix() const
Returns object prefix.
Definition: output.cc:133
@ STDERR
Definition: output.h:59
void init(const std::string &prefix, uint32_t verbose_level, uint32_t verbose_mask, output_location_t location, const std::string &localoutputfilename="")
Initialize the object after construction.
Definition: output.cc:72
uint32_t getVerboseMask() const
Returns object verbose mask.
Definition: output.cc:121
Parameter store.
Definition: params.h:56
void addGlobalParamSet(const std::string &set)
Adds a global param set to be looked at in this Params object if the key isn't found locally.
Definition: params.cc:284
std::vector< std::string > getSubscribedGlobalParamSets() const
Get a vector of the global param sets this Params object is subscribed to.
Definition: params.cc:433
std::vector< std::string > getLocalKeys() const
Get a vector of the local keys.
Definition: params.cc:421
void insert(const std::string &key, const std::string &value, bool overwrite=true)
Add a key/value pair into the param object.
Definition: params.cc:140
Definition: configGraph.h:553
Definition: configGraph.h:619
void print(std::ostream &os) const
Print the configuration graph.
Definition: configGraph.h:626
Definition: configGraph.h:578
SimTime_t getMinLatency() const
Return the minimum latency of this link (from both sides)
Definition: configGraph.h:598
void print(std::ostream &os) const
Print the Link information.
Definition: configGraph.h:605
Definition: rankInfo.h:22
Main control class for a SST Simulation.
Definition: simulation_impl.h:77
Class that stores data in a vector, but can access the data similar to a map.
Definition: sparseVectorMap.h:44
iterator end()
Returns the end iterator to the underlying vector.
Definition: sparseVectorMap.h:188
iterator begin()
Returns the begin iterator to the underlying vector.
Definition: sparseVectorMap.h:181
void clear()
Clears the contents of the SparseVectorMap.
Definition: sparseVectorMap.h:259
size_t size()
Returns the number of items in the SparseVectorMap.
Definition: sparseVectorMap.h:266
Class for creating and managing TimeConverter objects.
Definition: timeLord.h:38
Performs Unit math in full precision.
Definition: unitAlgebra.h:109