SST 16.0.0
Structural Simulation Toolkit
simulation.h
1// -*- c++ -*-
2
3// Copyright 2009-2026 NTESS. Under the terms
4// of Contract DE-NA0003525 with NTESS, the U.S.
5// Government retains certain rights in this software.
6//
7// Copyright (c) 2009-2026, NTESS
8// All rights reserved.
9//
10// This file is part of the SST software package. For license
11// information, see the LICENSE file in the top level directory of the
12// distribution.
13
14#ifndef SST_CORE_SIMULATION_IMPL_H
15#define SST_CORE_SIMULATION_IMPL_H
16
17#include "sst/core/clock.h"
18#include "sst/core/componentInfo.h"
19#include "sst/core/exit.h"
20#include "sst/core/impl/oneshotManager.h"
21#include "sst/core/output.h"
22#include "sst/core/profile/profiletool.h"
23#include "sst/core/rankInfo.h"
24#include "sst/core/sst_types.h"
25#include "sst/core/statapi/statengine.h"
26#include "sst/core/timeConverter.h"
27#include "sst/core/unitAlgebra.h"
28#include "sst/core/util/basicPerf.h"
29#include "sst/core/util/filesystem.h"
30
31#include <atomic>
32#include <cstdint>
33#include <cstdio>
34#include <iostream>
35#include <map>
36#include <mutex>
37#include <set>
38#include <signal.h>
39#include <string>
40#include <thread>
41#include <unordered_map>
42#include <utility>
43#include <vector>
44
45/* Forward declare for Friendship */
46extern int main(int argc, char** argv);
47
48namespace SST {
49
50// Function to exit, guarding against race conditions if multiple threads call it
51[[noreturn]]
52void SST_Exit(int exit_code);
53
54#define _SIM_DBG(fmt, args...) __DBG(DBG_SIM, Sim, fmt, ##args)
55
56class Activity;
58class Component;
59class Config;
60class ConfigGraph;
61class Exit;
62class Factory;
64class Link;
65class LinkMap;
66class Params;
67class RealTimeManager;
69class SyncBase;
70class SyncManager;
71class ThreadSync;
72class TimeLord;
73class TimeVortex;
74class UnitAlgebra;
75
76namespace Statistics {
77class StatisticOutput;
79} // namespace Statistics
80
81namespace Util {
82class PerfReporter;
83} // namespace Util
84
85namespace pvt {
86
87/**
88 Class to sort the contents of the TimeVortex in preparation for
89 checkpointing
90 */
91struct TimeVortexSort
92{
93 struct less
94 {
95 bool operator()(const Activity* lhs, const Activity* rhs) const;
96 };
97
98 std::vector<Activity*> data;
99
100 using iterator = std::vector<Activity*>::iterator;
101
102 // Iterator to start of actions after sort
103 iterator action_start;
104
105 TimeVortexSort() = default;
106
107 void sortData();
108
109 std::pair<iterator, iterator> getEventsForHandler(uintptr_t handler);
110
111 std::pair<iterator, iterator> getActions();
112};
113
114} // namespace pvt
115
116/**
117 * Main control class for a SST Simulation.
118 * Provides base features for managing the simulation
119 */
120class Simulation
121{
122
123public:
124 SST::Core::Serialization::ObjectMap* getComponentObjectMap();
125
126 /******** Public API inherited from Simulation ********/
127 /** Get the run mode of the simulation (e.g. init, run, both etc) */
128 SimulationRunMode getSimulationMode() const { return runMode; };
129
130 /** Return the current simulation time as a cycle count*/
131 SimTime_t getCurrentSimCycle() const;
132
133 /** Return the end simulation time as a cycle count*/
134 SimTime_t getEndSimCycle() const;
135
136 /** Return the current priority */
137 int getCurrentPriority() const;
138
139 /** Return the elapsed simulation time as a time */
141
142 /** Return the end simulation time as a time */
144
145 /** Get this instance's parallel rank */
146 RankInfo getRank() const { return my_rank; }
147
148 /** Get the number of parallel ranks in the simulation */
149 RankInfo getNumRanks() const { return num_ranks; }
150
151 /**
152 Returns the output directory of the simulation
153 @return Directory in which simulation outputs are placed
154 */
155 std::string& getOutputDirectory() { return output_directory; }
156
157 /** Signifies that a library is required for this simulation.
158 * @param name Name of the library
159 */
160 void requireLibrary(const std::string& name);
161
162 /** Causes the current status of the simulation to be printed to stderr.
163 * @param fullStatus - if true, call printStatus() on all components as well
164 * as print the base Simulation's status
165 */
166 void printStatus(bool fullStatus);
167
168 double getRunPhaseElapsedRealTime() const;
169 double getInitPhaseElapsedRealTime() const;
170 double getCompletePhaseElapsedRealTime() const;
171
172 /******** End Public API from Simulation ********/
173
174 using clockMap_t = std::map<std::pair<SimTime_t, int>, Clock*>; /*!< Map of times to clocks */
175 // using oneShotMap_t = std::map<int, OneShot*>; /*!< Map of priorities to OneShots */
176
177 ~Simulation();
178
179 /********* Static Core-only Functions *********/
180
181 /** Return a pointer to the singleton instance of the Simulation */
182 static Simulation* getSimulation() { return instanceMap.at(std::this_thread::get_id()); }
183
184 /** Return the TimeLord associated with this Simulation */
185 static TimeLord* getTimeLord() { return &timeLord; }
186
187 /** Return the base simulation Output class instance */
188 static Output& getSimulationOutput() { return sim_output; }
189
190 /** Create new simulation
191 * @param my_rank - Parallel Rank of this simulation object
192 * @param num_ranks - How many Ranks are in the simulation
193 * @param restart - Whether this simulation is being restarted from a checkpoint (true) or not
194 */
196 RankInfo my_rank, RankInfo num_ranks, bool restart, SimTime_t currentSimCycle, int currentPriority);
197
198 /**
199 * Used to signify the end of simulation. Cleans up any existing Simulation Objects
200 */
201 static void shutdown();
202
203 /** Sets an internal flag for signaling the simulation. Used by signal handler & thread 0. */
204 static void notifySignal();
205
206 static void serializeSharedObjectManager(SST::Core::Serialization::serializer& ser);
207
208 /******** Core only API *************/
209
210 /** Insert an activity to fire at a specified time */
211 void insertActivity(SimTime_t time, Activity* ev);
212
213 /** Return the exit event */
214 Exit* getExit() const { return m_exit; }
215
216 /** Processes the ConfigGraph to pull out any need information
217 * about relationships among the threads
218 */
219 void processGraphInfo(ConfigGraph& graph, const RankInfo& myRank, SimTime_t min_part);
220
221 int initializeStatisticEngine(StatsConfig* stats_config);
222 int prepareLinks(ConfigGraph& graph, const RankInfo& myRank, SimTime_t min_part);
223 int performWireUp(ConfigGraph& graph, const RankInfo& myRank, SimTime_t min_part);
224 void exchangeLinkInfo();
225
226 /** Functions to compute the current rank and thread sync intervals */
228 void findThreadSyncInterval();
229 void updateSyncMinPart();
230
231 /** Setup external control actions (forced stops, signal handling */
232 void setupSimActions();
233
234 /** Helper for signal string parsing */
235 bool parseSignalString(std::string& arg, std::string& name, Params& params);
236
237 /** Perform the init() phase of simulation */
238 void initialize();
239
240 /** Perform the complete() phase of simulation */
241 void complete();
242
243 /** Perform the setup() and run phases of the simulation. */
244 void setup();
245
246 void prepare_for_run();
247
248 void setup_interactive_mode();
249
250 void run();
251
252 void finish();
253
254 void updateSyncInterval();
255
256 /** Adjust clocks and time to reflect precise simulation end time which
257 may differ in parallel simulations from the time simulation end is detected.
258 */
259 void adjustTimeAtSimEnd();
260
261 bool isIndependentThread() { return independent; }
262
263 void printProfilingInfo(Util::PerfReporter* reporter);
264
265 void printPerformanceInfo();
266
267
268 const std::vector<SimTime_t>& getInterThreadLatencies() const { return interThreadLatencies; }
269
270 SimTime_t getInterThreadMinLatency() const { return interThreadMinLatency; }
271
272 static TimeConverter getMinPartTC() { return minPartTC; }
273
274 LinkMap* getComponentLinkMap(ComponentId_t id) const
275 {
276 ComponentInfo* info = compInfoMap.getByID(id);
277 if ( nullptr == info ) {
278 return nullptr;
279 }
280 else {
281 return info->getLinkMap();
282 }
283 }
284
285 /** Returns reference to the Component Info Map */
286 const ComponentInfoMap& getComponentInfoMap() const { return compInfoMap; }
287
288 /** returns the component with the given ID */
289 BaseComponent* getComponent(const ComponentId_t& id) const
290 {
291 ComponentInfo* i = compInfoMap.getByID(id);
292 if ( nullptr != i ) {
293 return i->getComponent();
294 }
295 else {
296 printf("Simulation::getComponent() couldn't find component with id = %" PRIu64 "\n", id);
297 SST_Exit(1);
298 }
299 }
300
301 /** returns the ComponentInfo object for the given ID */
302 ComponentInfo* getComponentInfo(const ComponentId_t& id) const
303 {
304 ComponentInfo* i = compInfoMap.getByID(id);
305 if ( nullptr != i ) {
306 return i;
307 }
308 else {
309 printf("Simulation::getComponentInfo() couldn't find component with id = %" PRIu64 "\n", id);
310 SST_Exit(1);
311 }
312 }
313
314 /**
315 Set the output directory for this simulation
316 @param outDir Path of directory to place simulation outputs in
317 */
318 void setOutputDirectory(const std::string& outDir) { output_directory = outDir; }
319
320 /**
321 * Gets the minimum next activity time across all TimeVortices in
322 * the Rank
323 */
324 static SimTime_t getLocalMinimumNextActivityTime();
325
326 /**
327 * Returns true when the Wireup is finished.
328 */
329 bool isWireUpFinished() { return wireUpFinished_; }
330
331 uint64_t getTimeVortexMaxDepth() const;
332
333 uint64_t getTimeVortexCurrentDepth() const;
334
335 uint64_t getSyncQueueDataSize() const;
336
337 /** Return the checkpoint event */
338 CheckpointAction* getCheckpointAction() const { return checkpoint_action_; }
339
340
341 std::pair<pvt::TimeVortexSort::iterator, pvt::TimeVortexSort::iterator> getEventsForHandler(uintptr_t handler);
342
343 /******** API provided through BaseComponent only ***********/
344
345 /** Register a handler to be called on a set frequency */
346 TimeConverter registerClock(const std::string& freq, Clock::HandlerBase* handler, int priority);
347
348 TimeConverter registerClock(const UnitAlgebra& freq, Clock::HandlerBase* handler, int priority);
349
350 TimeConverter registerClock(TimeConverter tcFreq, Clock::HandlerBase* handler, int priority);
351
352 // registerClock function used during checkpoint/restart
353 void registerClock(SimTime_t factor, Clock::HandlerBase* handler, int priority);
354
355 // Reports that a clock should be present, but doesn't register anything with it
356 void reportClock(SimTime_t factor, int priority);
357
358 /** Remove a clock handler from the list of active clock handlers */
359 void unregisterClock(TimeConverter tc, Clock::HandlerBase* handler, int priority);
360
361 /** Reactivate an existing clock and handler.
362 * @return time when handler will next fire
363 */
364 Cycle_t reregisterClock(TimeConverter tc, Clock::HandlerBase* handler, int priority);
365
366 /** Returns the next Cycle that the TimeConverter would fire. */
367 Cycle_t getNextClockCycle(TimeConverter tc, int priority = CLOCKPRIORITY);
368
369 /** Gets the clock the handler is registered with, represented by it's factor
370 *
371 * @param handler Clock handler to search for
372 *
373 * @return Factor of TimeConverter for the clock the specified
374 * handler is registered with. If the handler is not currently
375 * registered with a clock, returns 0.
376 */
377 SimTime_t getClockForHandler(Clock::HandlerBase* handler);
378
379 /** Return the Statistic Processing Engine associated with this Simulation */
381
382
383 friend class Link;
384 friend class Action;
385 friend class Output;
386 // To enable main to set up globals
387 friend int ::main(int argc, char** argv);
388
389 Simulation(RankInfo my_rank, RankInfo num_ranks, bool restart, SimTime_t currentSimCycle, int currentPriority);
390 Simulation(const Simulation&) = delete; // Don't Implement
391 Simulation& operator=(const Simulation&) = delete; // Don't implement
392
393 /** Get a handle to a TimeConverter
394 * @param cycles Frequency which is the base of the TimeConverter
395 */
396 TimeConverter minPartToTC(SimTime_t cycles) const;
397
398 static void writeCheckpointConfigGraph(ConfigGraph* graph);
399 void scheduleCheckpoint();
400 void scheduleInteractiveConsole(const std::string& msg);
401
402 /**
403 Write the partition specific checkpoint data
404 */
405 void checkpoint(const std::string& checkpoint_filename);
406
407 /**
408 Append partitions registry information
409 */
410 void checkpoint_append_registry(const std::string& registry_name, const std::string& blob_name);
411
412 /**
413 Write the global data to a binary file and create the registry
414 and write the header info
415 */
416 void checkpoint_write_globals(int checkpoint_id, const std::string& checkpoint_filename,
417 const std::string& registry_filename, const std::string& globals_filename);
418 void restart(ConfigGraph* graph);
419
420 void discoverRemoteLinks();
421
422 /**** Functions/variables needed for discoverRemoteLinks() ****/
425 std::vector<std::pair<LinkId_t, RankInfo>>* xfer_vec = nullptr;
426
427 void discoverRemoteLinksMoveData(
428 std::vector<std::pair<LinkId_t, RankInfo>>& send_vec, std::vector<std::pair<LinkId_t, RankInfo>>& recv_vec);
429
430 /**************************************************************/
431
432 /**
433 Function used to get the rank for a link on restart. A rank of
434 -1 on the return means that the paritioning stayed the same
435 between checkpoint and restart and the original rank info
436 stored in the checkpoint should be used.
437 */
438 RankInfo getRankForLinkOnRestart(RankInfo rank, LinkId_t UNUSED(id))
439 {
440 if ( serial_restart_ ) return RankInfo(0, 0);
441 return RankInfo(rank.rank, rank.thread);
442 }
443
444 void initialize_interactive_console(const std::string& type);
445
446 /** Factory used to generate the simulation components */
448
449 /**
450 Filesystem object that will be used to ensure all core-created
451 files end up in the directory specified by --output-directory.
452 */
454
455 static void resizeBarriers(uint32_t nthr);
456 static Core::ThreadSafe::Barrier initBarrier;
457 static Core::ThreadSafe::Barrier completeBarrier;
458 static Core::ThreadSafe::Barrier setupBarrier;
459 static Core::ThreadSafe::Barrier runBarrier;
460 static Core::ThreadSafe::Barrier exitBarrier;
461 static Core::ThreadSafe::Barrier finishBarrier;
462 static std::mutex simulationMutex;
463
464 static Util::BasicPerfTracker basicPerf;
465
466 // Support for crossthread links
467 static Core::ThreadSafe::Spinlock cross_thread_lock;
468 static std::map<LinkId_t, Link*> cross_thread_links;
469 bool direct_interthread;
470
471 Component* createComponent(ComponentId_t id, const std::string& name, Params& params);
472
473 TimeVortex* getTimeVortex() const { return timeVortex; }
474
475 /** Emergency Shutdown
476 * Called when a fatal event has occurred
477 */
478 static void emergencyShutdown();
479
480 /** Signal Shutdown
481 * Called when a signal needs to terminate SST
482 * E.g., SIGINT or SIGTERM has been seen
483 * abnormal indicates whether this was unexpected or not
484 */
485 void signalShutdown(bool abnormal);
486
487 /** Console Shutdown
488 * Called when a shutdown command or watchpoint shutdown action trigger needs to terminate SST
489 */
490 void consoleShutdown(bool abnormal);
491
492
493 /** Set EndSim
494 * Called by SyncMgr when interactive console ready to shutdown
495 */
496 void setEndSim();
497
498 /** Normal Shutdown
499 */
500 void endSimulation();
501 void endSimulation(SimTime_t end);
502
503 void checkIndependent();
504
505 enum ShutdownMode_t {
506 SHUTDOWN_CLEAN, /* Normal shutdown */
507 SHUTDOWN_SIGNAL, /* SIGINT or SIGTERM received */
508 SHUTDOWN_EMERGENCY, /* emergencyShutdown() called */
509 };
510
511 friend class SyncManager;
512
513 // TODO: Reorder data members to reduce excessive padding (currently 42 bytes padding; 2 bytes of padding possible)
514 //
515 // Optimal fields order: timeVortex, threadMinPartTC, current_activity, interThreadMinLatency, syncManager,
516 // m_heartbeat, checkpoint_action_, real_time_, interactive_, stop_at_, clockDivisor, currentSimCycle, endSimCycle,
517 // run_phase_start_time_, run_phase_total_time_, init_phase_start_time_, init_phase_total_time_,
518 // complete_phase_start_time_, complete_phase_total_time_, my_rank, num_ranks, interThreadLatencies,
519 // component_blob_offsets_, timeVortexType, interactive_type_, interactive_start_, replay_file_, interactive_msg_,
520 // tv_sort_, clockResolution, output_directory, checkpoint_prefix_, globalOutputFileName, clockMap, profile_tools,
521 // profiler_map, link_restart_tracking, event_handler_restart_tracking, compInfoMap, one_shot_manager_, stat_engine,
522 // untimed_phase, signal_arrived_, shutdown_mode_, runMode, currentPriority, checkpoint_id_, direct_interthread,
523 // endSim, independent, wireUpFinished_, enter_interactive_, serial_restart_
524
525 TimeVortex* timeVortex = nullptr;
526 std::string timeVortexType; // Required for checkpoint
527 TimeConverter threadMinPartTC; // Unused...?
528 Activity* current_activity;
529 static SimTime_t minPart;
530 static TimeConverter minPartTC;
531 std::vector<SimTime_t> interThreadLatencies;
532 SimTime_t interThreadMinLatency = MAX_SIMTIME_T;
533 SyncManager* syncManager;
534 ComponentInfoMap compInfoMap;
535 clockMap_t clockMap;
536 static Exit* m_exit;
537 SimulatorHeartbeat* m_heartbeat = nullptr;
538 CheckpointAction* checkpoint_action_;
539 static std::string checkpoint_directory_;
540 static std::string checkpoint_configgraph_;
541 bool endSim = false;
542 bool independent; // true if no links leave thread (i.e. no syncs required)
543 static std::atomic<int> untimed_msg_count;
544 unsigned int untimed_phase;
545 volatile sig_atomic_t signal_arrived_; // true if a signal has arrived
546 ShutdownMode_t shutdown_mode_;
547 bool enter_shutdown_ = false;
548 bool wireUpFinished_;
549 RealTimeManager* real_time_;
550 std::string interactive_type_ = "";
551 std::string interactive_start_ = "";
552 std::string replay_file_ = "";
553 InteractiveConsole* interactive_ = nullptr;
554 bool enter_interactive_ = false;
555 std::string interactive_msg_;
556 SimTime_t stop_at_ = 0;
557
558 uint32_t next_link_order_tag_ = 1;
559
560 /**
561 Gets the next value for the order field of the link. The ordering of events based on links will be based on
562 the order that configureLink() is called.
563 */
564 uint32_t getNextLinkOrderTag() { return next_link_order_tag_++; }
565
566 // OneShotManager
567 Core::OneShotManager one_shot_manager_;
568
569 /**
570 vector to hold offsets of component blobs in checkpoint files
571 */
572 std::vector<std::pair<ComponentId_t, uint64_t>> component_blob_offsets_;
573
574 pvt::TimeVortexSort tv_sort_;
575
576 /** TimeLord of the simulation */
578 /** Output */
579 static Output sim_output;
580
581
582 /** Statistics Engine */
584
585 /** Performance Tracking Information **/
586
587 void initializeProfileTools(const std::string& config);
588
589 std::map<std::string, SST::Profile::ProfileTool*> profile_tools;
590 // Maps the component profile points to profiler names
591 std::map<std::string, std::vector<std::string>> profiler_map;
592
593 template <typename T>
594 std::vector<T*> getProfileTool(std::string point)
595 {
596 std::vector<T*> ret;
597 try {
598 std::vector<std::string>& profilers = profiler_map.at(point);
599
600 for ( auto& x : profilers ) {
601 try {
602 SST::Profile::ProfileTool* val = profile_tools.at(x);
603
604 T* tool = dynamic_cast<T*>(val);
605 if ( !tool ) {
606 // Not the right type, fatal
607 Output::getDefaultObject().fatal(CALL_INFO_LONG, 1,
608 "ERROR: wrong type of profiling tool found (name = %s). Check to make sure the profiling "
609 "points enabled for this tool accept the type specified\n",
610 x.c_str());
611 }
612 ret.push_back(tool);
613 }
614 catch ( const std::out_of_range& e ) {
615 // This shouldn't happen. If it does, then something
616 // didn't get initialized correctly.
617 Output::getDefaultObject().fatal(CALL_INFO_LONG, 1,
618 "INTERNAL ERROR: ProfileTool refered to in profiler_map not found in profile_tools map\n");
619 return ret;
620 }
621 }
622 }
623 catch ( const std::out_of_range& e ) {
624 // point not turned on, return nullptr
625 return ret;
626 }
627
628
629 return ret;
630 }
631
632
633#if SST_PERFORMANCE_INSTRUMENTING
634 FILE* fp;
635#endif
636
637#if SST_PERIODIC_PRINT
638 uint64_t periodicCounter = 0;
639#endif
640
641#if SST_RUNTIME_PROFILING
642 uint64_t sumtime = 0;
643 uint64_t runtime = 0;
644 struct timeval start, end, diff;
645 struct timeval sumstart, sumend, sumdiff;
646#endif
647
648
649#if SST_EVENT_PROFILING
650 uint64_t rankLatency = 0; // Serialization time
651 uint64_t messageXferSize = 0;
652
653 uint64_t rankExchangeCounter = 0; // Num rank peer exchanges
654
655
656 // Profiling functions
657 void incrementSerialCounters(uint64_t count);
658
659#endif
660
661#if SST_HIGH_RESOLUTION_CLOCK
662 uint64_t clockDivisor = 1e9;
663 std::string clockResolution = "ns";
664#else
665 uint64_t clockDivisor = 1e6;
666 std::string clockResolution = "us";
667#endif
668
669 // Run mode for the simulation
670 SimulationRunMode runMode;
671
672 // Track current simulated time
673 SimTime_t currentSimCycle = 0;
674 int currentPriority = 0;
675 SimTime_t endSimCycle = 0;
676
677 // Rank information
678 RankInfo my_rank;
679 RankInfo num_ranks;
680
681 std::string output_directory;
682
683 double run_phase_start_time_;
684 double run_phase_total_time_;
685 double init_phase_start_time_;
686 double init_phase_total_time_;
687 double complete_phase_start_time_;
688 double complete_phase_total_time_;
689
690 static std::unordered_map<std::thread::id, Simulation*> instanceMap;
691 static std::vector<Simulation*> instanceVec_;
692
693 /******** Checkpoint/restart tracking data structures ***********/
694 std::map<LinkId_t, Link*> link_restart_tracking;
695 std::map<uintptr_t, uintptr_t> event_handler_restart_tracking;
696 uint32_t checkpoint_id_ = 0;
697 std::string checkpoint_prefix_ = "";
698 std::string globalOutputFileName = "";
699 std::string version_ = "";
700 std::string arch_ = "";
701 std::string os_ = "";
702 bool serial_restart_ = false;
703
704 // Config object used by the simulation
705 static Config config;
706 static StatsConfig* stats_config_;
707
708 void printSimulationState();
709
710 friend void wait_my_turn_start();
711 friend void wait_my_turn_end();
712
713private:
714 /**
715 * Returns the time of the next item to be executed
716 * that is in the TImeVortex of the Simulation
717 */
718 SimTime_t getNextActivityTime() const;
719};
720
721// Function to allow for easy serialization of threads while debugging
722// code. Can only be used when you can guarantee all threads will be
723// taking the same code path. If you can't guarantee that, then use a
724// spinlock to make sure only one person is in a given region at a
725// time. ONLY FOR DEBUG USE.
726void wait_my_turn_start(Core::ThreadSafe::Barrier& barrier, int thread, int total_threads);
727
728void wait_my_turn_end(Core::ThreadSafe::Barrier& barrier, int thread, int total_threads);
729
730} // namespace SST
731
732#endif // SST_CORE_SIMULATION_IMPL_H
An Action is a schedulable Activity which is not an Event.
Definition action.h:27
Base class for all Activities in the SST Event Queue.
Definition activity.h:48
Main component object for the simulation.
Definition baseComponent.h:67
A recurring event to trigger checkpoint generation.
Definition checkpointAction.h:69
A Clock class.
Definition clock.h:35
SSTHandlerBase< bool, Cycle_t > HandlerBase
Base handler for clock functions.
Definition clock.h:44
Definition componentInfo.h:285
Definition componentInfo.h:45
Main component object for the simulation.
Definition component.h:32
A Configuration Graph A graph representing Components and Links.
Definition configGraph.h:76
Class to contain SST Simulation Configuration variables.
Definition config.h:52
Manages the OneShot actions for the core.
Definition oneshotManager.h:100
Base class for objects created by the serializer mapping mode used to map the variables for objects.
Definition objectMap.h:188
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition serializer.h:43
Definition threadsafe.h:50
Definition threadsafe.h:169
Definition threadsafe.h:138
Exit Action.
Definition exit.h:35
Class for instantiating Components, Links and the like out of element libraries.
Definition factory.h:56
Definition interactiveConsole.h:46
Maps port names to the Links that are connected to it.
Definition linkMap.h:30
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
ProfileTool is a class loadable through the factory which allows dynamic addition of profiling capabi...
Definition profiletool.h:38
Definition rankInfo.h:24
Class to manage real-time events (signals and alarms).
Definition realtime.h:175
Main control class for a SST Simulation.
Definition simulation.h:121
static Simulation * getSimulation()
Return a pointer to the singleton instance of the Simulation.
Definition simulation.h:182
void setupSimActions()
Setup external control actions (forced stops, signal handling.
Definition simulation.cc:420
bool isWireUpFinished()
Returns true when the Wireup is finished.
Definition simulation.h:329
void setEndSim()
Set EndSim Called by SyncMgr when interactive console ready to shutdown.
Definition simulation.cc:1245
Cycle_t getNextClockCycle(TimeConverter tc, int priority=CLOCKPRIORITY)
Returns the next Cycle that the TimeConverter would fire.
Definition simulation.cc:1452
static Output & getSimulationOutput()
Return the base simulation Output class instance.
Definition simulation.h:188
static SST::Util::Filesystem filesystem
Filesystem object that will be used to ensure all core-created files end up in the directory specifie...
Definition simulation.h:453
static TimeLord * getTimeLord()
Return the TimeLord associated with this Simulation.
Definition simulation.h:185
static Simulation * createSimulation(RankInfo my_rank, RankInfo num_ranks, bool restart, SimTime_t currentSimCycle, int currentPriority)
Create new simulation.
Definition simulation.cc:244
static Output sim_output
Output.
Definition simulation.h:579
void signalShutdown(bool abnormal)
Signal Shutdown Called when a signal needs to terminate SST E.g., SIGINT or SIGTERM has been seen abn...
Definition simulation.cc:1212
TimeConverter minPartToTC(SimTime_t cycles) const
Get a handle to a TimeConverter.
Definition simulation.cc:188
void requireLibrary(const std::string &name)
Signifies that a library is required for this simulation.
Definition simulation.cc:548
RankInfo getNumRanks() const
Get the number of parallel ranks in the simulation.
Definition simulation.h:149
std::map< std::pair< SimTime_t, int >, Clock * > clockMap_t
Definition simulation.h:174
bool parseSignalString(std::string &arg, std::string &name, Params &params)
Helper for signal string parsing.
Definition simulation.cc:490
ComponentInfo * getComponentInfo(const ComponentId_t &id) const
returns the ComponentInfo object for the given ID
Definition simulation.h:302
Cycle_t reregisterClock(TimeConverter tc, Clock::HandlerBase *handler, int priority)
Reactivate an existing clock and handler.
Definition simulation.cc:1440
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.
Definition simulation.cc:1800
std::vector< std::pair< ComponentId_t, uint64_t > > component_blob_offsets_
vector to hold offsets of component blobs in checkpoint files
Definition simulation.h:572
SST::Statistics::StatisticProcessingEngine stat_engine
Statistics Engine.
Definition simulation.h:583
void setOutputDirectory(const std::string &outDir)
Set the output directory for this simulation.
Definition simulation.h:318
SimTime_t getCurrentSimCycle() const
Return the current simulation time as a cycle count.
Definition simulation.cc:156
void insertActivity(SimTime_t time, Activity *ev)
Insert an activity to fire at a specified time.
Definition simulation.cc:1487
SimTime_t getEndSimCycle() const
Return the end simulation time as a cycle count.
Definition simulation.cc:162
void unregisterClock(TimeConverter tc, Clock::HandlerBase *handler, int priority)
Remove a clock handler from the list of active clock handlers.
Definition simulation.cc:1476
static Factory * factory
Factory used to generate the simulation components.
Definition simulation.h:447
int getCurrentPriority() const
Return the current priority.
Definition simulation.cc:168
SimTime_t getClockForHandler(Clock::HandlerBase *handler)
Gets the clock the handler is registered with, represented by it's factor.
Definition simulation.cc:1464
uint32_t getNextLinkOrderTag()
Gets the next value for the order field of the link.
Definition simulation.h:564
static SimTime_t getLocalMinimumNextActivityTime()
Gets the minimum next activity time across all TimeVortices in the Rank.
Definition simulation.cc:560
void endSimulation()
Normal Shutdown.
Definition simulation.cc:1254
CheckpointAction * getCheckpointAction() const
Return the checkpoint event.
Definition simulation.h:338
static void shutdown()
Used to signify the end of simulation.
Definition simulation.cc:265
BaseComponent * getComponent(const ComponentId_t &id) const
returns the component with the given ID
Definition simulation.h:289
std::string & getOutputDirectory()
Returns the output directory of the simulation.
Definition simulation.h:155
void checkpoint(const std::string &checkpoint_filename)
Write the partition specific checkpoint data.
Definition simulation.cc:1980
static TimeLord timeLord
TimeLord of the simulation.
Definition simulation.h:577
void printStatus(bool fullStatus)
Causes the current status of the simulation to be printed to stderr.
Definition simulation.cc:1338
void consoleShutdown(bool abnormal)
Console Shutdown Called when a shutdown command or watchpoint shutdown action trigger needs to termin...
Definition simulation.cc:1225
const ComponentInfoMap & getComponentInfoMap() const
Returns reference to the Component Info Map.
Definition simulation.h:286
UnitAlgebra getElapsedSimTime() const
Return the elapsed simulation time as a time.
Definition simulation.cc:174
Exit * getExit() const
Return the exit event.
Definition simulation.h:214
void setup()
Perform the setup() and run phases of the simulation.
Definition simulation.cc:969
static void notifySignal()
Sets an internal flag for signaling the simulation.
Definition simulation.cc:1326
UnitAlgebra getEndSimTime() const
Return the end simulation time as a time.
Definition simulation.cc:180
void findRankSyncInterval()
Functions to compute the current rank and thread sync intervals.
Definition simulation.cc:868
void complete()
Perform the complete() phase of simulation.
Definition simulation.cc:934
void initializeProfileTools(const std::string &config)
Performance Tracking Information.
Definition simulation.cc:1572
RankInfo getRank() const
Get this instance's parallel rank.
Definition simulation.h:146
void initialize()
Perform the init() phase of simulation.
Definition simulation.cc:886
Statistics::StatisticProcessingEngine * getStatisticsProcessingEngine()
Return the Statistic Processing Engine associated with this Simulation.
Definition simulation.cc:1512
void checkpoint_append_registry(const std::string &registry_name, const std::string &blob_name)
Append partitions registry information.
Definition simulation.cc:1958
SimulationRunMode getSimulationMode() const
Get the run mode of the simulation (e.g.
Definition simulation.h:128
RankInfo getRankForLinkOnRestart(RankInfo rank, LinkId_t UNUSED(id))
Function used to get the rank for a link on restart.
Definition simulation.h:438
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.
Definition simulation.cc:573
static void emergencyShutdown()
Emergency Shutdown Called when a fatal event has occurred.
Definition simulation.cc:1196
void adjustTimeAtSimEnd()
Adjust clocks and time to reflect precise simulation end time which may differ in parallel simulation...
Definition simulation.cc:1276
TimeConverter registerClock(const std::string &freq, Clock::HandlerBase *handler, int priority)
Register a handler to be called on a set frequency.
Definition simulation.cc:1389
An optional heartbeat to show progress in a simulation.
Definition heartbeat.h:34
Forms the base class for statistics output generation within the SST core.
Definition statoutput.h:54
An SST core component that handles timing and event processing informing all registered Statistics to...
Definition statengine.h:55
Definition syncManager.h:192
Definition syncManager.h:121
A class to convert between a component's view of time and the core's view of time.
Definition timeConverter.h:31
Class for creating and managing TimeConverter objects.
Definition timeLord.h:41
Primary Event Queue.
Definition timeVortex.h:32
Performs Unit math in full precision.
Definition unitAlgebra.h:107
Class used to track various performance data during simulation execution.
Definition basicPerf.h:100
Class used to manage files and directories.
Definition filesystem.h:35
Definition perfReporter.h:97
Definition configStatistic.h:143
Definition simulation.h:94
Class to sort the contents of the TimeVortex in preparation for checkpointing.
Definition simulation.h:92