SST  14.1.0
StructuralSimulationToolkit
realtimeAction.h
1 // Copyright 2009-2024 NTESS. Under the terms
2 // of Contract DE-NA0003525 with NTESS, the U.S.
3 // Government retains certain rights in this software.
4 //
5 // Copyright (c) 2009-2024, NTESS
6 // All rights reserved.
7 //
8 // This file is part of the SST software package. For license
9 // information, see the LICENSE file in the top level directory of the
10 // distribution.
11 
12 #ifndef SST_CORE_REAL_TIME_ACTION_H
13 #define SST_CORE_REAL_TIME_ACTION_H
14 
15 #include "sst/core/eli/elementinfo.h"
16 #include "sst/core/serialization/serializable.h"
17 #include "sst/core/sst_types.h"
18 #include "sst/core/threadsafe.h"
19 #include "sst/core/warnmacros.h"
20 
21 namespace SST {
22 
23 class Output;
24 class RankInfo;
25 class UnitAlgebra;
26 
27 /** An event to trigger at a real-time interval */
29 {
30 public:
31  SST_ELI_DECLARE_BASE(RealTimeAction)
32  SST_ELI_DECLARE_DEFAULT_INFO_EXTERN()
33  SST_ELI_DECLARE_DEFAULT_CTOR_EXTERN()
34 
35 
37 
38  /* Optional function called just before run loop starts. Passes in
39  * the next scheduled time of the event or 0 if the event is not
40  * scheduled */
41  virtual void begin(time_t UNUSED(scheduled_time)) {}
42  virtual void execute() = 0;
43 
44  /* Attribute functions that let the core know when certain actions
45  * need to be planned for */
46 
47  /**
48  Let's the core know if this action may trigger a checkpoint so
49  that all the checkpoint infrastructure can be initialized.
50  */
51  virtual bool canInitiateCheckpoint() { return false; }
52 
53  /* Accessors for core state that signal handlers may need
54  * These accessors return per-thread information unless noted in a comment
55  */
56 
57  /** Get the core timebase */
59  /** Return the current simulation time as a cycle count*/
60  SimTime_t getCurrentSimCycle() const;
61  /** Return the elapsed simulation time as a time */
63  /** Return the end simulation time as a cycle count*/
64  SimTime_t getEndSimCycle() const;
65  /** Return the end simulation time as a time */
66  UnitAlgebra getEndSimTime() const;
67  /** Get this instance's parallel rank */
68  RankInfo getRank() const;
69  /** Get the number of parallel ranks in the simulation */
70  RankInfo getNumRanks() const;
71  /** Return the base simulation Output class instance */
72  Output& getSimulationOutput() const;
73  /** Return the max depth of the TimeVortex */
74  uint64_t getTimeVortexMaxDepth() const;
75  /** Return the size of the SyncQueue - per-rank */
76  uint64_t getSyncQueueDataSize() const;
77  /** Return MemPool usage information - per-rank */
78  void getMemPoolUsage(int64_t& bytes, int64_t& active_entries);
79 
80 
81  /* Actions that signal handlers can take */
82 
83  /** Invokes printStatus on the simulation instance
84  * component_status indicates whether printStatus should
85  * also be called on all components
86  */
87  void simulationPrintStatus(bool component_status);
88 
89  /** Inform the simulation that a signal requires a shutdown
90  * abnormal indicates whether emergencyShutdown() should be called
91  */
92  void simulationSignalShutdown(bool abnormal);
93 
94  /** Generate a checkpoint */
95  void simulationCheckpoint();
96 
97  void initiateInteractive(const std::string& msg);
98 };
99 
100 } // namespace SST
101 
102 #ifndef SST_ELI_REGISTER_REALTIMEACTION
103 #define SST_ELI_REGISTER_REALTIMEACTION(cls, lib, name, version, desc) \
104  SST_ELI_REGISTER_DERIVED(SST::RealTimeAction,cls,lib,name,ELI_FORWARD_AS_ONE(version),desc)
105 #endif
106 
107 #endif /* SST_CORE_REAL_TIME_ACTION_H */
Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file...
Definition: output.h:53
Output & getSimulationOutput() const
Return the base simulation Output class instance.
Definition: realtime.cc:139
RankInfo getNumRanks() const
Get the number of parallel ranks in the simulation.
Definition: realtime.cc:133
UnitAlgebra getEndSimTime() const
Return the end simulation time as a time.
Definition: realtime.cc:121
UnitAlgebra getCoreTimeBase() const
Get the core timebase.
Definition: realtime.cc:97
uint64_t getTimeVortexMaxDepth() const
Return the max depth of the TimeVortex.
Definition: realtime.cc:145
Definition: action.cc:18
SimTime_t getCurrentSimCycle() const
Return the current simulation time as a cycle count.
Definition: realtime.cc:103
An event to trigger at a real-time interval.
Definition: realtimeAction.h:28
void simulationPrintStatus(bool component_status)
Invokes printStatus on the simulation instance component_status indicates whether printStatus should ...
Definition: realtime.cc:163
Definition: rankInfo.h:21
void getMemPoolUsage(int64_t &bytes, int64_t &active_entries)
Return MemPool usage information - per-rank.
Definition: realtime.cc:151
void simulationSignalShutdown(bool abnormal)
Inform the simulation that a signal requires a shutdown abnormal indicates whether emergencyShutdown(...
Definition: realtime.cc:169
uint64_t getSyncQueueDataSize() const
Return the size of the SyncQueue - per-rank.
Definition: realtime.cc:157
SimTime_t getEndSimCycle() const
Return the end simulation time as a cycle count.
Definition: realtime.cc:115
UnitAlgebra getElapsedSimTime() const
Return the elapsed simulation time as a time.
Definition: realtime.cc:109
RankInfo getRank() const
Get this instance's parallel rank.
Definition: realtime.cc:127
virtual bool canInitiateCheckpoint()
Let's the core know if this action may trigger a checkpoint so that all the checkpoint infrastructure...
Definition: realtimeAction.h:51
void simulationCheckpoint()
Generate a checkpoint.
Definition: realtime.cc:175
Performs Unit math in full precision.
Definition: unitAlgebra.h:106