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