SST  10.1.0
StructuralSimulationToolkit
simulation.h
1 // -*- c++ -*-
2 
3 // Copyright 2009-2020 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-2020, 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_H
15 #define SST_CORE_SIMULATION_H
16 
17 
18 #include "sst/core/sst_types.h"
19 
20 #include <signal.h>
21 #include <atomic>
22 #include <iostream>
23 #include <thread>
24 
25 #include <unordered_map>
26 
27 #include "sst/core/output.h"
28 #include "sst/core/clock.h"
29 #include "sst/core/oneshot.h"
30 #include "sst/core/unitAlgebra.h"
31 #include "sst/core/rankInfo.h"
32 
33 #include "sst/core/componentInfo.h"
34 
35 /* Forward declare for Friendship */
36 extern int main(int argc, char **argv);
37 
38 
39 namespace SST {
40 
41 #define _SIM_DBG( fmt, args...) __DBG( DBG_SIM, Sim, fmt, ## args )
42 #define STATALLFLAG "--ALLSTATS--"
43 
44 class Activity;
45 class Component;
46 class Config;
47 class ConfigGraph;
48 class Exit;
49 class Factory;
50 class SimulatorHeartbeat;
51 //class Graph;
52 class LinkMap;
53 class Params;
54 class SyncBase;
55 class SyncManager;
56 class ThreadSync;
57 class TimeConverter;
58 class TimeLord;
59 class TimeVortex;
60 class UnitAlgebra;
61 class SharedRegionManager;
62 namespace Statistics {
63  class StatisticOutput;
64  class StatisticProcessingEngine;
65 }
66 
67 
68 
69 /**
70  * Main control class for a SST Simulation.
71  * Provides base features for managing the simulation
72  */
73 class Simulation {
74 public:
75  /** Type of Run Modes */
76  typedef enum {
77  UNKNOWN, /*!< Unknown mode - Invalid for running */
78  INIT, /*!< Initialize-only. Useful for debugging initialization and graph generation */
79  RUN, /*!< Run-only. Useful when restoring from a checkpoint */
80  BOTH /*!< Default. Both initialize and Run the simulation */
81  } Mode_t;
82 
83  typedef std::map<std::pair<SimTime_t, int>, Clock*> clockMap_t; /*!< Map of times to clocks */
84  typedef std::map<std::pair<SimTime_t, int>, OneShot*> oneShotMap_t; /*!< Map of times to OneShots */
85  // typedef std::map< unsigned int, Sync* > SyncMap_t; /*!< Map of times to Sync Objects */
86 
87  ~Simulation();
88 
89  /********* Static Core-only Functions *********/
90 
91  /** Create new simulation
92  * @param config - Configuration of the simulation
93  * @param my_rank - Parallel Rank of this simulation object
94  * @param num_ranks - How many Ranks are in the simulation
95  */
96 #if !SST_BUILDING_CORE
97  static Simulation *createSimulation(Config *config, RankInfo my_rank, RankInfo num_ranks, SimTime_t min_part) __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
98 #else
99  static Simulation *createSimulation(Config *config, RankInfo my_rank, RankInfo num_ranks, SimTime_t min_part);
100 #endif
101 
102  /**
103  * Used to signify the end of simulation. Cleans up any existing Simulation Objects
104  */
105 #if !SST_BUILDING_CORE
106  static void shutdown() __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
107 #else
108  static void shutdown();
109 #endif
110 
111  /** Sets an internal flag for signaling the simulation. Used internally */
112 #if !SST_BUILDING_CORE
113  static void setSignal(int signal) __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
114 #else
115  static void setSignal(int signal);
116 #endif
117 
118 
119  /********* Public Static API ************/
120 
121  /** Return a pointer to the singleton instance of the Simulation */
122  static Simulation *getSimulation() { return instanceMap.at(std::this_thread::get_id()); }
123 
124  /**
125  * Returns the Simulation's SharedRegionManager
126  */
127  static SharedRegionManager* getSharedRegionManager() { return sharedRegionManager; }
128 
129  /** Return the TimeLord associated with this Simulation */
130  static TimeLord* getTimeLord(void) { return &timeLord; }
131 
132  /** Return the base simulation Output class instance */
133  static Output& getSimulationOutput() { return sim_output; };
134 
135 
136 
137  /********* Public API ************/
138  /** Get the run mode of the simulation (e.g. init, run, both etc) */
139  Mode_t getSimulationMode() const { return runMode; };
140 
141  /** Return the current simulation time as a cycle count*/
142  const SimTime_t& getCurrentSimCycle() const;
143 
144  /** Return the end simulation time as a cycle count*/
145  SimTime_t getEndSimCycle() const;
146 
147  /** Return the current priority */
148  int getCurrentPriority() const;
149 
150  /** Return the elapsed simulation time as a time */
152 
153  /** Return the end simulation time as a time */
155 
156  /** Get this instance's parallel rank */
157  RankInfo getRank() const {return my_rank;}
158 
159  /** Get the number of parallel ranks in the simulation */
160  RankInfo getNumRanks() const {return num_ranks;}
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 
169  /** Signifies that an event type is required for this simulation
170  * Causes the Factory to verify that the required event type can be found.
171  * @param name fully qualified libraryName.EventName
172  */
173  void requireEvent(const std::string& name);
174 
175 
176  /** Causes the current status of the simulation to be printed to stderr.
177  * @param fullStatus - if true, call printStatus() on all components as well
178  * as print the base Simulation's status
179  */
180  void printStatus(bool fullStatus);
181 
182 
183  /******** Core only API *************/
184 
185  /** Processes the ConfigGraph to pull out any need information
186  * about relationships among the threads
187  */
188 #if !SST_BUILDING_CORE
189  void processGraphInfo( ConfigGraph& graph, const RankInfo &myRank, SimTime_t min_part ) __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
190 #else
191  void processGraphInfo( ConfigGraph& graph, const RankInfo &myRank, SimTime_t min_part );
192 #endif
193 
194  /** Converts a ConfigGraph graph into actual set of links and components */
195 #if !SST_BUILDING_CORE
196  int performWireUp( ConfigGraph& graph, const RankInfo &myRank, SimTime_t min_part ) __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
197 #else
198  int performWireUp( ConfigGraph& graph, const RankInfo &myRank, SimTime_t min_part );
199 #endif
200 
201  /** Set cycle count, which, if reached, will cause the simulation to halt. */
202 #if !SST_BUILDING_CORE
203  void setStopAtCycle( Config* cfg ) __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
204 #else
205  void setStopAtCycle( Config* cfg );
206 #endif
207 
208  /** Perform the init() phase of simulation */
209 #if !SST_BUILDING_CORE
210  void initialize() __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
211 #else
212  void initialize();
213 #endif
214 
215  /** Perform the complete() phase of simulation */
216 #if !SST_BUILDING_CORE
217  void complete() __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
218 #else
219  void complete();
220 #endif
221 
222  /** Perform the setup() and run phases of the simulation. */
223 #if !SST_BUILDING_CORE
224  void setup() __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
225 #else
226  void setup();
227 #endif
228 
229 #if !SST_BUILDING_CORE
230  void run() __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
231 #else
232  void run();
233 #endif
234 
235 #if !SST_BUILDING_CORE
236  void finish() __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
237 #else
238  void finish();
239 #endif
240 
241 #if !SST_BUILDING_CORE
242  bool isIndependentThread() __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11."))) { return independent;}
243 #else
244  bool isIndependentThread() { return independent;}
245 #endif
246 
247  /** Register a OneShot event to be called after a time delay
248  Note: OneShot cannot be canceled, and will always callback after
249  the timedelay.
250  */
251 #if !SST_BUILDING_CORE
252  TimeConverter* registerOneShot(const std::string& timeDelay, OneShot::HandlerBase* handler, int priority) __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
253 #else
254  TimeConverter* registerOneShot(const std::string& timeDelay, OneShot::HandlerBase* handler, int priority);
255 #endif
256 
257 #if !SST_BUILDING_CORE
258  TimeConverter* registerOneShot(const UnitAlgebra& timeDelay, OneShot::HandlerBase* handler, int priority) __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
259 #else
260  TimeConverter* registerOneShot(const UnitAlgebra& timeDelay, OneShot::HandlerBase* handler, int priority);
261 #endif
262 
263 #if !SST_BUILDING_CORE
264  const std::vector<SimTime_t>& getInterThreadLatencies() const __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11."))) { return interThreadLatencies; }
265 #else
266  const std::vector<SimTime_t>& getInterThreadLatencies() const { return interThreadLatencies; }
267 #endif
268 
269 #if !SST_BUILDING_CORE
270  SimTime_t getInterThreadMinLatency() const __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11."))) { return interThreadMinLatency; }
271 #else
272  SimTime_t getInterThreadMinLatency() const { return interThreadMinLatency; }
273 #endif
274 
275 #if !SST_BUILDING_CORE
276  static TimeConverter* getMinPartTC() __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11."))) { return minPartTC; }
277 #else
278  static TimeConverter* getMinPartTC() { return minPartTC; }
279 #endif
280 
281  /** Return pointer to map of links for a given component id */
282 #if !SST_BUILDING_CORE
283  LinkMap* getComponentLinkMap(ComponentId_t id) const __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11."))) {
284 #else
285  LinkMap* getComponentLinkMap(ComponentId_t id) const {
286 #endif
287  ComponentInfo* info = compInfoMap.getByID(id);
288  if ( nullptr == info ) {
289  return nullptr;
290  } else {
291  return info->getLinkMap();
292  }
293  }
294 
295  /** Returns reference to the Component Info Map */
296 #if !SST_BUILDING_CORE
297  const ComponentInfoMap& getComponentInfoMap(void) __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11."))) { return compInfoMap; }
298 #else
299  const ComponentInfoMap& getComponentInfoMap(void) { return compInfoMap; }
300 #endif
301 
302  /** returns the component with the given ID */
303 #if !SST_BUILDING_CORE
304  BaseComponent* getComponent(const ComponentId_t &id) const __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11."))) {
305 #else
306  BaseComponent* getComponent(const ComponentId_t &id) const {
307 #endif
308  ComponentInfo* i = compInfoMap.getByID(id);
309  // CompInfoMap_t::const_iterator i = compInfoMap.find(id);
310  if ( nullptr != i ) {
311  return i->getComponent();
312  } else {
313  printf("Simulation::getComponent() couldn't find component with id = %" PRIu64 "\n", id);
314  exit(1);
315  }
316  }
317 
318 
319  /** returns the ComponentInfo object for the given ID */
320 #if !SST_BUILDING_CORE
321  ComponentInfo* getComponentInfo(const ComponentId_t &id) const __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11."))) {
322 #else
323  ComponentInfo* getComponentInfo(const ComponentId_t &id) const {
324 #endif
325  ComponentInfo* i = compInfoMap.getByID(id);
326  // CompInfoMap_t::const_iterator i = compInfoMap.find(id);
327  if ( nullptr != i ) {
328  return i;
329  } else {
330  printf("Simulation::getComponentInfo() couldn't find component with id = %" PRIu64 "\n", id);
331  exit(1);
332  }
333  }
334 
335 
336  /**
337  Set the output directory for this simulation
338  @param outDir Path of directory to place simulation outputs in
339  */
340 #if !SST_BUILDING_CORE
341  void setOutputDirectory(const std::string& outDir) __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11."))) {
342 #else
343  void setOutputDirectory(const std::string& outDir) {
344 #endif
345  output_directory = outDir;
346  }
347 
348  /**
349  Returns the output directory of the simulation
350  @return Directory in which simulation outputs are placed
351  */
352 #if !SST_BUILDING_CORE
353  std::string& getOutputDirectory() __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11."))) {
354 #else
355  std::string& getOutputDirectory() {
356 #endif
357  return output_directory;
358  }
359 
360  /**
361  * Returns the time of the next item to be executed
362  * that is in the TImeVortex of the Simulation
363  */
364 #if !SST_BUILDING_CORE
365  SimTime_t getNextActivityTime() const __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
366 #else
367  SimTime_t getNextActivityTime() const;
368 #endif
369 
370  /**
371  * Gets the minimum next activity time across all TimeVortices in
372  * the Rank
373  */
374 #if !SST_BUILDING_CORE
375  static SimTime_t getLocalMinimumNextActivityTime() __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
376 #else
377  static SimTime_t getLocalMinimumNextActivityTime();
378 #endif
379 
380  /**
381  * Returns true when the Wireup is finished.
382  */
383 #if !SST_BUILDING_CORE
384  bool isWireUpFinished() __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11."))) {return wireUpFinished; }
385 #else
386  bool isWireUpFinished() {return wireUpFinished; }
387 #endif
388 
389 
390 
391 #if !SST_BUILDING_CORE
392  uint64_t getTimeVortexMaxDepth() const __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
393 #else
394  uint64_t getTimeVortexMaxDepth() const;
395 #endif
396 
397 #if !SST_BUILDING_CORE
398  uint64_t getTimeVortexCurrentDepth() const __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
399 #else
400  uint64_t getTimeVortexCurrentDepth() const;
401 #endif
402 
403 #if !SST_BUILDING_CORE
404  uint64_t getSyncQueueDataSize() const __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
405 #else
406  uint64_t getSyncQueueDataSize() const;
407 #endif
408 
409 
410  /******** API provided through BaseComponent only ***********/
411 
412 
413  /** Register a handler to be called on a set frequency */
414 #if !SST_BUILDING_CORE
415  TimeConverter* registerClock(const std::string& freq, Clock::HandlerBase* handler, int priority) __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
416 #else
417  TimeConverter* registerClock(const std::string& freq, Clock::HandlerBase* handler, int priority);
418 #endif
419 
420 #if !SST_BUILDING_CORE
421  TimeConverter* registerClock(const UnitAlgebra& freq, Clock::HandlerBase* handler, int priority) __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
422 #else
423  TimeConverter* registerClock(const UnitAlgebra& freq, Clock::HandlerBase* handler, int priority);
424 #endif
425 
426 #if !SST_BUILDING_CORE
427  TimeConverter* registerClock(TimeConverter *tcFreq, Clock::HandlerBase* handler, int priority) __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
428 #else
429  TimeConverter* registerClock(TimeConverter *tcFreq, Clock::HandlerBase* handler, int priority);
430 #endif
431 
432  /** Remove a clock handler from the list of active clock handlers */
433 #if !SST_BUILDING_CORE
434  void unregisterClock(TimeConverter *tc, Clock::HandlerBase* handler, int priority) __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
435 #else
436  void unregisterClock(TimeConverter *tc, Clock::HandlerBase* handler, int priority);
437 #endif
438 
439  /** Reactivate an existing clock and handler.
440  * @return time when handler will next fire
441  */
442 #if !SST_BUILDING_CORE
443  Cycle_t reregisterClock(TimeConverter *tc, Clock::HandlerBase* handler, int priority) __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
444 #else
445  Cycle_t reregisterClock(TimeConverter *tc, Clock::HandlerBase* handler, int priority);
446 #endif
447 
448  /** Returns the next Cycle that the TImeConverter would fire. */
449 #if !SST_BUILDING_CORE
450  Cycle_t getNextClockCycle(TimeConverter* tc, int priority = CLOCKPRIORITY) __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
451 #else
452  Cycle_t getNextClockCycle(TimeConverter* tc, int priority = CLOCKPRIORITY);
453 #endif
454 
455  /** Return the Statistic Processing Engine associated with this Simulation */
456 #if !SST_BUILDING_CORE
457  Statistics::StatisticProcessingEngine* getStatisticsProcessingEngine(void) const __attribute__ ((deprecated("this function was not intended to be used outside of SST core and will be removed in SST 11.")));
458 #else
459  Statistics::StatisticProcessingEngine* getStatisticsProcessingEngine(void) const;
460 #endif
461 
462 
463 
464 
465 private:
466  friend class Link;
467  friend class Action;
468  friend class Output;
469  // To enable main to set up globals
470  friend int ::main(int argc, char **argv);
471 
472  Simulation(); // Don't call. Only rational way to serialize
473  Simulation(Config* config, RankInfo my_rank, RankInfo num_ranks, SimTime_t min_part);
474  Simulation(Simulation const&); // Don't Implement
475  void operator=(Simulation const&); // Don't implement
476 
477 
478  /** Get a handle to a TimeConverter
479  * @param cycles Frequency which is the base of the TimeConverter
480  */
481  TimeConverter* minPartToTC(SimTime_t cycles) const;
482 
483  /** Factory used to generate the simulation components */
484  static Factory *factory;
485  /** TimeLord of the simulation */
486  static TimeLord timeLord;
487  /** Output */
488  static Output sim_output;
489  static void resizeBarriers(uint32_t nthr);
490  static Core::ThreadSafe::Barrier initBarrier;
491  static Core::ThreadSafe::Barrier completeBarrier;
492  static Core::ThreadSafe::Barrier setupBarrier;
493  static Core::ThreadSafe::Barrier runBarrier;
494  static Core::ThreadSafe::Barrier exitBarrier;
495  static Core::ThreadSafe::Barrier finishBarrier;
496  static std::mutex simulationMutex;
497 
498 
499 
500  Component* createComponent(ComponentId_t id, const std::string& name,
501  Params &params);
502 
503  TimeVortex* getTimeVortex() const { return timeVortex; }
504 
505  /** Emergency Shutdown
506  * Called when a SIGINT or SIGTERM has been seen
507  */
508  static void emergencyShutdown();
509  /** Normal Shutdown
510  */
511  void endSimulation(void) { endSimulation(currentSimCycle); }
512  void endSimulation(SimTime_t end);
513 
514  typedef enum {
515  SHUTDOWN_CLEAN, /* Normal shutdown */
516  SHUTDOWN_SIGNAL, /* SIGINT or SIGTERM received */
517  SHUTDOWN_EMERGENCY, /* emergencyShutdown() called */
518  } ShutdownMode_t;
519 
520  friend class SyncManager;
521 
522  Mode_t runMode;
523  TimeVortex* timeVortex;
524  TimeConverter* threadMinPartTC;
525  Activity* current_activity;
526  static SimTime_t minPart;
527  static TimeConverter* minPartTC;
528  std::vector<SimTime_t> interThreadLatencies;
529  SimTime_t interThreadMinLatency;
530  SyncManager* syncManager;
531  ThreadSync* threadSync;
532  ComponentInfoMap compInfoMap;
533  clockMap_t clockMap;
534  oneShotMap_t oneShotMap;
535  SimTime_t currentSimCycle;
536  SimTime_t endSimCycle;
537  int currentPriority;
538  static Exit* m_exit;
539  SimulatorHeartbeat* m_heartbeat;
540  bool endSim;
541  RankInfo my_rank;
542  RankInfo num_ranks;
543  bool independent; // true if no links leave thread (i.e. no syncs required)
544  static std::atomic<int> untimed_msg_count;
545  unsigned int untimed_phase;
546  volatile sig_atomic_t lastRecvdSignal;
547  ShutdownMode_t shutdown_mode;
548  std::string output_directory;
549  static SharedRegionManager* sharedRegionManager;
550  bool wireUpFinished;
551 
552  static std::unordered_map<std::thread::id, Simulation*> instanceMap;
553  static std::vector<Simulation*> instanceVec;
554 
555  friend void wait_my_turn_start();
556  friend void wait_my_turn_end();
557 
558 };
559 
560 // Function to allow for easy serialization of threads while debugging
561 // code. Can only be used when you can guarantee all threads will be
562 // taking the same code path. If you can't guarantee that, then use a
563 // spinlock to make sure only one person is in a given region at a
564 // time. ONLY FOR DEBUG USE.
565 void wait_my_turn_start(Core::ThreadSafe::Barrier& barrier, int thread, int total_threads);
566 
567 void wait_my_turn_end(Core::ThreadSafe::Barrier& barrier, int thread, int total_threads);
568 
569 
570 } // namespace SST
571 
572 #endif //SST_CORE_SIMULATION_H
Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file...
Definition: output.h:54
Cycle_t getNextClockCycle(TimeConverter *tc, int priority=CLOCKPRIORITY)
Returns the next Cycle that the TImeConverter would fire.
Definition: simulation.cc:745
Exit * getExit() const
Return the exit event.
Definition: simulation.h:166
static SimTime_t getLocalMinimumNextActivityTime()
Gets the minimum next activity time across all TimeVortices in the Rank.
Definition: simulation.cc:194
UnitAlgebra getFinalSimTime() const
Return the end simulation time as a time.
Definition: simulation.cc:681
Main control class for a SST Simulation.
Definition: simulation.h:73
Base class for all Activities in the SST Event Queue.
Definition: activity.h:52
Maps port names to the Links that are connected to it.
Definition: linkMap.h:28
Class to contain SST Simulation Configuration variables.
Definition: config.h:31
static TimeLord * getTimeLord(void)
Return the TimeLord associated with this Simulation.
Definition: simulation.h:130
RankInfo getNumRanks() const
Get the number of parallel ranks in the simulation.
Definition: simulation.h:160
Cycle_t reregisterClock(TimeConverter *tc, Clock::HandlerBase *handler, int priority)
Reactivate an existing clock and handler.
Definition: simulation.cc:734
const SimTime_t & getCurrentSimCycle() const
Return the current simulation time as a cycle count.
Definition: simulation.cc:640
Mode_t getSimulationMode() const
Get the run mode of the simulation (e.g.
Definition: simulation.h:139
A Configuration Graph A graph representing Components and Links.
Definition: configGraph.h:321
static Simulation * createSimulation(Config *config, RankInfo my_rank, RankInfo num_ranks, SimTime_t min_part)
Create new simulation.
Definition: simulation.cc:99
SimTime_t getNextActivityTime() const
Returns the time of the next item to be executed that is in the TImeVortex of the Simulation...
Definition: simulation.cc:188
std::string & getOutputDirectory()
Returns the output directory of the simulation.
Definition: simulation.h:353
void requireEvent(const std::string &name)
Signifies that an event type is required for this simulation Causes the Factory to verify that the re...
Definition: simulation.cc:182
void insertActivity(SimTime_t time, Activity *ev)
Insert an activity to fire at a specified time.
Definition: simulation.cc:787
Definition: simulation.h:78
ComponentInfo * getComponentInfo(const ComponentId_t &id) const
returns the ComponentInfo object for the given ID
Definition: simulation.h:321
Definition: simulation.h:77
static void setSignal(int signal)
Sets an internal flag for signaling the simulation.
Definition: simulation.cc:686
void setStopAtCycle(Config *cfg)
Set cycle count, which, if reached, will cause the simulation to halt.
Definition: simulation.cc:157
void initialize()
Perform the init() phase of simulation.
Definition: simulation.cc:416
Exit Event Action.
Definition: exit.h:34
std::map< std::pair< SimTime_t, int >, OneShot * > oneShotMap_t
Definition: simulation.h:84
Definition: componentInfo.h:250
static Output & getSimulationOutput()
Return the base simulation Output class instance.
Definition: simulation.h:133
int getCurrentPriority() const
Return the current priority.
Definition: simulation.cc:652
void setup()
Perform the setup() and run phases of the simulation.
Definition: simulation.cc:493
A Clock class.
Definition: clock.h:32
BaseComponent * getComponent(const ComponentId_t &id) const
returns the component with the given ID
Definition: simulation.h:304
static void shutdown()
Used to signify the end of simulation.
Definition: simulation.cc:112
int performWireUp(ConfigGraph &graph, const RankInfo &myRank, SimTime_t min_part)
Converts a ConfigGraph graph into actual set of links and components.
Definition: simulation.cc:282
LinkMap * getComponentLinkMap(ComponentId_t id) const
Return pointer to map of links for a given component id.
Definition: simulation.h:283
RankInfo getRank() const
Get this instance&#39;s parallel rank.
Definition: simulation.h:157
UnitAlgebra getElapsedSimTime() const
Return the elapsed simulation time as a time.
Definition: simulation.cc:676
Definition: rankInfo.h:21
Main component object for the simulation.
Definition: baseComponent.h:52
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:763
void setOutputDirectory(const std::string &outDir)
Set the output directory for this simulation.
Definition: simulation.h:341
static Simulation * getSimulation()
Return a pointer to the singleton instance of the Simulation.
Definition: simulation.h:122
A OneShot Event class.
Definition: oneshot.h:33
Class for creating and managing TimeConverter objects.
Definition: timeLord.h:36
TimeConverter * registerClock(const std::string &freq, Clock::HandlerBase *handler, int priority)
Register a handler to be called on a set frequency.
Definition: simulation.cc:708
static SharedRegionManager * getSharedRegionManager()
Returns the Simulation&#39;s SharedRegionManager.
Definition: simulation.h:127
bool isWireUpFinished()
Returns true when the Wireup is finished.
Definition: simulation.h:384
Definition: simulation.h:79
void printStatus(bool fullStatus)
Causes the current status of the simulation to be printed to stderr.
Definition: simulation.cc:692
Definition: componentInfo.h:36
SimTime_t getEndSimCycle() const
Return the end simulation time as a cycle count.
Definition: simulation.cc:646
Statistics::StatisticProcessingEngine * getStatisticsProcessingEngine(void) const
Return the Statistic Processing Engine associated with this Simulation.
Definition: simulation.cc:805
Definition: simulation.h:80
void unregisterClock(TimeConverter *tc, Clock::HandlerBase *handler, int priority)
Remove a clock handler from the list of active clock handlers.
Definition: simulation.cc:755
Mode_t
Type of Run Modes.
Definition: simulation.h:76
Performs Unit math in full precision.
Definition: unitAlgebra.h:107
std::map< std::pair< SimTime_t, int >, Clock * > clockMap_t
Definition: simulation.h:83
const ComponentInfoMap & getComponentInfoMap(void)
Returns reference to the Component Info Map.
Definition: simulation.h:297
void complete()
Perform the complete() phase of simulation.
Definition: simulation.cc:458
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:208
Definition: sharedRegion.h:60