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