SST 16.0.0
Structural Simulation Toolkit
realtimeAction.h
1// Copyright 2009-2026 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-2026, 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#include <cstdint>
22#include <ctime>
23#include <string>
24namespace SST {
25
26class Output;
27class RankInfo;
28class UnitAlgebra;
29
30/** An event to trigger at a real-time interval */
31class RealTimeAction
32{
33public:
34 SST_ELI_DECLARE_BASE(RealTimeAction)
35 SST_ELI_DECLARE_DEFAULT_INFO_EXTERN()
36 SST_ELI_DECLARE_DEFAULT_CTOR_EXTERN()
37
38 RealTimeAction() = default;
39
40 virtual ~RealTimeAction() = default;
41
42 /* Optional function called just before run loop starts. Passes in
43 * the next scheduled time of the event or 0 if the event is not
44 * scheduled */
45 virtual void begin(time_t UNUSED(scheduled_time)) {}
46 virtual void execute() = 0;
47
48 /* Attribute functions that let the core know when certain actions
49 * need to be planned for */
50
51 /**
52 Let's the core know if this action may trigger a checkpoint so
53 that all the checkpoint infrastructure can be initialized.
54 */
55 virtual bool canInitiateCheckpoint() { return false; }
56
57 /**
58 Lets the core know if this action may trigger an interactive console.
59 */
60 virtual bool canInitiateInteractive() { return false; }
61
62 /* Reports whether the action is valid for use with sigalrm */
63 virtual bool isValidSigalrmAction() { return true; }
64
65 /* Accessors for core state that signal handlers may need
66 * These accessors return per-thread information unless noted in a comment
67 */
68
69 /** Get the core timebase */
70 UnitAlgebra getCoreTimeBase() const;
71 /** Return the current simulation time as a cycle count*/
72 SimTime_t getCurrentSimCycle() const;
73 /** Return the elapsed simulation time as a time */
74 UnitAlgebra getElapsedSimTime() const;
75 /** Return the end simulation time as a cycle count*/
76 SimTime_t getEndSimCycle() const;
77 /** Return the end simulation time as a time */
78 UnitAlgebra getEndSimTime() const;
79 /** Get this instance's parallel rank */
80 RankInfo getRank() const;
81 /** Get the number of parallel ranks in the simulation */
82 RankInfo getNumRanks() const;
83 /** Return the base simulation Output class instance */
84 Output& getSimulationOutput() const;
85 /** Return the max depth of the TimeVortex */
86 uint64_t getTimeVortexMaxDepth() const;
87 /** Return the size of the SyncQueue - per-rank */
88 uint64_t getSyncQueueDataSize() const;
89 /** Return MemPool usage information - per-rank */
90 void getMemPoolUsage(int64_t& bytes, int64_t& active_entries);
91
92
93 /* Actions that signal handlers can take */
94
95 /** Invokes printStatus on the simulation instance
96 * component_status indicates whether printStatus should
97 * also be called on all components
98 */
99 void simulationPrintStatus(bool component_status);
100
101 /** Inform the simulation that a signal requires a shutdown
102 * abnormal indicates whether emergencyShutdown() should be called
103 */
104 void simulationSignalShutdown(bool abnormal);
105
106 /** Generate a checkpoint */
108
109 void initiateInteractive(const std::string& msg);
110};
111
112} // namespace SST
113
114#ifndef SST_ELI_REGISTER_REALTIMEACTION
115#define SST_ELI_REGISTER_REALTIMEACTION(cls, lib, name, version, desc) \
116 SST_ELI_REGISTER_DERIVED(SST::RealTimeAction,cls,lib,name,ELI_FORWARD_AS_ONE(version),desc)
117#endif
118
119#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:58
Definition rankInfo.h:24
UnitAlgebra getCoreTimeBase() const
Get the core timebase.
Definition realtime.cc:89
UnitAlgebra getElapsedSimTime() const
Return the elapsed simulation time as a time.
Definition realtime.cc:101
virtual bool canInitiateInteractive()
Lets the core know if this action may trigger an interactive console.
Definition realtimeAction.h:60
void simulationCheckpoint()
Generate a checkpoint.
Definition realtime.cc:167
UnitAlgebra getEndSimTime() const
Return the end simulation time as a time.
Definition realtime.cc:113
uint64_t getSyncQueueDataSize() const
Return the size of the SyncQueue - per-rank.
Definition realtime.cc:149
virtual bool canInitiateCheckpoint()
Let's the core know if this action may trigger a checkpoint so that all the checkpoint infrastructure...
Definition realtimeAction.h:55
RankInfo getNumRanks() const
Get the number of parallel ranks in the simulation.
Definition realtime.cc:125
uint64_t getTimeVortexMaxDepth() const
Return the max depth of the TimeVortex.
Definition realtime.cc:137
SimTime_t getCurrentSimCycle() const
Return the current simulation time as a cycle count.
Definition realtime.cc:95
Output & getSimulationOutput() const
Return the base simulation Output class instance.
Definition realtime.cc:131
RankInfo getRank() const
Get this instance's parallel rank.
Definition realtime.cc:119
SimTime_t getEndSimCycle() const
Return the end simulation time as a cycle count.
Definition realtime.cc:107
void getMemPoolUsage(int64_t &bytes, int64_t &active_entries)
Return MemPool usage information - per-rank.
Definition realtime.cc:143
void simulationSignalShutdown(bool abnormal)
Inform the simulation that a signal requires a shutdown abnormal indicates whether emergencyShutdown(...
Definition realtime.cc:161
void simulationPrintStatus(bool component_status)
Invokes printStatus on the simulation instance component_status indicates whether printStatus should ...
Definition realtime.cc:155
Performs Unit math in full precision.
Definition unitAlgebra.h:107