SST  12.0.1
StructuralSimulationToolkit
simulation.h
1 // -*- c++ -*-
2 
3 // Copyright 2009-2022 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-2022, 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 #include "sst/core/output.h"
18 #include "sst/core/rankInfo.h"
19 #include "sst/core/sst_types.h"
20 #include "sst/core/unitAlgebra.h"
21 
22 namespace SST {
23 
24 // #define _SIM_DBG( fmt, args...) __DBG( DBG_SIM, Sim, fmt, ## args )
25 #define STATALLFLAG "--ALLSTATS--"
26 
27 class Output;
28 class TimeLord;
29 
30 /**
31  * Main control class for a SST Simulation.
32  * Provides base features for managing the simulation
33  */
35 {
36 public:
37  /** Type of Run Modes */
38  typedef enum {
39  UNKNOWN, /*!< Unknown mode - Invalid for running */
40  INIT, /*!< Initialize-only. Useful for debugging initialization and graph generation */
41  RUN, /*!< Run-only. Useful when restoring from a checkpoint (not currently supported) */
42  BOTH /*!< Default. Both initialize and Run the simulation */
43  } Mode_t;
44 
45  virtual ~Simulation();
46 
47  /********* Public Static API ************/
48 
49  /** Return a pointer to the singleton instance of the Simulation */
50  static Simulation* getSimulation()
51  __attribute__((deprecated("Element facing Simulation class APIs are deprecated and have moved to the various "
52  "element base classes. The APIs will be removed in SST 13.")));
53 
54  /** Return the TimeLord associated with this Simulation */
55  static TimeLord* getTimeLord(void)
56  __attribute__((deprecated("Element facing Simulation class APIs are deprecated and have moved to the various "
57  "element base classes. The APIs will be removed in SST 13.")));
58 
59  /** Return the base simulation Output class instance */
60  static Output& getSimulationOutput()
61  __attribute__((deprecated("Element facing Simulation class APIs are deprecated and have moved to the various "
62  "element base classes. The APIs will be removed in SST 13.")));
63 
64  /********* Public API ************/
65  /** Get the run mode of the simulation (e.g. init, run, both etc) */
66  virtual Mode_t getSimulationMode() const = 0;
67 
68  /** Return the current simulation time as a cycle count*/
69  virtual SimTime_t getCurrentSimCycle() const = 0;
70 
71  /** Return the end simulation time as a cycle count*/
72  virtual SimTime_t getEndSimCycle() const = 0;
73 
74  /** Return the current priority */
75  virtual int getCurrentPriority() const = 0;
76 
77  /** Return the elapsed simulation time as a time */
78  virtual UnitAlgebra getElapsedSimTime() const = 0;
79 
80  /** Return the end simulation time as a time */
81  virtual UnitAlgebra getEndSimTime() const = 0;
82 
83  /** Return the end simulation time as a time */
84  virtual UnitAlgebra getFinalSimTime() const
85  __attribute__((deprecated("getFinalSimTime() has been deprecated and will be removed in SST 13. It has been "
86  "replaced by getEndSimTime()."))) = 0;
87 
88  /** Get this instance's parallel rank */
89  virtual RankInfo getRank() const = 0;
90 
91  /** Get the number of parallel ranks in the simulation */
92  virtual RankInfo getNumRanks() const = 0;
93 
94  /** Returns the output directory of the simulation
95  * @return Directory in which simulation outputs are placed
96  */
97  virtual std::string& getOutputDirectory() = 0;
98 
99  /** Signifies that an event type is required for this simulation
100  * Causes the Factory to verify that the required event type can be found.
101  * @param name fully qualified libraryName.EventName
102  */
103  virtual void requireEvent(const std::string& name) __attribute__((deprecated(
104  "requireEvent() has been deprecated in favor or requireLibrary() and will be removed in SST 13."))) = 0;
105 
106  /** Signifies that a library is required for this simulation.
107  * @param name Name of the library
108  */
109  virtual void requireLibrary(const std::string& name) = 0;
110 
111  /** Causes the current status of the simulation to be printed to stderr.
112  * @param fullStatus - if true, call printStatus() on all components as well
113  * as print the base Simulation's status
114  */
115  virtual void printStatus(bool fullStatus) = 0;
116 
117  /** Get the amount of real-time spent executing the run phase of
118  * the simulation.
119  *
120  * @return real-time in seconds spent executing the run phase
121  */
122  virtual double getRunPhaseElapsedRealTime() const = 0;
123 
124  /** Get the amount of real-time spent executing the init phase of
125  * the simulation.
126  *
127  * @return real-time in seconds spent executing the init phase
128  */
129  virtual double getInitPhaseElapsedRealTime() const = 0;
130 
131  /** Get the amount of real-time spent executing the complete phase of
132  * the simulation.
133  *
134  * @return real-time in seconds spent executing the complete phase
135  */
136  virtual double getCompletePhaseElapsedRealTime() const = 0;
137 
138 protected:
139  Simulation() {}
140  // Simulation(Config* config, RankInfo my_rank, RankInfo num_ranks);
141  Simulation(Simulation const&); // Don't Implement
142  void operator=(Simulation const&); // Don't implement
143 };
144 
145 } // namespace SST
146 
147 #endif // SST_CORE_SIMULATION_H
Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file...
Definition: output.h:51
virtual SimTime_t getEndSimCycle() const =0
Return the end simulation time as a cycle count.
static TimeLord * getTimeLord(void)
Return the TimeLord associated with this Simulation.
Definition: simulation.cc:57
static Simulation * getSimulation()
Return a pointer to the singleton instance of the Simulation.
Definition: simulation.cc:51
Main control class for a SST Simulation.
Definition: simulation.h:34
virtual void requireLibrary(const std::string &name)=0
Signifies that a library is required for this simulation.
virtual UnitAlgebra getFinalSimTime() const =0
Return the end simulation time as a time.
virtual RankInfo getRank() const =0
Get this instance&#39;s parallel rank.
Definition: simulation.h:40
Definition: simulation.h:39
virtual UnitAlgebra getElapsedSimTime() const =0
Return the elapsed simulation time as a time.
virtual void printStatus(bool fullStatus)=0
Causes the current status of the simulation to be printed to stderr.
virtual double getCompletePhaseElapsedRealTime() const =0
Get the amount of real-time spent executing the complete phase of the simulation. ...
Definition: rankInfo.h:21
virtual RankInfo getNumRanks() const =0
Get the number of parallel ranks in the simulation.
virtual int getCurrentPriority() const =0
Return the current priority.
virtual UnitAlgebra getEndSimTime() const =0
Return the end simulation time as a time.
virtual double getRunPhaseElapsedRealTime() const =0
Get the amount of real-time spent executing the run phase of the simulation.
Class for creating and managing TimeConverter objects.
Definition: timeLord.h:37
Definition: simulation.h:41
static Output & getSimulationOutput()
Return the base simulation Output class instance.
Definition: simulation.cc:63
virtual SimTime_t getCurrentSimCycle() const =0
Return the current simulation time as a cycle count.
virtual std::string & getOutputDirectory()=0
Returns the output directory of the simulation.
Definition: simulation.h:42
Mode_t
Type of Run Modes.
Definition: simulation.h:38
Performs Unit math in full precision.
Definition: unitAlgebra.h:106
virtual double getInitPhaseElapsedRealTime() const =0
Get the amount of real-time spent executing the init phase of the simulation.
virtual Mode_t getSimulationMode() const =0
Get the run mode of the simulation (e.g.
virtual void requireEvent(const std::string &name)=0
Signifies that an event type is required for this simulation Causes the Factory to verify that the re...