SST  11.0.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 
18 #include "sst/core/sst_types.h"
19 
20 #include "sst/core/output.h"
21 #include "sst/core/rankInfo.h"
22 #include "sst/core/unitAlgebra.h"
23 
24 namespace SST {
25 
26 // #define _SIM_DBG( fmt, args...) __DBG( DBG_SIM, Sim, fmt, ## args )
27 #define STATALLFLAG "--ALLSTATS--"
28 
29 class Output;
30 class TimeLord;
31 class SharedRegionManager;
32 
33 
34 /**
35  * Main control class for a SST Simulation.
36  * Provides base features for managing the simulation
37  */
38 class Simulation {
39 public:
40  /** Type of Run Modes */
41  typedef enum {
42  UNKNOWN, /*!< Unknown mode - Invalid for running */
43  INIT, /*!< Initialize-only. Useful for debugging initialization and graph generation */
44  RUN, /*!< Run-only. Useful when restoring from a checkpoint (not currently supported) */
45  BOTH /*!< Default. Both initialize and Run the simulation */
46  } Mode_t;
47 
48  virtual ~Simulation();
49 
50 
51  /********* Public Static API ************/
52 
53  /** Return a pointer to the singleton instance of the Simulation */
54  static Simulation* getSimulation();
55 
56  /**
57  * Returns the Simulation's SharedRegionManager
58  */
59 
60 #if !SST_BUILDING_CORE
61  static SharedRegionManager* getSharedRegionManager() __attribute__ ((deprecated("SharedRegion and its accompanying classes have been deprecated and will be removed in SST 12. Please use the new SharedObject classes found in sst/core/shared.")));
62 #else
64 #endif
65 
66  /** Return the TimeLord associated with this Simulation */
67  static TimeLord* getTimeLord(void);
68 
69  /** Return the base simulation Output class instance */
70  static Output& getSimulationOutput();
71 
72 
73 
74  /********* Public API ************/
75  /** Get the run mode of the simulation (e.g. init, run, both etc) */
76  virtual Mode_t getSimulationMode() const = 0;
77 
78  /** Return the current simulation time as a cycle count*/
79  virtual SimTime_t getCurrentSimCycle() const = 0;
80 
81  /** Return the end simulation time as a cycle count*/
82  virtual SimTime_t getEndSimCycle() const = 0;
83 
84  /** Return the current priority */
85  virtual int getCurrentPriority() const = 0;
86 
87  /** Return the elapsed simulation time as a time */
88  virtual UnitAlgebra getElapsedSimTime() const = 0;
89 
90  /** Return the end simulation time as a time */
91  virtual UnitAlgebra getFinalSimTime() const = 0;
92 
93  /** Get this instance's parallel rank */
94  virtual RankInfo getRank() const = 0;
95 
96  /** Get the number of parallel ranks in the simulation */
97  virtual RankInfo getNumRanks() const = 0;
98 
99  /**
100  Returns the output directory of the simulation
101  @return Directory in which simulation outputs are placed
102  */
103  virtual std::string& getOutputDirectory() = 0;
104 
105  /** Signifies that an event type is required for this simulation
106  * Causes the Factory to verify that the required event type can be found.
107  * @param name fully qualified libraryName.EventName
108  */
109  virtual void requireEvent(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 
118 protected:
119 
120 
121  Simulation() {}
122  // Simulation(Config* config, RankInfo my_rank, RankInfo num_ranks);
123  Simulation(Simulation const&); // Don't Implement
124  void operator=(Simulation const&); // Don't implement
125 };
126 
127 } // namespace SST
128 
129 #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
Definition: sharedRegion.h:135
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:38
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:43
Definition: simulation.h:42
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.
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.
Class for creating and managing TimeConverter objects.
Definition: timeLord.h:38
Definition: simulation.h:44
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:45
Mode_t
Type of Run Modes.
Definition: simulation.h:41
Performs Unit math in full precision.
Definition: unitAlgebra.h:107
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:64