14#ifndef SST_CORE_MODEL_CONFIGGRAPH_H
15#define SST_CORE_MODEL_CONFIGGRAPH_H
17#include "sst/core/model/configComponent.h"
18#include "sst/core/model/configLink.h"
19#include "sst/core/model/configStatistic.h"
20#include "sst/core/params.h"
21#include "sst/core/rankInfo.h"
22#include "sst/core/serialization/serializable.h"
23#include "sst/core/sparseVectorMap.h"
24#include "sst/core/sst_types.h"
25#include "sst/core/statapi/statbase.h"
26#include "sst/core/statapi/statoutput.h"
27#include "sst/core/timeConverter.h"
28#include "sst/core/unitAlgebra.h"
40using namespace SST::Statistics;
52using LinkIdMap_t = std::vector<LinkId_t>;
63using ConfigComponentNameMap_t = std::map<std::string, ComponentId_t>;
65using ParamsMap_t = std::map<std::string, Params*>;
67using VariableMap_t = std::map<std::string, std::string>;
79 static bool serialize_for_checkpoint;
82 void print(std::ostream& os)
const
84 os <<
"Printing graph" << std::endl;
85 os <<
"Components:" << std::endl;
86 for ( ConfigComponentMap_t::const_iterator i = comps_.begin(); i != comps_.end(); ++i ) {
89 os <<
"Links:" << std::endl;
90 for (
auto i = links_.begin(); i != links_.end(); ++i ) {
98 size_t getNumComponents() {
return comps_.data.size(); }
100 size_t getNumComponentsInMPIRank(uint32_t rank);
111 ComponentId_t
addComponent(
const std::string& name,
const std::string& type);
114 void addSharedParam(
const std::string& shared_set,
const std::string& key,
const std::string& value);
116 [[deprecated(
"addGlobalParam() has been deprecated and will be removed in SST 16. Please use addSharedParam()")]]
117 void addGlobalParam(
const std::string& shared_set,
const std::string& key,
const std::string& value);
131 std::vector<ConfigStatOutput>& getStatOutputs();
135 long getStatLoadLevel()
const;
141 LinkId_t
createLink(
const char* name,
const char* latency =
nullptr);
144 void addLink(ComponentId_t comp_id, LinkId_t link_id,
const char* port,
const char* latency_str);
164 void getNonLocalLinks(std::vector<ConfigLink*>& vec);
166 void updateLinkId(
ConfigLink* link, LinkId_t new_id);
167 void resortLinkMap();
169 const std::map<std::string, ConfigStatGroup>& getStatGroups()
const;
172 bool containsComponent(ComponentId_t
id)
const;
182 ConfigGraph* splitGraph(
const std::set<uint32_t>& orig_rank_set,
const std::set<uint32_t>& new_rank_set);
183 void reduceGraphToSingleRank(uint32_t rank);
185 SimTime_t getMinimumPartitionLatency();
190 void getConnectedNoCutComps(ComponentId_t start, std::set<ComponentId_t>& group);
191 StatsConfig* getStatsConfig() {
return stats_config_; }
194 auto* ret = stats_config_;
195 stats_config_ =
nullptr;
199 void annotateCompRestartLocation(ComponentId_t cid,
const std::string& filename, uint64_t offset);
201 void setComponentConfigGraphPointers();
202 void serialize_order(SST::Core::Serialization::serializer& ser)
override
207 if ( ser.mode() == SST::Core::Serialization::serializer::UNPACK ) {
210 setComponentConfigGraphPointers();
214 if ( serialize_for_checkpoint )
return;
216 SST_SER(stats_config_);
219 SST_SER(cpt_currentSimCycle);
220 SST_SER(cpt_currentPriority);
221 SST_SER(cpt_minPart);
222 SST_SER(cpt_minPartTC);
223 SST_SER(cpt_max_event_id);
224 SST_SER(cpt_remap_partitions);
225 SST_SER(cpt_repartition);
227 SST_SER(*(cpt_libnames.get()));
228 SST_SER(*(cpt_shared_objects.get()));
229 SST_SER(*(cpt_stats_config.get()));
232 void restoreRestartData();
236 SimTime_t cpt_currentSimCycle = 0;
237 int cpt_currentPriority = 0;
238 SimTime_t cpt_minPart = std::numeric_limits<SimTime_t>::max();
239 TimeConverter cpt_minPartTC;
240 uint64_t cpt_max_event_id = 0;
241 bool cpt_remap_partitions =
false;
242 bool cpt_repartition =
false;
243 std::string cpt_orig_configgraph;
245 std::shared_ptr<std::set<std::string>> cpt_libnames = std::make_shared<std::set<std::string>>();
246 std::shared_ptr<std::vector<char>> cpt_shared_objects = std::make_shared<std::vector<char>>();
247 std::shared_ptr<std::vector<char>> cpt_stats_config = std::make_shared<std::vector<char>>();
253 friend class Simulation;
256 LinkId_t link_rank_mask = 0;
258 ComponentId_t nextComponentId;
260 ConfigLinkMap_t links_;
261 ConfigComponentMap_t comps_;
262 ConfigComponentNameMap_t comps_by_name_;
264 std::map<std::string, LinkId_t> link_names_;
266 StatsConfig* stats_config_;
268 ImplementSerializable(SST::ConfigGraph)
273 ConfigGraph* ograph_;
274 ConfigGraph* ngraph_;
275 const std::set<uint32_t>& oset_;
276 const std::set<uint32_t>& nset_;
279 GraphFilter(ConfigGraph* original_graph, ConfigGraph* new_graph,
const std::set<uint32_t>& original_rank_set,
280 const std::set<uint32_t>& new_rank_set);
282 ConfigLink* operator()(ConfigLink* link);
283 ConfigComponent* operator()(ConfigComponent* comp);
287class PartitionComponent
295 ComponentIdMap_t group;
304 explicit PartitionComponent(LinkId_t
id) :
307 rank(
RankInfo(RankInfo::UNASSIGNED, 0))
313 inline ComponentId_t key()
const {
return id; }
322 PartitionComponentMap_t comps_;
323 PartitionLinkMap_t links_;
329 os <<
"Printing graph" << std::endl;
330 for ( PartitionComponentMap_t::const_iterator i = comps_.begin(); i != comps_.end(); ++i ) {
331 (*i)->print(os,
this);
335 PartitionComponentMap_t& getComponentMap() {
return comps_; }
336 PartitionLinkMap_t& getLinkMap() {
return links_; }
338 const PartitionLink& getLink(LinkId_t
id)
const {
return links_[id]; }
340 size_t getNumComponents() {
return comps_.
size(); }
Represents the configuration of a generic component.
Definition configComponent.h:83
float weight
Definition configComponent.h:92
ComponentId_t id
Definition configComponent.h:87
RankInfo rank
Definition configComponent.h:93
A Configuration Graph A graph representing Components and Links.
Definition configGraph.h:76
void setStatisticLoadLevel(uint8_t loadLevel)
Set the statistic system load level.
Definition configGraph.cc:359
ComponentId_t addComponent(const std::string &name, const std::string &type)
Create a new component.
Definition configGraph.cc:320
void addNonLocalLink(LinkId_t link_id, int rank, int thread)
Adds the remote rank info for nonlocal links.
Definition configGraph.cc:415
ConfigComponentMap_t & getComponentMap()
Return the map of components.
Definition configGraph.h:162
void setLinkNoCut(LinkId_t link_name)
Set a Link to be no-cut.
Definition configGraph.cc:450
bool checkForStructuralErrors()
Check the graph for Structural errors.
Definition configGraph.cc:238
void postCreationCleanup()
Perform any post-creation cleanup processes.
Definition configGraph.cc:202
void addSharedParam(const std::string &shared_set, const std::string &key, const std::string &value)
Add a parameter to a shared param set.
Definition configGraph.cc:335
bool checkRanks(RankInfo ranks)
Verify that all components have valid Ranks assigned.
Definition configGraph.cc:167
bool containsComponentInRank(RankInfo rank)
Checks to see if rank contains at least one component.
Definition configGraph.cc:158
void setStatisticOutputParams(const Params &p)
Set a set of parameter to the statistic output module.
Definition configGraph.cc:347
LinkId_t createLink(const char *name, const char *latency=nullptr)
Create link and return it's ID.
Definition configGraph.cc:435
void addStatisticOutputParameter(const std::string ¶m, const std::string &value)
Add parameter to the statistic output module.
Definition configGraph.cc:353
void addLink(ComponentId_t comp_id, LinkId_t link_id, const char *port, const char *latency_str)
Add a Link to a Component on a given Port.
Definition configGraph.cc:365
ConfigLinkMap_t & getLinkMap()
Return the map of links.
Definition configGraph.h:180
void setComponentRanks(RankInfo rank)
Helper function to set all the ranks to the same value.
Definition configGraph.cc:150
void print(std::ostream &os) const
Print the configuration graph.
Definition configGraph.h:82
void setStatisticOutput(const std::string &name)
Set the statistic output module.
Definition configGraph.cc:341
Represents the configuration of a generic Link.
Definition configLink.h:37
Definition configStatistic.h:82
Definition configStatistic.h:121
Definition configStatistic.h:41
Class to contain SST Simulation Configuration variables.
Definition config.h:52
Definition serializable.h:25
Parameter store.
Definition params.h:65
Definition configGraph.h:320
void print(std::ostream &os) const
Print the configuration graph.
Definition configGraph.h:327
Main control class for a SST Simulation.
Definition simulation.h:121
Class that stores data in a vector, but can access the data similar to a map.
Definition sparseVectorMap.h:47
size_t size()
Returns the number of items in the SparseVectorMap.
Definition sparseVectorMap.h:278
Class for creating and managing TimeConverter objects.
Definition timeLord.h:41
Definition configStatistic.h:143