SST 16.0.0
Structural Simulation Toolkit
SST::Simulation Class Reference

Main control class for a SST Simulation. More...

#include <simulation.h>

Public Types

enum  ShutdownMode_t { SHUTDOWN_CLEAN , SHUTDOWN_SIGNAL , SHUTDOWN_EMERGENCY }
using clockMap_t = std::map<std::pair<SimTime_t, int>, Clock*>

Public Member Functions

SST::Core::Serialization::ObjectMapgetComponentObjectMap ()
SimulationRunMode getSimulationMode () const
 Get the run mode of the simulation (e.g.
SimTime_t getCurrentSimCycle () const
 Return the current simulation time as a cycle count.
SimTime_t getEndSimCycle () const
 Return the end simulation time as a cycle count.
int getCurrentPriority () const
 Return the current priority.
UnitAlgebra getElapsedSimTime () const
 Return the elapsed simulation time as a time.
UnitAlgebra getEndSimTime () const
 Return the end simulation time as a time.
RankInfo getRank () const
 Get this instance's parallel rank.
RankInfo getNumRanks () const
 Get the number of parallel ranks in the simulation.
std::string & getOutputDirectory ()
 Returns the output directory of the simulation.
void requireLibrary (const std::string &name)
 Signifies that a library is required for this simulation.
void printStatus (bool fullStatus)
 Causes the current status of the simulation to be printed to stderr.
double getRunPhaseElapsedRealTime () const
double getInitPhaseElapsedRealTime () const
double getCompletePhaseElapsedRealTime () const
void insertActivity (SimTime_t time, Activity *ev)
 Insert an activity to fire at a specified time.
ExitgetExit () const
 Return the exit event.
void processGraphInfo (ConfigGraph &graph, const RankInfo &myRank, SimTime_t min_part)
 Processes the ConfigGraph to pull out any need information about relationships among the threads.
int initializeStatisticEngine (StatsConfig *stats_config)
int prepareLinks (ConfigGraph &graph, const RankInfo &myRank, SimTime_t min_part)
int performWireUp (ConfigGraph &graph, const RankInfo &myRank, SimTime_t min_part)
void exchangeLinkInfo ()
void findRankSyncInterval ()
 Functions to compute the current rank and thread sync intervals.
void findThreadSyncInterval ()
void updateSyncMinPart ()
void setupSimActions ()
 Setup external control actions (forced stops, signal handling.
bool parseSignalString (std::string &arg, std::string &name, Params &params)
 Helper for signal string parsing.
void initialize ()
 Perform the init() phase of simulation.
void complete ()
 Perform the complete() phase of simulation.
void setup ()
 Perform the setup() and run phases of the simulation.
void prepare_for_run ()
void setup_interactive_mode ()
void run ()
void finish ()
void updateSyncInterval ()
void adjustTimeAtSimEnd ()
 Adjust clocks and time to reflect precise simulation end time which may differ in parallel simulations from the time simulation end is detected.
bool isIndependentThread ()
void printProfilingInfo (Util::PerfReporter *reporter)
void printPerformanceInfo ()
const std::vector< SimTime_t > & getInterThreadLatencies () const
SimTime_t getInterThreadMinLatency () const
LinkMapgetComponentLinkMap (ComponentId_t id) const
const ComponentInfoMapgetComponentInfoMap () const
 Returns reference to the Component Info Map.
BaseComponentgetComponent (const ComponentId_t &id) const
 returns the component with the given ID
ComponentInfogetComponentInfo (const ComponentId_t &id) const
 returns the ComponentInfo object for the given ID
void setOutputDirectory (const std::string &outDir)
 Set the output directory for this simulation.
bool isWireUpFinished ()
 Returns true when the Wireup is finished.
uint64_t getTimeVortexMaxDepth () const
uint64_t getTimeVortexCurrentDepth () const
uint64_t getSyncQueueDataSize () const
CheckpointActiongetCheckpointAction () const
 Return the checkpoint event.
std::pair< pvt::TimeVortexSort::iterator, pvt::TimeVortexSort::iterator > getEventsForHandler (uintptr_t handler)
TimeConverter registerClock (const std::string &freq, Clock::HandlerBase *handler, int priority)
 Register a handler to be called on a set frequency.
TimeConverter registerClock (const UnitAlgebra &freq, Clock::HandlerBase *handler, int priority)
TimeConverter registerClock (TimeConverter tcFreq, Clock::HandlerBase *handler, int priority)
void registerClock (SimTime_t factor, Clock::HandlerBase *handler, int priority)
void reportClock (SimTime_t factor, int priority)
void unregisterClock (TimeConverter tc, Clock::HandlerBase *handler, int priority)
 Remove a clock handler from the list of active clock handlers.
Cycle_t reregisterClock (TimeConverter tc, Clock::HandlerBase *handler, int priority)
 Reactivate an existing clock and handler.
Cycle_t getNextClockCycle (TimeConverter tc, int priority=CLOCKPRIORITY)
 Returns the next Cycle that the TimeConverter would fire.
SimTime_t getClockForHandler (Clock::HandlerBase *handler)
 Gets the clock the handler is registered with, represented by it's factor.
Statistics::StatisticProcessingEnginegetStatisticsProcessingEngine ()
 Return the Statistic Processing Engine associated with this Simulation.
 Simulation (RankInfo my_rank, RankInfo num_ranks, bool restart, SimTime_t currentSimCycle, int currentPriority)
 Simulation (const Simulation &)=delete
Simulation & operator= (const Simulation &)=delete
TimeConverter minPartToTC (SimTime_t cycles) const
 Get a handle to a TimeConverter.
void scheduleCheckpoint ()
void scheduleInteractiveConsole (const std::string &msg)
void checkpoint (const std::string &checkpoint_filename)
 Write the partition specific checkpoint data.
void checkpoint_append_registry (const std::string &registry_name, const std::string &blob_name)
 Append partitions registry information.
void checkpoint_write_globals (int checkpoint_id, const std::string &checkpoint_filename, const std::string &registry_filename, const std::string &globals_filename)
 Write the global data to a binary file and create the registry and write the header info.
void restart (ConfigGraph *graph)
void discoverRemoteLinks ()
void discoverRemoteLinksMoveData (std::vector< std::pair< LinkId_t, RankInfo > > &send_vec, std::vector< std::pair< LinkId_t, RankInfo > > &recv_vec)
RankInfo getRankForLinkOnRestart (RankInfo rank, LinkId_t UNUSED(id))
 Function used to get the rank for a link on restart.
void initialize_interactive_console (const std::string &type)
ComponentcreateComponent (ComponentId_t id, const std::string &name, Params &params)
TimeVortexgetTimeVortex () const
void signalShutdown (bool abnormal)
 Signal Shutdown Called when a signal needs to terminate SST E.g., SIGINT or SIGTERM has been seen abnormal indicates whether this was unexpected or not.
void consoleShutdown (bool abnormal)
 Console Shutdown Called when a shutdown command or watchpoint shutdown action trigger needs to terminate SST.
void setEndSim ()
 Set EndSim Called by SyncMgr when interactive console ready to shutdown.
void endSimulation ()
 Normal Shutdown.
void endSimulation (SimTime_t end)
void checkIndependent ()
uint32_t getNextLinkOrderTag ()
 Gets the next value for the order field of the link.
void initializeProfileTools (const std::string &config)
 Performance Tracking Information.
template<typename T>
std::vector< T * > getProfileTool (std::string point)
void printSimulationState ()

Static Public Member Functions

static Simulation * getSimulation ()
 Return a pointer to the singleton instance of the Simulation.
static TimeLordgetTimeLord ()
 Return the TimeLord associated with this Simulation.
static Output & getSimulationOutput ()
 Return the base simulation Output class instance.
static Simulation * createSimulation (RankInfo my_rank, RankInfo num_ranks, bool restart, SimTime_t currentSimCycle, int currentPriority)
 Create new simulation.
static void shutdown ()
 Used to signify the end of simulation.
static void notifySignal ()
 Sets an internal flag for signaling the simulation.
static void serializeSharedObjectManager (SST::Core::Serialization::serializer &ser)
static TimeConverter getMinPartTC ()
static SimTime_t getLocalMinimumNextActivityTime ()
 Gets the minimum next activity time across all TimeVortices in the Rank.
static void writeCheckpointConfigGraph (ConfigGraph *graph)
static void resizeBarriers (uint32_t nthr)
static void emergencyShutdown ()
 Emergency Shutdown Called when a fatal event has occurred.

Data Fields

Core::ThreadSafe::BoundedQueue< std::vector< std::pair< LinkId_t, RankInfo > > * > local_discover_queue
Core::ThreadSafe::BoundedQueue< std::vector< std::pair< LinkId_t, RankInfo > > * > * remote_discover_queue
std::vector< std::pair< LinkId_t, RankInfo > > * xfer_vec = nullptr
bool direct_interthread
TimeVortextimeVortex = nullptr
std::string timeVortexType
TimeConverter threadMinPartTC
Activitycurrent_activity
std::vector< SimTime_t > interThreadLatencies
SimTime_t interThreadMinLatency = MAX_SIMTIME_T
SyncManager * syncManager
ComponentInfoMap compInfoMap
clockMap_t clockMap
SimulatorHeartbeatm_heartbeat = nullptr
CheckpointActioncheckpoint_action_
bool endSim = false
bool independent
unsigned int untimed_phase
volatile sig_atomic_t signal_arrived_
ShutdownMode_t shutdown_mode_
bool enter_shutdown_ = false
bool wireUpFinished_
RealTimeManagerreal_time_
std::string interactive_type_ = ""
std::string interactive_start_ = ""
std::string replay_file_ = ""
InteractiveConsoleinteractive_ = nullptr
bool enter_interactive_ = false
std::string interactive_msg_
SimTime_t stop_at_ = 0
uint32_t next_link_order_tag_ = 1
Core::OneShotManager one_shot_manager_
std::vector< std::pair< ComponentId_t, uint64_t > > component_blob_offsets_
 vector to hold offsets of component blobs in checkpoint files
pvt::TimeVortexSort tv_sort_
SST::Statistics::StatisticProcessingEngine stat_engine
 Statistics Engine.
std::map< std::string, SST::Profile::ProfileTool * > profile_tools
std::map< std::string, std::vector< std::string > > profiler_map
uint64_t clockDivisor = 1e6
std::string clockResolution = "us"
SimulationRunMode runMode
SimTime_t currentSimCycle = 0
int currentPriority = 0
SimTime_t endSimCycle = 0
RankInfo my_rank
RankInfo num_ranks
std::string output_directory
double run_phase_start_time_
double run_phase_total_time_
double init_phase_start_time_
double init_phase_total_time_
double complete_phase_start_time_
double complete_phase_total_time_
std::map< LinkId_t, Link * > link_restart_tracking
std::map< uintptr_t, uintptr_t > event_handler_restart_tracking
uint32_t checkpoint_id_ = 0
std::string checkpoint_prefix_ = ""
std::string globalOutputFileName = ""
std::string version_ = ""
std::string arch_ = ""
std::string os_ = ""
bool serial_restart_ = false

Static Public Attributes

static Factoryfactory
 Factory used to generate the simulation components.
static SST::Util::Filesystem filesystem
 Filesystem object that will be used to ensure all core-created files end up in the directory specified by –output-directory.
static Core::ThreadSafe::Barrier initBarrier
static Core::ThreadSafe::Barrier completeBarrier
static Core::ThreadSafe::Barrier setupBarrier
static Core::ThreadSafe::Barrier runBarrier
static Core::ThreadSafe::Barrier exitBarrier
static Core::ThreadSafe::Barrier finishBarrier
static std::mutex simulationMutex
static Util::BasicPerfTracker basicPerf
static Core::ThreadSafe::Spinlock cross_thread_lock
static std::map< LinkId_t, Link * > cross_thread_links
static SimTime_t minPart
static TimeConverter minPartTC
static Exitm_exit
static std::string checkpoint_directory_ = ""
static std::string checkpoint_configgraph_ = ""
static std::atomic< int > untimed_msg_count
static TimeLord timeLord
 TimeLord of the simulation.
static Output sim_output
 Output.
static std::unordered_map< std::thread::id, Simulation * > instanceMap
static std::vector< Simulation * > instanceVec_
static Config config
static StatsConfigstats_config_ = nullptr

Friends

class Link
class Action
class Output
class SyncManager
friend int::main (int argc, char **argv)
void wait_my_turn_start ()
void wait_my_turn_end ()

Detailed Description

Main control class for a SST Simulation.

Provides base features for managing the simulation

Member Typedef Documentation

◆ clockMap_t

using SST::Simulation::clockMap_t = std::map<std::pair<SimTime_t, int>, Clock*>

Map of times to clocks

Member Function Documentation

◆ createSimulation()

Simulation * SST::Simulation::createSimulation ( RankInfo my_rank,
RankInfo num_ranks,
bool restart,
SimTime_t currentSimCycle,
int currentPriority )
static

Create new simulation.

Parameters
my_rank- Parallel Rank of this simulation object
num_ranks- How many Ranks are in the simulation
restart- Whether this simulation is being restarted from a checkpoint (true) or not

References initializeProfileTools().

◆ getClockForHandler()

SimTime_t SST::Simulation::getClockForHandler ( Clock::HandlerBase * handler)

Gets the clock the handler is registered with, represented by it's factor.

Parameters
handlerClock handler to search for
Returns
Factor of TimeConverter for the clock the specified handler is registered with. If the handler is not currently registered with a clock, returns 0.

◆ getCurrentSimCycle()

◆ getNextLinkOrderTag()

uint32_t SST::Simulation::getNextLinkOrderTag ( )
inline

Gets the next value for the order field of the link.

The ordering of events based on links will be based on the order that configureLink() is called.

◆ getOutputDirectory()

std::string & SST::Simulation::getOutputDirectory ( )
inline

Returns the output directory of the simulation.

Returns
Directory in which simulation outputs are placed

◆ getRankForLinkOnRestart()

RankInfo SST::Simulation::getRankForLinkOnRestart ( RankInfo rank,
LinkId_t UNUSEDid )
inline

Function used to get the rank for a link on restart.

A rank of -1 on the return means that the paritioning stayed the same between checkpoint and restart and the original rank info stored in the checkpoint should be used.

◆ getSimulationMode()

SimulationRunMode SST::Simulation::getSimulationMode ( ) const
inline

Get the run mode of the simulation (e.g.

init, run, both etc)

◆ minPartToTC()

TimeConverter SST::Simulation::minPartToTC ( SimTime_t cycles) const

Get a handle to a TimeConverter.

Simulation functions.

Parameters
cyclesFrequency which is the base of the TimeConverter

References getTimeLord().

Referenced by processGraphInfo().

◆ notifySignal()

void SST::Simulation::notifySignal ( )
static

Sets an internal flag for signaling the simulation.

Used by signal handler & thread 0.

◆ printStatus()

void SST::Simulation::printStatus ( bool fullStatus)

Causes the current status of the simulation to be printed to stderr.

Parameters
fullStatus- if true, call printStatus() on all components as well as print the base Simulation's status

References SST::Output::output(), and SST::Output::STDERR.

Referenced by SST::RealTimeAction::simulationPrintStatus().

◆ requireLibrary()

void SST::Simulation::requireLibrary ( const std::string & name)

Signifies that a library is required for this simulation.

Parameters
nameName of the library

References factory.

◆ reregisterClock()

Cycle_t SST::Simulation::reregisterClock ( TimeConverter tc,
Clock::HandlerBase * handler,
int priority )

Reactivate an existing clock and handler.

Returns
time when handler will next fire

References SST::Output::fatal(), SST::TimeConverter::getFactor(), and SST::Output::STDERR.

◆ setOutputDirectory()

void SST::Simulation::setOutputDirectory ( const std::string & outDir)
inline

Set the output directory for this simulation.

Parameters
outDirPath of directory to place simulation outputs in

◆ shutdown()

void SST::Simulation::shutdown ( )
static

Used to signify the end of simulation.

Cleans up any existing Simulation Objects


The documentation for this class was generated from the following files: