SST  15.1.0
StructuralSimulationToolkit
interactiveConsole.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_INTERACTIVE_CONSOLE_H
13 #define SST_CORE_INTERACTIVE_CONSOLE_H
14 
15 #include "sst/core/action.h"
16 #include "sst/core/cputimer.h"
17 #include "sst/core/eli/elementinfo.h"
18 #include "sst/core/output.h"
19 #include "sst/core/rankInfo.h"
20 #include "sst/core/sst_types.h"
21 #include "sst/core/threadsafe.h"
22 #include "sst/core/unitAlgebra.h"
23 
24 #include <cstdint>
25 #include <set>
26 #include <string>
27 
28 namespace SST {
29 
30 class Params;
31 class Simulation_impl;
32 class TimeConverter;
33 
34 namespace Interactive {
35 /* Utility functions needed to manage directories */
36 
37 
38 } // namespace Interactive
39 
40 /**
41  \class CheckpointAction
42  A recurring event to trigger checkpoint generation
43 */
45 {
46 public:
47  // Make this an ELI base
48  SST_ELI_DECLARE_BASE(InteractiveConsole)
49  SST_ELI_DECLARE_CTOR_EXTERN(SST::Params&)
52  )
53 
54  /**
55  Create a new checkpoint object for the simulation core to initiate checkpoints
56  */
57  InteractiveConsole() = default;
58  virtual ~InteractiveConsole() = default;
59 
60  /** Called by TimeVortex to trigger checkpoint on simulation clock interval - not used in parallel simulation */
61  virtual void execute(const std::string& msg) = 0;
62 
63 protected:
64  // Functions that can be called by child class
65 
66  // Informational functions
67  /** Get the core timebase */
69 
70  /** Return the current simulation time as a cycle count*/
71  SimTime_t getCurrentSimCycle() const;
72 
73  /** Return the elapsed simulation time as a time */
75 
76  /** Return the end simulation time as a cycle count*/
77  SimTime_t getEndSimCycle() const;
78 
79  /** Return the end simulation time as a time */
80  UnitAlgebra getEndSimTime() const;
81 
82  /** Get this instance's parallel rank */
83  RankInfo getRank() const;
84 
85  /** Get the number of parallel ranks in the simulation */
86  RankInfo getNumRanks() const;
87 
88  /** Return the base simulation Output class instance */
89  Output& getSimulationOutput() const;
90 
91  /** Return the max depth of the TimeVortex */
92  uint64_t getTimeVortexMaxDepth() const;
93 
94  /** Return the size of the SyncQueue - per-rank */
95  uint64_t getSyncQueueDataSize() const;
96 
97  /** Return MemPool usage information - per-rank */
98  void getMemPoolUsage(int64_t& bytes, int64_t& active_entries);
99 
100  /** Get a TimeConverter */
101  TimeConverter* getTimeConverter(const std::string& time);
102 
103  /** Get the list of Components */
104  void getComponentList(std::vector<std::pair<std::string, SST::Component*>>& vec);
105 
106  // Actions that an InteractiveAction can take
107 
108  /**
109  Runs the simulation the specified number of core time base
110  units
111 
112  @param time Time in units of core time base
113  */
114  void simulationRun(SimTime_t time);
115 
116  /**
117  Schedules the action for execution at the current simulation
118  time plus time_offset
119 
120  @param time_offset Time in units of core time base
121  */
122  void schedule_interactive(SimTime_t time_offset, const std::string& msg);
123 
124  SST::Core::Serialization::ObjectMap* getComponentObjectMap();
125 
126  void simulationShutdown();
127 
128 private:
129  InteractiveConsole(const InteractiveConsole&) = delete;
130  InteractiveConsole& operator=(const InteractiveConsole&) = delete;
131 };
132 
133 } // namespace SST
134 
135 #ifndef SST_ELI_REGISTER_INTERACTIVE_CONSOLE
136 #define SST_ELI_REGISTER_INTERACTIVE_CONSOLE(cls, lib, name, version, desc) \
137  SST_ELI_REGISTER_DERIVED(SST::InteractiveConsole,cls,lib,name,ELI_FORWARD_AS_ONE(version),desc)
138 #endif
139 
140 
141 #endif // SST_CORE_INTERACTIVE_CONSOLE_H
Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file...
Definition: output.h:57
RankInfo getRank() const
Get this instance&#39;s parallel rank.
Definition: interactiveConsole.cc:59
UnitAlgebra getEndSimTime() const
Return the end simulation time as a time.
Definition: interactiveConsole.cc:53
A class to convert between a component&#39;s view of time and the core&#39;s view of time.
Definition: timeConverter.h:27
Definition: action.cc:18
TimeConverter * getTimeConverter(const std::string &time)
Get a TimeConverter.
Definition: interactiveConsole.cc:95
Base class for objects created by the serializer mapping mode used to map the variables for objects...
Definition: objectMap.h:158
UnitAlgebra getElapsedSimTime() const
Return the elapsed simulation time as a time.
Definition: interactiveConsole.cc:41
Output & getSimulationOutput() const
Return the base simulation Output class instance.
Definition: interactiveConsole.cc:71
SST_ELI_DECLARE_INFO_EXTERN(ELI::ProvidesParams) InteractiveConsole()=default
Create a new checkpoint object for the simulation core to initiate checkpoints
Definition: paramsInfo.h:39
uint64_t getTimeVortexMaxDepth() const
Return the max depth of the TimeVortex.
Definition: interactiveConsole.cc:77
void simulationRun(SimTime_t time)
Runs the simulation the specified number of core time base units.
SimTime_t getCurrentSimCycle() const
Return the current simulation time as a cycle count.
Definition: interactiveConsole.cc:35
Definition: rankInfo.h:23
uint64_t getSyncQueueDataSize() const
Return the size of the SyncQueue - per-rank.
Definition: interactiveConsole.cc:89
void getMemPoolUsage(int64_t &bytes, int64_t &active_entries)
Return MemPool usage information - per-rank.
Definition: interactiveConsole.cc:83
UnitAlgebra getCoreTimeBase() const
Get the core timebase.
Definition: interactiveConsole.cc:29
Definition: interactiveConsole.h:44
Parameter store.
Definition: params.h:63
virtual void execute(const std::string &msg)=0
Called by TimeVortex to trigger checkpoint on simulation clock interval - not used in parallel simula...
void schedule_interactive(SimTime_t time_offset, const std::string &msg)
Schedules the action for execution at the current simulation time plus time_offset.
Definition: interactiveConsole.cc:101
Performs Unit math in full precision.
Definition: unitAlgebra.h:105
void getComponentList(std::vector< std::pair< std::string, SST::Component *>> &vec)
Get the list of Components.
SimTime_t getEndSimCycle() const
Return the end simulation time as a cycle count.
Definition: interactiveConsole.cc:47
RankInfo getNumRanks() const
Get the number of parallel ranks in the simulation.
Definition: interactiveConsole.cc:65