SST 15.0
Structural Simulation Toolkit
realtimeAction.h
1// Copyright 2009-2025 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-2025, 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 <string>
23
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 /* Reports whether the action is valid for use with sigalrm */
58 virtual bool isValidSigalrmAction() { return true; }
59
60 /* Accessors for core state that signal handlers may need
61 * These accessors return per-thread information unless noted in a comment
62 */
63
64 /** Get the core timebase */
65 UnitAlgebra getCoreTimeBase() const;
66 /** Return the current simulation time as a cycle count*/
67 SimTime_t getCurrentSimCycle() const;
68 /** Return the elapsed simulation time as a time */
69 UnitAlgebra getElapsedSimTime() const;
70 /** Return the end simulation time as a cycle count*/
71 SimTime_t getEndSimCycle() const;
72 /** Return the end simulation time as a time */
73 UnitAlgebra getEndSimTime() const;
74 /** Get this instance's parallel rank */
75 RankInfo getRank() const;
76 /** Get the number of parallel ranks in the simulation */
77 RankInfo getNumRanks() const;
78 /** Return the base simulation Output class instance */
79 Output& getSimulationOutput() const;
80 /** Return the max depth of the TimeVortex */
81 uint64_t getTimeVortexMaxDepth() const;
82 /** Return the size of the SyncQueue - per-rank */
83 uint64_t getSyncQueueDataSize() const;
84 /** Return MemPool usage information - per-rank */
85 void getMemPoolUsage(int64_t& bytes, int64_t& active_entries);
86
87
88 /* Actions that signal handlers can take */
89
90 /** Invokes printStatus on the simulation instance
91 * component_status indicates whether printStatus should
92 * also be called on all components
93 */
94 void simulationPrintStatus(bool component_status);
95
96 /** Inform the simulation that a signal requires a shutdown
97 * abnormal indicates whether emergencyShutdown() should be called
98 */
99 void simulationSignalShutdown(bool abnormal);
100
101 /** Generate a checkpoint */
103
104 void initiateInteractive(const std::string& msg);
105};
106
107} // namespace SST
108
109#ifndef SST_ELI_REGISTER_REALTIMEACTION
110#define SST_ELI_REGISTER_REALTIMEACTION(cls, lib, name, version, desc) \
111 SST_ELI_REGISTER_DERIVED(SST::RealTimeAction,cls,lib,name,ELI_FORWARD_AS_ONE(version),desc)
112#endif
113
114#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:54
Definition rankInfo.h:24
UnitAlgebra getCoreTimeBase() const
Get the core timebase.
Definition realtime.cc:87
UnitAlgebra getElapsedSimTime() const
Return the elapsed simulation time as a time.
Definition realtime.cc:99
void simulationCheckpoint()
Generate a checkpoint.
Definition realtime.cc:165
UnitAlgebra getEndSimTime() const
Return the end simulation time as a time.
Definition realtime.cc:111
uint64_t getSyncQueueDataSize() const
Return the size of the SyncQueue - per-rank.
Definition realtime.cc:147
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:123
uint64_t getTimeVortexMaxDepth() const
Return the max depth of the TimeVortex.
Definition realtime.cc:135
SimTime_t getCurrentSimCycle() const
Return the current simulation time as a cycle count.
Definition realtime.cc:93
Output & getSimulationOutput() const
Return the base simulation Output class instance.
Definition realtime.cc:129
RankInfo getRank() const
Get this instance's parallel rank.
Definition realtime.cc:117
SimTime_t getEndSimCycle() const
Return the end simulation time as a cycle count.
Definition realtime.cc:105
void getMemPoolUsage(int64_t &bytes, int64_t &active_entries)
Return MemPool usage information - per-rank.
Definition realtime.cc:141
void simulationSignalShutdown(bool abnormal)
Inform the simulation that a signal requires a shutdown abnormal indicates whether emergencyShutdown(...
Definition realtime.cc:159
void simulationPrintStatus(bool component_status)
Invokes printStatus on the simulation instance component_status indicates whether printStatus should ...
Definition realtime.cc:153
Performs Unit math in full precision.
Definition unitAlgebra.h:107