SST 12.1.0
Structural Simulation Toolkit
SST::Simulation_impl Class Reference

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

#include <simulation_impl.h>

Inheritance diagram for SST::Simulation_impl:
SST::Simulation

Public Types

enum  ShutdownMode_t { SHUTDOWN_CLEAN , SHUTDOWN_SIGNAL , SHUTDOWN_EMERGENCY }
 
typedef std::map< std::pair< SimTime_t, int >, Clock * > clockMap_t
 
typedef std::map< std::pair< SimTime_t, int >, OneShot * > oneShotMap_t
 
- Public Types inherited from SST::Simulation
enum  Mode_t { UNKNOWN , INIT , RUN , BOTH }
 Type of Run Modes. More...
 

Public Member Functions

Mode_t getSimulationMode () const override
 Get the run mode of the simulation (e.g. More...
 
SimTime_t getCurrentSimCycle () const override
 Return the current simulation time as a cycle count. More...
 
SimTime_t getEndSimCycle () const override
 Return the end simulation time as a cycle count. More...
 
int getCurrentPriority () const override
 Return the current priority. More...
 
UnitAlgebra getElapsedSimTime () const override
 Return the elapsed simulation time as a time. More...
 
UnitAlgebra getEndSimTime () const override
 Return the end simulation time as a time. More...
 
UnitAlgebra getFinalSimTime () const override
 Return the end simulation time as a time. More...
 
RankInfo getRank () const override
 Get this instance's parallel rank. More...
 
RankInfo getNumRanks () const override
 Get the number of parallel ranks in the simulation. More...
 
std::string & getOutputDirectory () override
 Returns the output directory of the simulation. More...
 
virtual void requireEvent (const std::string &name) override
 Signifies that an event type is required for this simulation Causes the Factory to verify that the required event type can be found. More...
 
virtual void requireLibrary (const std::string &name) override
 Signifies that a library is required for this simulation. More...
 
virtual void printStatus (bool fullStatus) override
 Causes the current status of the simulation to be printed to stderr. More...
 
virtual double getRunPhaseElapsedRealTime () const override
 Get the amount of real-time spent executing the run phase of the simulation. More...
 
virtual double getInitPhaseElapsedRealTime () const override
 Get the amount of real-time spent executing the init phase of the simulation. More...
 
virtual double getCompletePhaseElapsedRealTime () const override
 Get the amount of real-time spent executing the complete phase of the simulation. More...
 
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 prepareLinks (ConfigGraph &graph, const RankInfo &myRank, SimTime_t min_part)
 
int performWireUp (ConfigGraph &graph, const RankInfo &myRank, SimTime_t min_part)
 
void exchangeLinkInfo ()
 
void setStopAtCycle (Config *cfg)
 Set cycle count, which, if reached, will cause the simulation to halt.
 
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 run ()
 
void finish ()
 
bool isIndependentThread ()
 
void printProfilingInfo (FILE *fp)
 
void printPerformanceInfo ()
 
TimeConverterregisterOneShot (const std::string &timeDelay, OneShot::HandlerBase *handler, int priority)
 Register a OneShot event to be called after a time delay Note: OneShot cannot be canceled, and will always callback after the timedelay.
 
TimeConverterregisterOneShot (const UnitAlgebra &timeDelay, OneShot::HandlerBase *handler, int priority)
 
const std::vector< SimTime_t > & getInterThreadLatencies () const
 
SimTime_t getInterThreadMinLatency () const
 
LinkMapgetComponentLinkMap (ComponentId_t id) const
 
const ComponentInfoMapgetComponentInfoMap (void)
 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. More...
 
bool isWireUpFinished ()
 Returns true when the Wireup is finished.
 
uint64_t getTimeVortexMaxDepth () const
 
uint64_t getTimeVortexCurrentDepth () const
 
uint64_t getSyncQueueDataSize () const
 
TimeConverterregisterClock (const std::string &freq, Clock::HandlerBase *handler, int priority)
 Register a handler to be called on a set frequency.
 
TimeConverterregisterClock (const UnitAlgebra &freq, Clock::HandlerBase *handler, int priority)
 
TimeConverterregisterClock (TimeConverter *tcFreq, Clock::HandlerBase *handler, 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. More...
 
Cycle_t getNextClockCycle (TimeConverter *tc, int priority=CLOCKPRIORITY)
 Returns the next Cycle that the TImeConverter would fire.
 
Statistics::StatisticProcessingEnginegetStatisticsProcessingEngine (void) const
 Return the Statistic Processing Engine associated with this Simulation.
 
friend int::main (int argc, char **argv)
 
 Simulation_impl (Config *config, RankInfo my_rank, RankInfo num_ranks)
 
 Simulation_impl (Simulation_impl const &)
 
void operator= (Simulation_impl const &)
 
TimeConverterminPartToTC (SimTime_t cycles) const
 Get a handle to a TimeConverter. More...
 
ComponentcreateComponent (ComponentId_t id, const std::string &name, Params &params)
 
TimeVortexgetTimeVortex () const
 
void endSimulation (void)
 Normal Shutdown.
 
void endSimulation (SimTime_t end)
 
void intializeProfileTools (const std::string &config)
 Performance Tracking Information.
 
template<typename T >
std::vector< T * > getProfileTool (std::string point)
 
virtual Mode_t getSimulationMode () const =0
 Get the run mode of the simulation (e.g. More...
 
virtual SimTime_t getCurrentSimCycle () const =0
 Return the current simulation time as a cycle count. More...
 
virtual SimTime_t getEndSimCycle () const =0
 Return the end simulation time as a cycle count. More...
 
virtual int getCurrentPriority () const =0
 Return the current priority. More...
 
virtual UnitAlgebra getElapsedSimTime () const =0
 Return the elapsed simulation time as a time. More...
 
virtual UnitAlgebra getEndSimTime () const =0
 Return the end simulation time as a time. More...
 
virtual UnitAlgebra getFinalSimTime () const =0
 Return the end simulation time as a time. More...
 
virtual RankInfo getRank () const =0
 Get this instance's parallel rank. More...
 
virtual RankInfo getNumRanks () const =0
 Get the number of parallel ranks in the simulation. More...
 
virtual std::string & getOutputDirectory ()=0
 Returns the output directory of the simulation. More...
 
virtual void requireEvent (const std::string &name)=0
 Signifies that an event type is required for this simulation Causes the Factory to verify that the required event type can be found. More...
 
virtual void requireLibrary (const std::string &name)=0
 Signifies that a library is required for this simulation. More...
 
virtual void printStatus (bool fullStatus)=0
 Causes the current status of the simulation to be printed to stderr. More...
 
virtual double getRunPhaseElapsedRealTime () const =0
 Get the amount of real-time spent executing the run phase of the simulation. More...
 
virtual double getInitPhaseElapsedRealTime () const =0
 Get the amount of real-time spent executing the init phase of the simulation. More...
 
virtual double getCompletePhaseElapsedRealTime () const =0
 Get the amount of real-time spent executing the complete phase of the simulation. More...
 

Static Public Member Functions

static Simulation_implgetSimulation ()
 Return a pointer to the singleton instance of the Simulation.
 
static TimeLordgetTimeLord (void)
 Return the TimeLord associated with this Simulation.
 
static OutputgetSimulationOutput ()
 Return the base simulation Output class instance.
 
static Simulation_implcreateSimulation (Config *config, RankInfo my_rank, RankInfo num_ranks)
 Create new simulation. More...
 
static void shutdown ()
 Used to signify the end of simulation. More...
 
static void setSignal (int signal)
 Sets an internal flag for signaling the simulation. More...
 
static TimeConvertergetMinPartTC ()
 
static SimTime_t getLocalMinimumNextActivityTime ()
 Gets the minimum next activity time across all TimeVortices in the Rank.
 
static void resizeBarriers (uint32_t nthr)
 
static void emergencyShutdown ()
 Emergency Shutdown Called when a SIGINT or SIGTERM has been seen.
 
- Static Public Member Functions inherited from SST::Simulation
static SimulationgetSimulation ()
 Return a pointer to the singleton instance of the Simulation. More...
 
static TimeLordgetTimeLord (void)
 Return the TimeLord associated with this Simulation.
 
static OutputgetSimulationOutput ()
 Return the base simulation Output class instance.
 

Data Fields

bool direct_interthread
 
TimeVortextimeVortex
 
TimeConverterthreadMinPartTC
 
Activitycurrent_activity
 
std::vector< SimTime_t > interThreadLatencies
 
SimTime_t interThreadMinLatency
 
SyncManagersyncManager
 
ComponentInfoMap compInfoMap
 
clockMap_t clockMap
 
oneShotMap_t oneShotMap
 
SimulatorHeartbeatm_heartbeat
 
bool endSim
 
bool independent
 
unsigned int untimed_phase
 
volatile sig_atomic_t lastRecvdSignal
 
ShutdownMode_t shutdown_mode
 
bool wireUpFinished
 
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"
 
Mode_t runMode
 
SimTime_t currentSimCycle
 
SimTime_t endSimCycle
 
int currentPriority
 
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
 

Static Public Attributes

static Factoryfactory
 Factory used to generate the simulation components.
 
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 std::map< LinkId_t, Link * > cross_thread_links
 
static SimTime_t minPart
 
static TimeConverterminPartTC = nullptr
 
static Exitm_exit
 
static std::atomic< int > untimed_msg_count
 
static TimeLord timeLord
 TimeLord of the simulation.
 
static Output sim_output
 Output.
 
static SharedRegionManager * sharedRegionManager
 
static std::unordered_map< std::thread::id, Simulation_impl * > instanceMap
 
static std::vector< Simulation_impl * > instanceVec
 

Friends

class Link
 
class Action
 
class Output
 
class SyncManager
 
void wait_my_turn_start ()
 
void wait_my_turn_end ()
 

Additional Inherited Members

- Protected Member Functions inherited from SST::Simulation
 Simulation (Simulation const &)
 
void operator= (Simulation const &)
 

Detailed Description

Main control class for a SST Simulation.

Provides base features for managing the simulation

Member Typedef Documentation

◆ clockMap_t

typedef std::map<std::pair<SimTime_t, int>, Clock*> SST::Simulation_impl::clockMap_t

Map of times to clocks

◆ oneShotMap_t

typedef std::map<std::pair<SimTime_t, int>, OneShot*> SST::Simulation_impl::oneShotMap_t

Map of times to OneShots

Member Function Documentation

◆ createSimulation()

Simulation_impl * SST::Simulation_impl::createSimulation ( Config config,
RankInfo  my_rank,
RankInfo  num_ranks 
)
static

Create new simulation.

Parameters
config- Configuration of the simulation
my_rank- Parallel Rank of this simulation object
num_ranks- How many Ranks are in the simulation

References SST::Config::enabledProfiling(), and intializeProfileTools().

◆ getCompletePhaseElapsedRealTime()

double SST::Simulation_impl::getCompletePhaseElapsedRealTime ( ) const
overridevirtual

Get the amount of real-time spent executing the complete phase of the simulation.

Returns
real-time in seconds spent executing the complete phase

Implements SST::Simulation.

◆ getCurrentPriority()

int SST::Simulation_impl::getCurrentPriority ( ) const
overridevirtual

Return the current priority.

Implements SST::Simulation.

Referenced by SST::Clock::schedule().

◆ getCurrentSimCycle()

SimTime_t SST::Simulation_impl::getCurrentSimCycle ( ) const
overridevirtual

Return the current simulation time as a cycle count.

Non-static functions.

Implements SST::Simulation.

Referenced by getElapsedSimTime(), SST::Exit::refDec(), and SST::Clock::schedule().

◆ getElapsedSimTime()

UnitAlgebra SST::Simulation_impl::getElapsedSimTime ( ) const
overridevirtual

Return the elapsed simulation time as a time.

Implements SST::Simulation.

References getCurrentSimCycle(), SST::TimeLord::getTimeBase(), and timeLord.

◆ getEndSimCycle()

SimTime_t SST::Simulation_impl::getEndSimCycle ( ) const
overridevirtual

Return the end simulation time as a cycle count.

Implements SST::Simulation.

Referenced by getEndSimTime(), and getFinalSimTime().

◆ getEndSimTime()

UnitAlgebra SST::Simulation_impl::getEndSimTime ( ) const
overridevirtual

Return the end simulation time as a time.

Implements SST::Simulation.

References getEndSimCycle(), SST::TimeLord::getTimeBase(), and timeLord.

◆ getFinalSimTime()

UnitAlgebra SST::Simulation_impl::getFinalSimTime ( ) const
overridevirtual

Return the end simulation time as a time.

Implements SST::Simulation.

References getEndSimCycle(), SST::TimeLord::getTimeBase(), and timeLord.

◆ getInitPhaseElapsedRealTime()

double SST::Simulation_impl::getInitPhaseElapsedRealTime ( ) const
overridevirtual

Get the amount of real-time spent executing the init phase of the simulation.

Returns
real-time in seconds spent executing the init phase

Implements SST::Simulation.

◆ getNumRanks()

RankInfo SST::Simulation_impl::getNumRanks ( ) const
inlineoverridevirtual

Get the number of parallel ranks in the simulation.

Implements SST::Simulation.

Referenced by SST::ThreadSyncDirectSkip::ThreadSyncDirectSkip(), and SST::ThreadSyncSimpleSkip::ThreadSyncSimpleSkip().

◆ getOutputDirectory()

std::string & SST::Simulation_impl::getOutputDirectory ( )
inlineoverridevirtual

Returns the output directory of the simulation.

Returns
Directory in which simulation outputs are placed

Implements SST::Simulation.

◆ getRank()

RankInfo SST::Simulation_impl::getRank ( ) const
inlineoverridevirtual

◆ getRunPhaseElapsedRealTime()

double SST::Simulation_impl::getRunPhaseElapsedRealTime ( ) const
overridevirtual

Get the amount of real-time spent executing the run phase of the simulation.

Returns
real-time in seconds spent executing the run phase

Implements SST::Simulation.

◆ getSimulationMode()

Mode_t SST::Simulation_impl::getSimulationMode ( ) const
inlineoverridevirtual

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

init, run, both etc)

Implements SST::Simulation.

◆ minPartToTC()

TimeConverter * SST::Simulation_impl::minPartToTC ( SimTime_t  cycles) const

Get a handle to a TimeConverter.

Simulation_impl functions.

Parameters
cyclesFrequency which is the base of the TimeConverter

References SST::TimeLord::getTimeConverter(), and getTimeLord().

Referenced by processGraphInfo().

◆ printStatus()

void SST::Simulation_impl::printStatus ( bool  fullStatus)
overridevirtual

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

Implements SST::Simulation.

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

◆ requireEvent()

void SST::Simulation_impl::requireEvent ( const std::string &  name)
overridevirtual

Signifies that an event type is required for this simulation Causes the Factory to verify that the required event type can be found.

Parameters
namefully qualified libraryName.EventName

Implements SST::Simulation.

References factory, and SST::Factory::RequireEvent().

◆ requireLibrary()

void SST::Simulation_impl::requireLibrary ( const std::string &  name)
overridevirtual

Signifies that a library is required for this simulation.

Parameters
nameName of the library

Implements SST::Simulation.

References factory.

◆ reregisterClock()

Cycle_t SST::Simulation_impl::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_impl::setOutputDirectory ( const std::string &  outDir)
inline

Set the output directory for this simulation.

Parameters
outDirPath of directory to place simulation outputs in

◆ setSignal()

void SST::Simulation_impl::setSignal ( int  signal)
static

Sets an internal flag for signaling the simulation.

Used internally

◆ shutdown()

void SST::Simulation_impl::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: