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