SST  14.1.0
StructuralSimulationToolkit
simulation_impl.h
1 // -*- c++ -*-
2 
3 // Copyright 2009-2024 NTESS. Under the terms
4 // of Contract DE-NA0003525 with NTESS, the U.S.
5 // Government retains certain rights in this software.
6 //
7 // Copyright (c) 2009-2024, NTESS
8 // All rights reserved.
9 //
10 // This file is part of the SST software package. For license
11 // information, see the LICENSE file in the top level directory of the
12 // distribution.
13 
14 #ifndef SST_CORE_SIMULATION_IMPL_H
15 #define SST_CORE_SIMULATION_IMPL_H
16 
17 #include "sst/core/clock.h"
18 #include "sst/core/componentInfo.h"
19 #include "sst/core/oneshot.h"
20 #include "sst/core/output.h"
21 #include "sst/core/profile/profiletool.h"
22 #include "sst/core/rankInfo.h"
23 #include "sst/core/sst_types.h"
24 #include "sst/core/statapi/statengine.h"
25 #include "sst/core/unitAlgebra.h"
26 
27 #include <atomic>
28 #include <cstdio>
29 #include <iostream>
30 #include <signal.h>
31 #include <thread>
32 #include <unordered_map>
33 
34 /* Forward declare for Friendship */
35 extern int main(int argc, char** argv);
36 
37 namespace SST {
38 
39 #define _SIM_DBG(fmt, args...) __DBG(DBG_SIM, Sim, fmt, ##args)
40 #define STATALLFLAG "--ALLSTATS--"
41 
42 class Activity;
43 class CheckpointAction;
44 class Component;
45 class Config;
46 class ConfigGraph;
47 class Exit;
48 class Factory;
49 class InteractiveConsole;
50 class Link;
51 class LinkMap;
52 class Params;
53 class RealTimeManager;
54 class SimulatorHeartbeat;
55 class SyncBase;
56 class SyncManager;
57 class ThreadSync;
58 class TimeConverter;
59 class TimeLord;
60 class TimeVortex;
61 class UnitAlgebra;
62 
63 namespace Statistics {
64 class StatisticOutput;
65 class StatisticProcessingEngine;
66 } // namespace Statistics
67 
68 namespace Serialization {
69 class ObjectMap;
70 } // namespace Serialization
71 
72 /**
73  * Main control class for a SST Simulation.
74  * Provides base features for managing the simulation
75  */
77 {
78 
79 public:
80  SST::Core::Serialization::ObjectMap* getComponentObjectMap();
81 
82  /******** Public API inherited from Simulation ********/
83  /** Get the run mode of the simulation (e.g. init, run, both etc) */
84  SimulationRunMode getSimulationMode() const { return runMode; };
85 
86  /** Return the current simulation time as a cycle count*/
87  SimTime_t getCurrentSimCycle() const;
88 
89  /** Return the end simulation time as a cycle count*/
90  SimTime_t getEndSimCycle() const;
91 
92  /** Return the current priority */
93  int getCurrentPriority() const;
94 
95  /** Return the elapsed simulation time as a time */
97 
98  /** Return the end simulation time as a time */
99  UnitAlgebra getEndSimTime() const;
100 
101  /** Get this instance's parallel rank */
102  RankInfo getRank() const { return my_rank; }
103 
104  /** Get the number of parallel ranks in the simulation */
105  RankInfo getNumRanks() const { return num_ranks; }
106 
107  /**
108  Returns the output directory of the simulation
109  @return Directory in which simulation outputs are placed
110  */
111  std::string& getOutputDirectory() { return output_directory; }
112 
113  /** Signifies that a library is required for this simulation.
114  * @param name Name of the library
115  */
116  void requireLibrary(const std::string& name);
117 
118  /** Causes the current status of the simulation to be printed to stderr.
119  * @param fullStatus - if true, call printStatus() on all components as well
120  * as print the base Simulation's status
121  */
122  void printStatus(bool fullStatus);
123 
124  double getRunPhaseElapsedRealTime() const;
125  double getInitPhaseElapsedRealTime() const;
126  double getCompletePhaseElapsedRealTime() const;
127 
128  /******** End Public API from Simulation ********/
129 
130  typedef std::map<std::pair<SimTime_t, int>, Clock*> clockMap_t; /*!< Map of times to clocks */
131  typedef std::map<std::pair<SimTime_t, int>, OneShot*> oneShotMap_t; /*!< Map of times to OneShots */
132 
133  ~Simulation_impl();
134 
135  /********* Static Core-only Functions *********/
136 
137  /** Return a pointer to the singleton instance of the Simulation */
138  static Simulation_impl* getSimulation() { return instanceMap.at(std::this_thread::get_id()); }
139 
140  /** Return the TimeLord associated with this Simulation */
141  static TimeLord* getTimeLord(void) { return &timeLord; }
142 
143  /** Return the base simulation Output class instance */
144  static Output& getSimulationOutput() { return sim_output; }
145 
146  /** Create new simulation
147  * @param config - Configuration of the simulation
148  * @param my_rank - Parallel Rank of this simulation object
149  * @param num_ranks - How many Ranks are in the simulation
150  * @param restart - Whether this simulation is being restarted from a checkpoint (true) or not
151  */
152  static Simulation_impl* createSimulation(Config* config, RankInfo my_rank, RankInfo num_ranks, bool restart);
153 
154  /**
155  * Used to signify the end of simulation. Cleans up any existing Simulation Objects
156  */
157  static void shutdown();
158 
159  /** Sets an internal flag for signaling the simulation. Used by signal handler & thread 0. */
160  static void notifySignal();
161 
162  /** Insert an activity to fire at a specified time */
163  void insertActivity(SimTime_t time, Activity* ev);
164 
165  /** Return the exit event */
166  Exit* getExit() const { return m_exit; }
167 
168  /******** Core only API *************/
169 
170  /** Processes the ConfigGraph to pull out any need information
171  * about relationships among the threads
172  */
173  void processGraphInfo(ConfigGraph& graph, const RankInfo& myRank, SimTime_t min_part);
174 
175  int initializeStatisticEngine(ConfigGraph& graph);
176  int prepareLinks(ConfigGraph& graph, const RankInfo& myRank, SimTime_t min_part);
177  int performWireUp(ConfigGraph& graph, const RankInfo& myRank, SimTime_t min_part);
178  void exchangeLinkInfo();
179 
180  /** Setup external control actions (forced stops, signal handling */
181  void setupSimActions(Config* cfg, bool restart = false);
182 
183  /** Helper for signal string parsing */
184  bool parseSignalString(std::string& arg, std::string& name, Params& params);
185 
186  /** Perform the init() phase of simulation */
187  void initialize();
188 
189  /** Perform the complete() phase of simulation */
190  void complete();
191 
192  /** Perform the setup() and run phases of the simulation. */
193  void setup();
194 
195  void prepare_for_run();
196 
197  void run();
198 
199  void finish();
200 
201  /** Adjust clocks and time to reflect precise simulation end time which
202  may differ in parallel simulations from the time simulation end is detected.
203  */
204  void adjustTimeAtSimEnd();
205 
206  bool isIndependentThread() { return independent; }
207 
208  void printProfilingInfo(FILE* fp);
209 
210  void printPerformanceInfo();
211 
212  /** Register a OneShot event to be called after a time delay
213  Note: OneShot cannot be canceled, and will always callback after
214  the timedelay.
215  */
216  TimeConverter* registerOneShot(const std::string& timeDelay, OneShot::HandlerBase* handler, int priority);
217 
218  TimeConverter* registerOneShot(const UnitAlgebra& timeDelay, OneShot::HandlerBase* handler, int priority);
219 
220  const std::vector<SimTime_t>& getInterThreadLatencies() const { return interThreadLatencies; }
221 
222  SimTime_t getInterThreadMinLatency() const { return interThreadMinLatency; }
223 
224  static TimeConverter* getMinPartTC() { return minPartTC; }
225 
226  LinkMap* getComponentLinkMap(ComponentId_t id) const
227  {
228  ComponentInfo* info = compInfoMap.getByID(id);
229  if ( nullptr == info ) { return nullptr; }
230  else {
231  return info->getLinkMap();
232  }
233  }
234 
235  /** Returns reference to the Component Info Map */
236  const ComponentInfoMap& getComponentInfoMap(void) { return compInfoMap; }
237 
238  /** returns the component with the given ID */
239  BaseComponent* getComponent(const ComponentId_t& id) const
240  {
241  ComponentInfo* i = compInfoMap.getByID(id);
242  // CompInfoMap_t::const_iterator i = compInfoMap.find(id);
243  if ( nullptr != i ) { return i->getComponent(); }
244  else {
245  printf("Simulation::getComponent() couldn't find component with id = %" PRIu64 "\n", id);
246  exit(1);
247  }
248  }
249 
250  /** returns the ComponentInfo object for the given ID */
251  ComponentInfo* getComponentInfo(const ComponentId_t& id) const
252  {
253  ComponentInfo* i = compInfoMap.getByID(id);
254  // CompInfoMap_t::const_iterator i = compInfoMap.find(id);
255  if ( nullptr != i ) { return i; }
256  else {
257  printf("Simulation::getComponentInfo() couldn't find component with id = %" PRIu64 "\n", id);
258  exit(1);
259  }
260  }
261 
262  /**
263  Set the output directory for this simulation
264  @param outDir Path of directory to place simulation outputs in
265  */
266  void setOutputDirectory(const std::string& outDir) { output_directory = outDir; }
267 
268  /**
269  * Gets the minimum next activity time across all TimeVortices in
270  * the Rank
271  */
272  static SimTime_t getLocalMinimumNextActivityTime();
273 
274  /**
275  * Returns true when the Wireup is finished.
276  */
277  bool isWireUpFinished() { return wireUpFinished_; }
278 
279  uint64_t getTimeVortexMaxDepth() const;
280 
281  uint64_t getTimeVortexCurrentDepth() const;
282 
283  uint64_t getSyncQueueDataSize() const;
284 
285  /** Return the checkpoint event */
286  CheckpointAction* getCheckpointAction() const { return checkpoint_action_; }
287 
288  /******** API provided through BaseComponent only ***********/
289 
290  /** Register a handler to be called on a set frequency */
291  TimeConverter* registerClock(const std::string& freq, Clock::HandlerBase* handler, int priority);
292 
293  TimeConverter* registerClock(const UnitAlgebra& freq, Clock::HandlerBase* handler, int priority);
294 
295  TimeConverter* registerClock(TimeConverter* tcFreq, Clock::HandlerBase* handler, int priority);
296 
297  // registerClock function used during checkpoint/restart
298  void registerClock(SimTime_t factor, Clock::HandlerBase* handler, int priority);
299 
300  /** Remove a clock handler from the list of active clock handlers */
301  void unregisterClock(TimeConverter* tc, Clock::HandlerBase* handler, int priority);
302 
303  /** Reactivate an existing clock and handler.
304  * @return time when handler will next fire
305  */
306  Cycle_t reregisterClock(TimeConverter* tc, Clock::HandlerBase* handler, int priority);
307 
308  /** Returns the next Cycle that the TImeConverter would fire. */
309  Cycle_t getNextClockCycle(TimeConverter* tc, int priority = CLOCKPRIORITY);
310 
311  /** Gets the clock the handler is registered with, represented by it's factor
312  *
313  * @param handler Clock handler to search for
314  *
315  * @return Factor of TimeConverter for the clock the specified
316  * handler is registered with. If the handler is not currently
317  * registered with a clock, returns 0.
318  */
319  SimTime_t getClockForHandler(Clock::HandlerBase* handler);
320 
321  /** Return the Statistic Processing Engine associated with this Simulation */
323 
324 
325  friend class Link;
326  friend class Action;
327  friend class Output;
328  // To enable main to set up globals
329  friend int ::main(int argc, char** argv);
330 
331  Simulation_impl() {}
332  Simulation_impl(Config* config, RankInfo my_rank, RankInfo num_ranks, bool restart);
333  Simulation_impl(Simulation_impl const&); // Don't Implement
334  void operator=(Simulation_impl const&); // Don't implement
335 
336  /** Get a handle to a TimeConverter
337  * @param cycles Frequency which is the base of the TimeConverter
338  */
339  TimeConverter* minPartToTC(SimTime_t cycles) const;
340 
341  std::string initializeCheckpointInfrastructure(const std::string& prefix);
342  void scheduleCheckpoint();
343 
344  /**
345  Write the partition specific checkpoint data
346  */
347  void checkpoint(const std::string& checkpoint_filename);
348 
349  /**
350  Append partitions registry information
351  */
352  void checkpoint_append_registry(const std::string& registry_name, const std::string& blob_name);
353 
354  /**
355  Write the global data to a binary file and create the registry
356  and write the header info
357  */
359  int checkpoint_id, const std::string& registry_filename, const std::string& globals_filename);
360  void restart(Config* config);
361 
362  void initialize_interactive_console(const std::string& type);
363 
364  /** Factory used to generate the simulation components */
365  static Factory* factory;
366 
367  static void resizeBarriers(uint32_t nthr);
368  static Core::ThreadSafe::Barrier initBarrier;
369  static Core::ThreadSafe::Barrier completeBarrier;
370  static Core::ThreadSafe::Barrier setupBarrier;
371  static Core::ThreadSafe::Barrier runBarrier;
372  static Core::ThreadSafe::Barrier exitBarrier;
373  static Core::ThreadSafe::Barrier finishBarrier;
374  static std::mutex simulationMutex;
375 
376  // Support for crossthread links
377  static Core::ThreadSafe::Spinlock cross_thread_lock;
378  static std::map<LinkId_t, Link*> cross_thread_links;
379  bool direct_interthread;
380 
381  Component* createComponent(ComponentId_t id, const std::string& name, Params& params);
382 
383  TimeVortex* getTimeVortex() const { return timeVortex; }
384 
385  /** Emergency Shutdown
386  * Called when a fatal event has occurred
387  */
388  static void emergencyShutdown();
389 
390  /** Signal Shutdown
391  * Called when a signal needs to terminate SST
392  * E.g., SIGINT or SIGTERM has been seen
393  * abnormal indicates whether this was unexpected or not
394  */
395  void signalShutdown(bool abnormal);
396 
397  /** Normal Shutdown
398  */
399  void endSimulation(void);
400  void endSimulation(SimTime_t end);
401 
402  typedef enum {
403  SHUTDOWN_CLEAN, /* Normal shutdown */
404  SHUTDOWN_SIGNAL, /* SIGINT or SIGTERM received */
405  SHUTDOWN_EMERGENCY, /* emergencyShutdown() called */
406  } ShutdownMode_t;
407 
408  friend class SyncManager;
409 
410  TimeVortex* timeVortex;
411  std::string timeVortexType; // Required for checkpoint
412  TimeConverter* threadMinPartTC; // Unused...?
413  Activity* current_activity;
414  static SimTime_t minPart;
415  static TimeConverter* minPartTC;
416  std::vector<SimTime_t> interThreadLatencies;
417  SimTime_t interThreadMinLatency;
418  SyncManager* syncManager;
419  // ThreadSync* threadSync;
420  ComponentInfoMap compInfoMap;
421  clockMap_t clockMap;
422  oneShotMap_t oneShotMap;
423  static Exit* m_exit;
424  SimulatorHeartbeat* m_heartbeat = nullptr;
425  CheckpointAction* checkpoint_action_;
426  static std::string checkpoint_directory_;
427  bool endSim;
428  bool independent; // true if no links leave thread (i.e. no syncs required)
429  static std::atomic<int> untimed_msg_count;
430  unsigned int untimed_phase;
431  volatile sig_atomic_t signal_arrived_; // true if a signal has arrived
432  ShutdownMode_t shutdown_mode_;
433  bool wireUpFinished_;
434  RealTimeManager* real_time_;
435  std::string interactive_type_ = "";
436  std::string interactive_start_ = "";
437  InteractiveConsole* interactive_ = nullptr;
438  bool enter_interactive_ = false;
439  std::string interactive_msg_;
440 
441  /**
442  vector to hold offsets of component blobs in checkpoint files
443  */
444  std::vector<std::pair<ComponentId_t, uint64_t>> component_blob_offsets_;
445 
446  /** TimeLord of the simulation */
448  /** Output */
450 
451 
452  /** Statistics Engine */
454 
455  /** Performance Tracking Information **/
456 
457  void initializeProfileTools(const std::string& config);
458 
459  std::map<std::string, SST::Profile::ProfileTool*> profile_tools;
460  // Maps the component profile points to profiler names
461  std::map<std::string, std::vector<std::string>> profiler_map;
462 
463  template <typename T>
464  std::vector<T*> getProfileTool(std::string point)
465  {
466  std::vector<T*> ret;
467  try {
468  std::vector<std::string>& profilers = profiler_map.at(point);
469 
470  for ( auto& x : profilers ) {
471  try {
472  SST::Profile::ProfileTool* val = profile_tools.at(x);
473 
474  T* tool = dynamic_cast<T*>(val);
475  if ( !tool ) {
476  // Not the right type, fatal
477  Output::getDefaultObject().fatal(
478  CALL_INFO_LONG, 1,
479  "ERROR: wrong type of profiling tool found (name = %s). Check to make sure the profiling "
480  "points enabled for this tool accept the type specified\n",
481  x.c_str());
482  }
483  ret.push_back(tool);
484  }
485  catch ( std::out_of_range& e ) {
486  // This shouldn't happen. If it does, then something
487  // didn't get initialized correctly.
488  Output::getDefaultObject().fatal(
489  CALL_INFO_LONG, 1,
490  "INTERNAL ERROR: ProfileTool refered to in profiler_map not found in profile_tools map\n");
491  return ret;
492  }
493  }
494  }
495  catch ( std::out_of_range& e ) {
496  // point not turned on, return nullptr
497  return ret;
498  }
499 
500 
501  return ret;
502  }
503 
504 
505 #if SST_PERFORMANCE_INSTRUMENTING
506  FILE* fp;
507 #endif
508 
509 #if SST_PERIODIC_PRINT
510  uint64_t periodicCounter = 0;
511 #endif
512 
513 #if SST_RUNTIME_PROFILING
514  uint64_t sumtime = 0;
515  uint64_t runtime = 0;
516  struct timeval start, end, diff;
517  struct timeval sumstart, sumend, sumdiff;
518 #endif
519 
520 
521 #if SST_EVENT_PROFILING
522  uint64_t rankLatency = 0; // Serialization time
523  uint64_t messageXferSize = 0;
524 
525  uint64_t rankExchangeBytes = 0; // Serialization size
526  uint64_t rankExchangeEvents = 0; // Serialized events
527  uint64_t rankExchangeCounter = 0; // Num rank peer exchanges
528 
529 
530  // Profiling functions
531  void incrementSerialCounters(uint64_t count);
532  void incrementExchangeCounters(uint64_t events, uint64_t bytes);
533 
534 #endif
535 
536 #if SST_SYNC_PROFILING
537  uint64_t rankSyncCounter = 0; // Num. of rank syncs
538  uint64_t rankSyncTime = 0; // Total time rank syncing, in ns
539  uint64_t threadSyncCounter = 0; // Num. of thread syncs
540  uint64_t threadSyncTime = 0; // Total time thread syncing, in ns
541  // Does not include thread syncs as part of rank syncs
542  void incrementSyncTime(bool rankSync, uint64_t count);
543 #endif
544 
545 #if SST_HIGH_RESOLUTION_CLOCK
546  uint64_t clockDivisor = 1e9;
547  std::string clockResolution = "ns";
548 #else
549  uint64_t clockDivisor = 1e6;
550  std::string clockResolution = "us";
551 #endif
552 
553  // Run mode for the simulation
554  SimulationRunMode runMode;
555 
556  // Track current simulated time
557  SimTime_t currentSimCycle;
558  int currentPriority;
559  SimTime_t endSimCycle;
560 
561  // Rank information
562  RankInfo my_rank;
563  RankInfo num_ranks;
564 
565  std::string output_directory;
566 
567  double run_phase_start_time_;
568  double run_phase_total_time_;
569  double init_phase_start_time_;
570  double init_phase_total_time_;
571  double complete_phase_start_time_;
572  double complete_phase_total_time_;
573 
574  static std::unordered_map<std::thread::id, Simulation_impl*> instanceMap;
575  static std::vector<Simulation_impl*> instanceVec_;
576 
577  /******** Checkpoint/restart tracking data structures ***********/
578  std::map<uintptr_t, Link*> link_restart_tracking;
579  std::map<uintptr_t, uintptr_t> event_handler_restart_tracking;
580  uint32_t checkpoint_id_ = 0;
581  std::string checkpoint_prefix_ = "";
582  std::string globalOutputFileName = "";
583 
584  void printSimulationState();
585 
586  friend void wait_my_turn_start();
587  friend void wait_my_turn_end();
588 
589 private:
590  /**
591  * Returns the time of the next item to be executed
592  * that is in the TImeVortex of the Simulation
593  */
594  SimTime_t getNextActivityTime() const;
595 };
596 
597 // Function to allow for easy serialization of threads while debugging
598 // code. Can only be used when you can guarantee all threads will be
599 // taking the same code path. If you can't guarantee that, then use a
600 // spinlock to make sure only one person is in a given region at a
601 // time. ONLY FOR DEBUG USE.
602 void wait_my_turn_start(Core::ThreadSafe::Barrier& barrier, int thread, int total_threads);
603 
604 void wait_my_turn_end(Core::ThreadSafe::Barrier& barrier, int thread, int total_threads);
605 
606 } // namespace SST
607 
608 #endif // SST_CORE_SIMULATION_IMPL_H
Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file...
Definition: output.h:53
void printStatus(bool fullStatus)
Causes the current status of the simulation to be printed to stderr.
Definition: simulation.cc:1047
An Action is a schedulable Activity which is not an Event.
Definition: action.h:26
Handlers with 1 handler defined argument to callback from caller.
Definition: ssthandler.h:210
RankInfo getNumRanks() const
Get the number of parallel ranks in the simulation.
Definition: simulation_impl.h:105
Base class for all Activities in the SST Event Queue.
Definition: activity.h:46
Class to contain SST Simulation Configuration variables.
Definition: config.h:38
TimeConverter * registerOneShot(const std::string &timeDelay, OneShot::HandlerBase *handler, int priority)
Register a OneShot event to be called after a time delay Note: OneShot cannot be canceled, and will always callback after the timedelay.
Definition: simulation.cc:1177
void insertActivity(SimTime_t time, Activity *ev)
Insert an activity to fire at a specified time.
Definition: simulation.cc:1203
A class to convert between a component&#39;s view of time and the core&#39;s view of time.
Definition: timeConverter.h:27
Main component object for the simulation.
Definition: component.h:30
A Configuration Graph A graph representing Components and Links.
Definition: configGraph.h:389
Primary Event Queue.
Definition: timeVortex.h:27
UnitAlgebra getElapsedSimTime() const
Return the elapsed simulation time as a time.
Definition: simulation.cc:82
static Output sim_output
Output.
Definition: simulation_impl.h:449
A recurring event to trigger checkpoint generation.
Definition: checkpointAction.h:60
CheckpointAction * getCheckpointAction() const
Return the checkpoint event.
Definition: simulation_impl.h:286
bool isWireUpFinished()
Returns true when the Wireup is finished.
Definition: simulation_impl.h:277
void setOutputDirectory(const std::string &outDir)
Set the output directory for this simulation
Definition: simulation_impl.h:266
static Output & getSimulationOutput()
Return the base simulation Output class instance.
Definition: simulation_impl.h:144
Definition: action.cc:18
static void notifySignal()
Sets an internal flag for signaling the simulation.
Definition: simulation.cc:1041
ProfileTool is a class loadable through the factory which allows dynamic addition of profiling capabi...
Definition: profiletool.h:29
void setup()
Perform the setup() and run phases of the simulation.
Definition: simulation.cc:748
SimTime_t getCurrentSimCycle() const
Return the current simulation time as a cycle count.
Definition: simulation.cc:64
const ComponentInfoMap & getComponentInfoMap(void)
Returns reference to the Component Info Map.
Definition: simulation_impl.h:236
SST::Statistics::StatisticProcessingEngine stat_engine
Statistics Engine.
Definition: simulation_impl.h:453
Class created by the serializer mapping mode used to map the variables for objects.
Definition: objectMap.h:61
void initialize()
Perform the init() phase of simulation.
Definition: simulation.cc:669
TimeConverter * minPartToTC(SimTime_t cycles) const
Get a handle to a TimeConverter.
Definition: simulation.cc:96
SSTHandlerBaseNoArgs< void > HandlerBase
Base handler for OneShot callbacks.
Definition: oneshot.h:38
SimTime_t getClockForHandler(Clock::HandlerBase *handler)
Gets the clock the handler is registered with, represented by it&#39;s factor.
Definition: simulation.cc:1157
Exit Event Action.
Definition: exit.h:34
Definition: componentInfo.h:285
RankInfo getRank() const
Get this instance&#39;s parallel rank.
Definition: simulation_impl.h:102
Exit * getExit() const
Return the exit event.
Definition: simulation_impl.h:166
A Clock class.
Definition: clock.h:32
BaseComponent * getComponent(const ComponentId_t &id) const
returns the component with the given ID
Definition: simulation_impl.h:239
Cycle_t reregisterClock(TimeConverter *tc, Clock::HandlerBase *handler, int priority)
Reactivate an existing clock and handler.
Definition: simulation.cc:1133
void initializeProfileTools(const std::string &config)
Performance Tracking Information.
Definition: simulation.cc:1304
UnitAlgebra getEndSimTime() const
Return the end simulation time as a time.
Definition: simulation.cc:88
static TimeLord * getTimeLord(void)
Return the TimeLord associated with this Simulation.
Definition: simulation_impl.h:141
std::map< std::pair< SimTime_t, int >, OneShot * > oneShotMap_t
Definition: simulation_impl.h:131
static SimTime_t getLocalMinimumNextActivityTime()
Gets the minimum next activity time across all TimeVortices in the Rank.
Definition: simulation.cc:383
SimTime_t getEndSimCycle() const
Return the end simulation time as a cycle count.
Definition: simulation.cc:70
void unregisterClock(TimeConverter *tc, Clock::HandlerBase *handler, int priority)
Remove a clock handler from the list of active clock handlers.
Definition: simulation.cc:1167
ComponentInfo * getComponentInfo(const ComponentId_t &id) const
returns the ComponentInfo object for the given ID
Definition: simulation_impl.h:251
Main control class for a SST Simulation.
Definition: simulation_impl.h:76
void signalShutdown(bool abnormal)
Signal Shutdown Called when a signal needs to terminate SST E.g., SIGINT or SIGTERM has been seen abn...
Definition: simulation.cc:969
Definition: rankInfo.h:21
Main component object for the simulation.
Definition: baseComponent.h:62
static Simulation_impl * getSimulation()
Return a pointer to the singleton instance of the Simulation.
Definition: simulation_impl.h:138
void complete()
Perform the complete() phase of simulation.
Definition: simulation.cc:713
static Factory * factory
Factory used to generate the simulation components.
Definition: simulation_impl.h:365
Definition: threadsafe.h:121
Cycle_t getNextClockCycle(TimeConverter *tc, int priority=CLOCKPRIORITY)
Returns the next Cycle that the TImeConverter would fire.
Definition: simulation.cc:1145
void setupSimActions(Config *cfg, bool restart=false)
Setup external control actions (forced stops, signal handling.
Definition: simulation.cc:246
A OneShot Event class.
Definition: oneshot.h:32
void checkpoint(const std::string &checkpoint_filename)
Write the partition specific checkpoint data.
Definition: simulation.cc:1592
void adjustTimeAtSimEnd()
Adjust clocks and time to reflect precise simulation end time which may differ in parallel simulation...
Definition: simulation.cc:1003
static void emergencyShutdown()
Emergency Shutdown Called when a fatal event has occurred.
Definition: simulation.cc:953
static TimeLord timeLord
TimeLord of the simulation.
Definition: simulation_impl.h:447
Parameter store.
Definition: params.h:55
void endSimulation(void)
Normal Shutdown.
Definition: simulation.cc:981
Class for creating and managing TimeConverter objects.
Definition: timeLord.h:37
Class for instantiating Components, Links and the like out of element libraries.
Definition: factory.h:43
SimulationRunMode getSimulationMode() const
Get the run mode of the simulation (e.g.
Definition: simulation_impl.h:84
std::string & getOutputDirectory()
Returns the output directory of the simulation
Definition: simulation_impl.h:111
TimeConverter * registerClock(const std::string &freq, Clock::HandlerBase *handler, int priority)
Register a handler to be called on a set frequency.
Definition: simulation.cc:1092
Definition: componentInfo.h:44
int getCurrentPriority() const
Return the current priority.
Definition: simulation.cc:76
Statistics::StatisticProcessingEngine * getStatisticsProcessingEngine(void)
Return the Statistic Processing Engine associated with this Simulation.
Definition: simulation.cc:1228
void processGraphInfo(ConfigGraph &graph, const RankInfo &myRank, SimTime_t min_part)
Processes the ConfigGraph to pull out any need information about relationships among the threads...
Definition: simulation.cc:394
void checkpoint_append_registry(const std::string &registry_name, const std::string &blob_name)
Append partitions registry information.
Definition: simulation.cc:1570
void requireLibrary(const std::string &name)
Signifies that a library is required for this simulation.
Definition: simulation.cc:371
An SST core component that handles timing and event processing informing all registered Statistics to...
Definition: statengine.h:52
std::map< std::pair< SimTime_t, int >, Clock * > clockMap_t
Definition: simulation_impl.h:130
void checkpoint_write_globals(int checkpoint_id, const std::string &registry_filename, const std::string &globals_filename)
Write the global data to a binary file and create the registry and write the header info...
Definition: simulation.cc:1484
bool parseSignalString(std::string &arg, std::string &name, Params &params)
Helper for signal string parsing.
Definition: simulation.cc:311
Performs Unit math in full precision.
Definition: unitAlgebra.h:106
std::vector< std::pair< ComponentId_t, uint64_t > > component_blob_offsets_
vector to hold offsets of component blobs in checkpoint files
Definition: simulation_impl.h:444
Definition: threadsafe.h:47
static void shutdown()
Used to signify the end of simulation.
Definition: simulation.cc:170
static Simulation_impl * createSimulation(Config *config, RankInfo my_rank, RankInfo num_ranks, bool restart)
Create new simulation.
Definition: simulation.cc:155