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