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/timeConverter.h" 25 #include "sst/core/unitAlgebra.h" 42 class Simulation_impl;
48 using ComponentIdMap_t = SparseVectorMap<ComponentId_t>;
49 using LinkIdMap_t = std::vector<LinkId_t>;
57 static std::map<std::string, uint32_t> lat_to_index;
59 static uint32_t getIndexForLatency(
const char* latency);
60 static std::vector<SimTime_t> initializeLinkLatencyVector();
61 SimTime_t getLatencyFromIndex(uint32_t index);
70 ComponentId_t component[2] = { 0, 0 };
93 SimTime_t latency[2] = { 0, 0 };
145 bool nonlocal =
false;
150 bool cross_rank =
false;
155 bool cross_thread =
false;
157 inline LinkId_t key()
const {
return id; }
162 if ( nonlocal )
return latency[0];
163 if ( latency[0] < latency[1] )
return latency[0];
167 std::string latency_str(uint32_t index)
const;
178 void setAsNonLocal(
int which_local,
RankInfo remote_rank_info);
183 os <<
"Link " << name <<
" (id = " <<
id <<
")" << std::endl;
184 os <<
" nonlocal = " << nonlocal << std::endl;
185 os <<
" component[0] = " << component[0] << std::endl;
186 os <<
" port[0] = " << port[0] << std::endl;
187 os <<
" latency[0] = " << latency[0] << std::endl;
188 os <<
" component[1] = " << component[1] << std::endl;
189 os <<
" port[1] = " << port[1] << std::endl;
190 os <<
" latency[1] = " << latency[1] << std::endl;
200 SST_SER(component[0]);
201 SST_SER(component[1]);
210 SST_SER(cross_thread);
214 friend class ConfigGraph;
215 explicit ConfigLink(LinkId_t
id) :
222 component[0] = ULONG_MAX;
223 component[1] = ULONG_MAX;
226 ConfigLink(LinkId_t
id,
const std::string& n) :
234 component[0] = ULONG_MAX;
235 component[1] = ULONG_MAX;
238 void updateLatencies();
249 ConfigStatistic(StatisticId_t _id,
bool _shared =
false, std::string _name =
"") :
259 ConfigStatistic(
const ConfigStatistic&) =
default;
260 ConfigStatistic(ConfigStatistic&&) =
default;
261 ConfigStatistic& operator=(
const ConfigStatistic&) =
default;
262 ConfigStatistic& operator=(ConfigStatistic&&) =
default;
263 ~ConfigStatistic()
override =
default;
265 inline const StatisticId_t& getId()
const {
return id; }
267 void addParameter(
const std::string& key,
const std::string& value,
bool overwrite);
277 ImplementSerializable(ConfigStatistic)
279 static constexpr StatisticId_t stat_null_id = std::numeric_limits<StatisticId_t>::max();
286 std::map<std::string, Params> statMap;
287 std::vector<ComponentId_t> components;
297 bool addComponent(ComponentId_t
id);
298 bool addStatistic(
const std::string& name,
Params& p);
299 bool setOutput(
size_t id);
300 bool setFrequency(
const std::string& freq);
307 std::pair<bool, std::string> verifyStatsAndComponents(
const ConfigGraph* graph);
315 SST_SER(outputFrequency);
332 void addParameter(
const std::string& key,
const std::string& val) { params.
insert(key, val); }
353 uint8_t stat_load_level = STATISTICLOADLEVELUNINITIALIZED;
355 std::map<std::string, Params> per_stat_configs;
363 void addParameter(
const std::string& key,
const std::string& value);
364 void addSharedParamSet(
const std::string&
set);
365 void setStatisticLoadLevel(
const uint8_t level);
366 void enableAllStatistics(
const SST::Params& params);
367 void enableStatistic(
const std::string& statistic_name,
const SST::Params& params);
373 SST_SER(stat_load_level);
374 SST_SER(all_stat_config);
375 SST_SER(per_stat_configs);
397 std::map<std::string, std::vector<ConfigPortModule>>
399 std::map<std::string, StatisticId_t>
405 std::vector<double> coords;
410 static constexpr ComponentId_t null_id = std::numeric_limits<ComponentId_t>::max();
412 inline const ComponentId_t& key()
const {
return id; }
415 void print(std::ostream& os)
const;
419 void setConfigGraphPointer(
ConfigGraph* graph_ptr);
424 statLoadLevel(STATISTICLOADLEVELUNINITIALIZED),
425 enabledAllStats(false),
430 StatisticId_t getNextStatisticID();
432 ConfigComponent* getParent()
const;
433 std::string getFullName()
const;
435 void setRank(RankInfo r);
436 void setWeight(
double w);
437 void setCoordinates(
const std::vector<double>& c);
438 void addParameter(
const std::string& key,
const std::string& value,
bool overwrite);
439 ConfigComponent* addSubComponent(
const std::string& name,
const std::string& type,
int slot);
440 ConfigComponent* findSubComponent(ComponentId_t);
441 const ConfigComponent* findSubComponent(ComponentId_t)
const;
442 ConfigComponent* findSubComponentByName(
const std::string& name);
443 ConfigStatistic* findStatistic(
const std::string& name)
const;
444 ConfigStatistic* insertStatistic(StatisticId_t
id);
445 ConfigStatistic* findStatistic(StatisticId_t)
const;
446 ConfigStatistic* enableStatistic(
447 const std::string& statisticName,
const SST::Params& params,
bool recursively =
false);
448 ConfigStatistic* createStatistic();
449 bool reuseStatistic(
const std::string& statisticName, StatisticId_t sid);
450 void addStatisticParameter(
451 const std::string& statisticName,
const std::string& param,
const std::string& value,
bool recursively =
false);
452 void setStatisticParameters(
const std::string& statisticName,
const Params& params,
bool recursively =
false);
453 void setStatisticLoadLevel(uint8_t level,
bool recursively =
false);
455 void addSharedParamSet(
const std::string&
set) { params.addSharedParamSet(
set); }
457 "addGlobalParamSet() has been deprecated and will be removed in SST 16. Please use addSharedParamSet()")]]
458 void addGlobalParamSet(
const std::string&
set)
460 params.addSharedParamSet(
set);
462 std::vector<std::string> getParamsLocalKeys()
const {
return params.getLocalKeys(); }
463 std::vector<std::string> getSubscribedSharedParamSets()
const {
return params.getSubscribedSharedParamSets(); }
465 [[deprecated(
"getSubscribedGlobalParamSets() has been deprecated and will be removed in SST 16. Please use " 466 "getSubscribedSharedParamSets()")]]
467 std::vector<std::string> getSubscribedGlobalParamSets()
const 469 return params.getSubscribedSharedParamSets();
474 size_t addPortModule(
const std::string& port,
const std::string& type,
const Params& params);
476 std::vector<LinkId_t> allLinks()
const;
480 std::vector<LinkId_t> clearAllLinks();
490 SST_SER(rank.thread);
493 SST_SER(statLoadLevel);
494 SST_SER(port_modules);
495 SST_SER(enabledStatNames);
496 SST_SER(enabledAllStats);
497 SST_SER(statistics_);
498 SST_SER(allStatConfig);
499 SST_SER(subComponents);
508 std::map<StatisticId_t, ConfigStatistic>
511 ComponentId_t getNextSubComponentID();
513 friend class ConfigGraph;
516 void checkPorts()
const;
528 statLoadLevel(STATISTICLOADLEVELUNINITIALIZED),
529 enabledAllStats(false),
533 coords.resize(3, 0.0);
537 const std::string& type,
float weight,
RankInfo rank) :
545 statLoadLevel(STATISTICLOADLEVELUNINITIALIZED),
546 enabledAllStats(false),
547 nextSubID(parent_subid),
548 nextStatID(parent_subid)
550 coords.resize(3, 0.0);
558 using ConfigComponentMap_t = SparseVectorMap<ComponentId_t, ConfigComponent*>;
560 using ConfigComponentNameMap_t = std::map<std::string, ComponentId_t>;
562 using ParamsMap_t = std::map<std::string, Params*>;
564 using VariableMap_t = std::map<std::string, std::string>;
566 class PartitionGraph;
570 std::map<std::string, ConfigStatGroup> groups;
571 std::vector<ConfigStatOutput> outputs;
591 os <<
"Printing graph" << std::endl;
592 os <<
"Components:" << std::endl;
593 for ( ConfigComponentMap_t::const_iterator i = comps_.begin(); i != comps_.end(); ++i ) {
596 os <<
"Links:" << std::endl;
597 for (
auto i = links_.begin(); i != links_.end(); ++i ) {
609 stats_config_->load_level = STATISTICSDEFAULTLOADLEVEL;
610 stats_config_->outputs.emplace_back(STATISTICSDEFAULTOUTPUTNAME);
612 Output& o = Output::getDefaultObject();
618 for (
auto comp : comps_ ) {
622 if ( stats_config_ )
delete stats_config_;
625 size_t getNumComponents() {
return comps_.data.size(); }
627 size_t getNumComponentsInMPIRank(uint32_t rank);
630 void setComponentRanks(RankInfo rank);
632 bool containsComponentInRank(RankInfo rank);
634 bool checkRanks(RankInfo ranks);
638 ComponentId_t addComponent(
const std::string& name,
const std::string& type);
641 void addSharedParam(
const std::string& shared_set,
const std::string& key,
const std::string& value);
643 [[deprecated(
"addGlobalParam() has been deprecated and will be removed in SST 16. Please use addSharedParam()")]]
644 void addGlobalParam(
const std::string& shared_set,
const std::string& key,
const std::string& value);
647 void setStatisticOutput(
const std::string& name);
650 void addStatisticOutputParameter(
const std::string& param,
const std::string& value);
653 void setStatisticOutputParams(
const Params& p);
656 void setStatisticLoadLevel(uint8_t loadLevel);
658 std::vector<ConfigStatOutput>& getStatOutputs() {
return stats_config_->outputs; }
660 const ConfigStatOutput& getStatOutput(
size_t index = 0)
const {
return stats_config_->outputs[index]; }
662 long getStatLoadLevel()
const {
return stats_config_->load_level; }
668 LinkId_t createLink(
const char* name,
const char* latency =
nullptr);
671 void addLink(ComponentId_t comp_id, LinkId_t link_id,
const char* port,
const char* latency_str);
676 void addNonLocalLink(LinkId_t link_id,
int rank,
int thread);
679 void setLinkNoCut(LinkId_t link_name);
682 void postCreationCleanup();
685 bool checkForStructuralErrors();
691 const std::map<std::string, ConfigStatGroup>& getStatGroups()
const {
return stats_config_->groups; }
692 ConfigStatGroup* getStatGroup(
const std::string& name)
694 auto found = stats_config_->groups.find(name);
695 if ( found == stats_config_->groups.end() ) {
697 std::tie(found, ok) = stats_config_->groups.emplace(name, name);
699 return &(found->second);
702 bool containsComponent(ComponentId_t
id)
const;
703 ConfigComponent* findComponent(ComponentId_t);
704 ConfigComponent* findComponentByName(
const std::string& name);
705 const ConfigComponent* findComponent(ComponentId_t)
const;
707 ConfigStatistic* findStatistic(StatisticId_t)
const;
712 ConfigGraph* splitGraph(
const std::set<uint32_t>& orig_rank_set,
const std::set<uint32_t>& new_rank_set);
713 void reduceGraphToSingleRank(uint32_t rank);
715 SimTime_t getMinimumPartitionLatency();
720 void getConnectedNoCutComps(ComponentId_t start, std::set<ComponentId_t>& group);
721 StatsConfig* getStatsConfig() {
return stats_config_; }
722 StatsConfig* takeStatsConfig()
724 auto* ret = stats_config_;
725 stats_config_ =
nullptr;
729 void setComponentConfigGraphPointers();
734 SST_SER(stats_config_);
735 if ( ser.mode() == SST::Core::Serialization::serializer::UNPACK ) {
738 setComponentConfigGraphPointers();
742 SST_SER(cpt_currentSimCycle);
743 SST_SER(cpt_currentPriority);
744 SST_SER(cpt_minPart);
745 SST_SER(cpt_minPartTC);
746 SST_SER(cpt_max_event_id);
748 SST_SER(*(cpt_libnames.get()));
749 SST_SER(*(cpt_shared_objects.get()));
750 SST_SER(*(cpt_stats_config.get()));
753 void restoreRestartData();
757 SimTime_t cpt_currentSimCycle = 0;
758 int cpt_currentPriority = 0;
759 SimTime_t cpt_minPart = std::numeric_limits<SimTime_t>::max();
760 TimeConverter cpt_minPartTC;
761 uint64_t cpt_max_event_id = 0;
763 std::shared_ptr<std::set<std::string>> cpt_libnames = std::make_shared<std::set<std::string>>();
764 std::shared_ptr<std::vector<char>> cpt_shared_objects = std::make_shared<std::vector<char>>();
765 std::shared_ptr<std::vector<char>> cpt_stats_config = std::make_shared<std::vector<char>>();
771 friend class Simulation_impl;
772 friend class SSTSDLModelDefinition;
776 ComponentId_t nextComponentId;
778 ConfigLinkMap_t links_;
779 ConfigComponentMap_t comps_;
780 ConfigComponentNameMap_t comps_by_name_;
782 std::map<std::string, LinkId_t> link_names_;
784 StatsConfig* stats_config_;
791 ConfigGraph* ograph_;
792 ConfigGraph* ngraph_;
793 const std::set<uint32_t>& oset_;
794 const std::set<uint32_t>& nset_;
797 GraphFilter(ConfigGraph* original_graph, ConfigGraph* new_graph,
const std::set<uint32_t>& original_rank_set,
798 const std::set<uint32_t>& new_rank_set);
800 ConfigLink* operator()(ConfigLink* link);
801 ConfigComponent* operator()(ConfigComponent* comp);
825 rank(
RankInfo(RankInfo::UNASSIGNED, 0))
831 inline ComponentId_t key()
const {
return id; }
838 ComponentId_t component[2];
839 SimTime_t latency[2];
852 inline LinkId_t key()
const {
return id; }
857 if ( latency[0] < latency[1] )
return latency[0];
864 os <<
" Link " <<
id << std::endl;
865 os <<
" component[0] = " << component[0] << std::endl;
866 os <<
" latency[0] = " << latency[0] << std::endl;
867 os <<
" component[1] = " << component[1] << std::endl;
868 os <<
" latency[1] = " << latency[1] << std::endl;
872 using PartitionComponentMap_t = SparseVectorMap<ComponentId_t, PartitionComponent*>;
873 using PartitionLinkMap_t = SparseVectorMap<LinkId_t, PartitionLink>;
885 os <<
"Printing graph" << std::endl;
886 for ( PartitionComponentMap_t::const_iterator i = comps_.
begin(); i != comps_.
end(); ++i ) {
887 (*i)->print(os,
this);
892 PartitionLinkMap_t& getLinkMap() {
return links_; }
894 const PartitionLink& getLink(LinkId_t
id)
const {
return links_[id]; }
896 size_t getNumComponents() {
return comps_.
size(); }
901 #endif // SST_CORE_CONFIGGRAPH_H Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file...
Definition: output.h:57
int slot_num
Definition: configGraph.h:389
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:42
std::map< std::string, StatisticId_t > enabledStatNames
Definition: configGraph.h:400
ConfigStatistic allStatConfig
Definition: configGraph.h:402
float weight
Definition: configGraph.h:391
StatisticId_t id
Definition: configGraph.h:244
ConfigComponentMap_t & getComponentMap()
Return the map of components.
Definition: configGraph.h:689
SimTime_t getMinLatency() const
Return the minimum latency of this link (from both sides)
Definition: configGraph.h:855
Represents the configuration of a generic component.
Definition: configGraph.h:381
Definition: configGraph.h:875
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:519
void print(std::ostream &os) const
Print the Link information.
Definition: configGraph.h:181
std::string type
Definition: configGraph.h:390
A Configuration Graph A graph representing Components and Links.
Definition: configGraph.h:585
LinkId_t id
id of the link.
Definition: configGraph.h:114
Definition: configGraph.h:834
bool no_cut
Whether or not this link is set to be no-cut.
Definition: configGraph.h:136
Definition: configGraph.h:568
Class that represents a PortModule in ConfigGraph.
Definition: configGraph.h:348
Definition: configGraph.h:241
bool enabledAllStats
Definition: configGraph.h:401
Definition: configGraph.h:805
iterator end()
Returns the end iterator to the underlying vector.
Definition: sparseVectorMap.h:198
RankInfo rank
Definition: configGraph.h:392
uint16_t nextSubID
Definition: configGraph.h:406
iterator begin()
Returns the begin iterator to the underlying vector.
Definition: sparseVectorMap.h:191
uint8_t statLoadLevel
Definition: configGraph.h:395
Definition: serializable.h:23
size_t size()
Returns the number of items in the SparseVectorMap.
Definition: sparseVectorMap.h:278
Represents the configuration of a generic Link.
Definition: configGraph.h:52
std::string name
Name of the link.
Definition: configGraph.h:108
ConfigLinkMap_t & getLinkMap()
Return the map of links.
Definition: configGraph.h:710
ComponentId_t id
Definition: configGraph.h:386
Params all_stat_config
Definition: configGraph.h:354
Definition: rankInfo.h:23
SimTime_t latency[2]
This is a dual purpose data member.
Definition: configGraph.h:93
SimTime_t getMinLatency() const
Return the minimum latency of this link (from both sides)
Definition: configGraph.h:160
void print(std::ostream &os) const
Print the configuration graph.
Definition: configGraph.h:589
Params params
Definition: configGraph.h:394
std::map< std::string, std::vector< ConfigPortModule > > port_modules
Definition: configGraph.h:398
uint16_t nextStatID
Definition: configGraph.h:407
std::vector< LinkId_t > links
Definition: configGraph.h:393
Parameter store.
Definition: params.h:63
Definition: configGraph.h:321
std::string name
Definition: configGraph.h:388
std::vector< ConfigComponent * > subComponents
Definition: configGraph.h:404
void print(std::ostream &os) const
Print the Link information.
Definition: configGraph.h:862
void print(std::ostream &os) const
Print the configuration graph.
Definition: configGraph.h:883
Definition: configGraph.h:282
Definition: componentInfo.h:44
uint32_t getVerboseLevel() const
Returns object verbose level.
Definition: output.cc:109
Definition: elementinfo.h:44
ConfigGraph * graph
Definition: configGraph.h:387
uint32_t getVerboseMask() const
Returns object verbose mask.
Definition: output.cc:121
ComponentId_t component[2]
Components that are connected to this link.
Definition: configGraph.h:70
Class that stores data in a vector, but can access the data similar to a map.
Definition: sparseVectorMap.h:46
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:171
Performs Unit math in full precision.
Definition: unitAlgebra.h:105
std::string getPrefix() const
Returns object prefix.
Definition: output.cc:133