SST  11.1.0
StructuralSimulationToolkit
simulation.h
1 // -*- c++ -*-
2 
3 // Copyright 2009-2021 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-2021, 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 class SharedRegionManager;
30 
31 /**
32  * Main control class for a SST Simulation.
33  * Provides base features for managing the simulation
34  */
36 {
37 public:
38  /** Type of Run Modes */
39  typedef enum {
40  UNKNOWN, /*!< Unknown mode - Invalid for running */
41  INIT, /*!< Initialize-only. Useful for debugging initialization and graph generation */
42  RUN, /*!< Run-only. Useful when restoring from a checkpoint (not currently supported) */
43  BOTH /*!< Default. Both initialize and Run the simulation */
44  } Mode_t;
45 
46  virtual ~Simulation();
47 
48  /********* Public Static API ************/
49 
50  /** Return a pointer to the singleton instance of the Simulation */
51  static Simulation* getSimulation();
52 
53  /**
54  * Returns the Simulation's SharedRegionManager
55  */
56 
57 #if !SST_BUILDING_CORE
59  __attribute__((deprecated("SharedRegion and its accompanying classes have been deprecated and will be removed "
60  "in SST 12. Please use the new SharedObject classes found in sst/core/shared.")));
61 #else
63 #endif
64 
65  /** Return the TimeLord associated with this Simulation */
66  static TimeLord* getTimeLord(void);
67 
68  /** Return the base simulation Output class instance */
69  static Output& getSimulationOutput();
70 
71  /********* Public API ************/
72  /** Get the run mode of the simulation (e.g. init, run, both etc) */
73  virtual Mode_t getSimulationMode() const = 0;
74 
75  /** Return the current simulation time as a cycle count*/
76  virtual SimTime_t getCurrentSimCycle() const = 0;
77 
78  /** Return the end simulation time as a cycle count*/
79  virtual SimTime_t getEndSimCycle() const = 0;
80 
81  /** Return the current priority */
82  virtual int getCurrentPriority() const = 0;
83 
84  /** Return the elapsed simulation time as a time */
85  virtual UnitAlgebra getElapsedSimTime() const = 0;
86 
87  /** Return the end simulation time as a time */
88  virtual UnitAlgebra getFinalSimTime() const = 0;
89 
90  /** Get this instance's parallel rank */
91  virtual RankInfo getRank() const = 0;
92 
93  /** Get the number of parallel ranks in the simulation */
94  virtual RankInfo getNumRanks() const = 0;
95 
96  /** Returns the output directory of the simulation
97  * @return Directory in which simulation outputs are placed
98  */
99  virtual std::string& getOutputDirectory() = 0;
100 
101  /** Signifies that an event type is required for this simulation
102  * Causes the Factory to verify that the required event type can be found.
103  * @param name fully qualified libraryName.EventName
104  */
105  virtual void requireEvent(const std::string& name) = 0;
106 
107  /** Causes the current status of the simulation to be printed to stderr.
108  * @param fullStatus - if true, call printStatus() on all components as well
109  * as print the base Simulation's status
110  */
111  virtual void printStatus(bool fullStatus) = 0;
112 
113  /** Get the amount of real-time spent executing the run phase of
114  * the simulation.
115  *
116  * @return real-time in seconds spent executing the run phase
117  */
118  virtual double getRunPhaseElapsedRealTime() const = 0;
119 
120  /** Get the amount of real-time spent executing the init phase of
121  * the simulation.
122  *
123  * @return real-time in seconds spent executing the init phase
124  */
125  virtual double getInitPhaseElapsedRealTime() const = 0;
126 
127  /** Get the amount of real-time spent executing the complete phase of
128  * the simulation.
129  *
130  * @return real-time in seconds spent executing the complete phase
131  */
132  virtual double getCompletePhaseElapsedRealTime() const = 0;
133 
134 protected:
135  Simulation() {}
136  // Simulation(Config* config, RankInfo my_rank, RankInfo num_ranks);
137  Simulation(Simulation const&); // Don't Implement
138  void operator=(Simulation const&); // Don't implement
139 };
140 
141 } // namespace SST
142 
143 #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
Definition: sharedRegion.h:133
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:64
static Simulation * getSimulation()
Return a pointer to the singleton instance of the Simulation.
Definition: simulation.cc:52
Main control class for a SST Simulation.
Definition: simulation.h:35
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.
static SharedRegionManager * getSharedRegionManager()
Returns the Simulation&#39;s SharedRegionManager.
Definition: simulation.cc:58
Definition: simulation.h:41
Definition: simulation.h:40
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 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:42
static Output & getSimulationOutput()
Return the base simulation Output class instance.
Definition: simulation.cc:70
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:43
Mode_t
Type of Run Modes.
Definition: simulation.h:39
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...
Definition: sharedRegion.h:63