SST 16.1.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 Clock* 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 /**
367 Register a clock on a restart
368 */
369 void registerClock_restart(SimTime_t factor, Clock::HandlerBase* handler, int priority);
370
371 /** Returns the next Cycle that the TimeConverter would fire. */
372 Cycle_t getNextClockCycle(TimeConverter tc, int priority = CLOCKPRIORITY);
373
374 /** Gets the clock the handler is registered with, represented by it's factor
375 *
376 * @param handler Clock handler to search for
377 *
378 * @return Factor of TimeConverter for the clock the specified
379 * handler is registered with. If the handler is not currently
380 * registered with a clock, returns 0.
381 */
382 SimTime_t getClockForHandler(Clock::HandlerBase* handler);
383
384 void registerClockGroup(TimeConverter tc, Clock::Group* group);
385 void registerClockGroup(SimTime_t factor, Clock::Group* group);
386
387 /** Return the Statistic Processing Engine associated with this Simulation */
389
390
391 friend class Link;
392 friend class Action;
393 friend class Output;
394 // To enable main to set up globals
395 friend int ::main(int argc, char** argv);
396
397 Simulation(RankInfo my_rank, RankInfo num_ranks, bool restart, SimTime_t currentSimCycle, int currentPriority);
398 Simulation(const Simulation&) = delete; // Don't Implement
399 Simulation& operator=(const Simulation&) = delete; // Don't implement
400
401 /** Get a handle to a TimeConverter
402 * @param cycles Frequency which is the base of the TimeConverter
403 */
404 TimeConverter minPartToTC(SimTime_t cycles) const;
405
406 static void writeCheckpointConfigGraph(ConfigGraph* graph);
407 void scheduleCheckpoint();
408 void scheduleInteractiveConsole(const std::string& msg);
409
410 /**
411 Write the partition specific checkpoint data
412 */
413 void checkpoint(const std::string& checkpoint_filename);
414
415 /**
416 Append partitions registry information
417 */
418 void checkpoint_append_registry(const std::string& registry_name, const std::string& blob_name);
419
420 /**
421 Write the global data to a binary file and create the registry
422 and write the header info
423 */
424 void checkpoint_write_globals(int checkpoint_id, const std::string& checkpoint_filename,
425 const std::string& registry_filename, const std::string& globals_filename);
426 void restart(ConfigGraph* graph);
427
428 void discoverRemoteLinks();
429
430 /**** Functions/variables needed for discoverRemoteLinks() ****/
433 std::vector<std::pair<LinkId_t, RankInfo>>* xfer_vec = nullptr;
434
435 void discoverRemoteLinksMoveData(
436 std::vector<std::pair<LinkId_t, RankInfo>>& send_vec, std::vector<std::pair<LinkId_t, RankInfo>>& recv_vec);
437
438 /**************************************************************/
439
440 /**
441 Function used to get the rank for a link on restart. A rank of
442 -1 on the return means that the partitioning stayed the same
443 between checkpoint and restart and the original rank info
444 stored in the checkpoint should be used.
445 */
446 RankInfo getRankForLinkOnRestart(RankInfo rank, LinkId_t UNUSED(id))
447 {
448 if ( serial_restart_ ) return RankInfo(0, 0);
449 return RankInfo(rank.rank, rank.thread);
450 }
451
452 void initialize_interactive_console(const std::string& type);
453
454 /** Factory used to generate the simulation components */
456
457 /**
458 Filesystem object that will be used to ensure all core-created
459 files end up in the directory specified by --output-directory.
460 */
462
463 static void resizeBarriers(uint32_t nthr);
464 static Core::ThreadSafe::Barrier initBarrier;
465 static Core::ThreadSafe::Barrier completeBarrier;
466 static Core::ThreadSafe::Barrier setupBarrier;
467 static Core::ThreadSafe::Barrier runBarrier;
468 static Core::ThreadSafe::Barrier exitBarrier;
469 static Core::ThreadSafe::Barrier finishBarrier;
470 static std::mutex simulationMutex;
471
472 static Util::BasicPerfTracker basicPerf;
473
474 // Support for crossthread links
475 static Core::ThreadSafe::Spinlock cross_thread_lock;
476 static std::map<LinkId_t, Link*> cross_thread_links;
477 bool direct_interthread;
478
479 Component* createComponent(ComponentId_t id, const std::string& name, Params& params);
480
481 TimeVortex* getTimeVortex() const { return timeVortex; }
482
483 /** Emergency Shutdown
484 * Called when a fatal event has occurred
485 */
486 static void emergencyShutdown();
487
488 /** Signal Shutdown
489 * Called when a signal needs to terminate SST
490 * E.g., SIGINT or SIGTERM has been seen
491 * abnormal indicates whether this was unexpected or not
492 */
493 void signalShutdown(bool abnormal);
494
495 /** Console Shutdown
496 * Called when a shutdown command or watchpoint shutdown action trigger needs to terminate SST
497 */
498 void consoleShutdown(bool abnormal);
499
500
501 /** Set EndSim
502 * Called by SyncMgr when interactive console ready to shutdown
503 */
504 void setEndSim();
505
506 /** Normal Shutdown
507 */
508 void endSimulation();
509 void endSimulation(SimTime_t end);
510
511 void checkIndependent();
512
513 enum ShutdownMode_t {
514 SHUTDOWN_CLEAN, /* Normal shutdown */
515 SHUTDOWN_SIGNAL, /* SIGINT or SIGTERM received */
516 SHUTDOWN_EMERGENCY, /* emergencyShutdown() called */
517 };
518
519 friend class SyncManager;
520
521 // TODO: Reorder data members to reduce excessive padding (currently 42 bytes padding; 2 bytes of padding possible)
522 //
523 // Optimal fields order: timeVortex, threadMinPartTC, current_activity, interThreadMinLatency, syncManager,
524 // m_heartbeat, checkpoint_action_, real_time_, interactive_, stop_at_, clockDivisor, currentSimCycle, endSimCycle,
525 // run_phase_start_time_, run_phase_total_time_, init_phase_start_time_, init_phase_total_time_,
526 // complete_phase_start_time_, complete_phase_total_time_, my_rank, num_ranks, interThreadLatencies,
527 // component_blob_offsets_, timeVortexType, interactive_type_, interactive_start_, replay_file_, interactive_msg_,
528 // tv_sort_, clockResolution, output_directory, checkpoint_prefix_, globalOutputFileName, clockMap, profile_tools,
529 // profiler_map, link_restart_tracking, event_handler_restart_tracking, compInfoMap, one_shot_manager_, stat_engine,
530 // untimed_phase, signal_arrived_, shutdown_mode_, runMode, currentPriority, checkpoint_id_, direct_interthread,
531 // endSim, independent, wireUpFinished_, enter_interactive_, serial_restart_
532
533 TimeVortex* timeVortex = nullptr;
534 std::string timeVortexType; // Required for checkpoint
535 TimeConverter threadMinPartTC; // Unused...?
536 Activity* current_activity;
537 static SimTime_t minPart;
538 static TimeConverter minPartTC;
539 std::vector<SimTime_t> interThreadLatencies;
540 SimTime_t interThreadMinLatency = MAX_SIMTIME_T;
541 SyncManager* syncManager;
542 ComponentInfoMap compInfoMap;
543 clockMap_t clockMap;
544 static Exit* m_exit;
545 SimulatorHeartbeat* m_heartbeat = nullptr;
546 CheckpointAction* checkpoint_action_;
547 static std::string checkpoint_directory_;
548 static std::string checkpoint_configgraph_;
549 bool endSim = false;
550 bool independent; // true if no links leave thread (i.e. no syncs required)
551 static std::atomic<int> untimed_msg_count;
552 unsigned int untimed_phase;
553 volatile sig_atomic_t signal_arrived_; // true if a signal has arrived
554 ShutdownMode_t shutdown_mode_;
555 bool enter_shutdown_ = false;
556 bool wireUpFinished_;
557 RealTimeManager* real_time_;
558 std::string interactive_type_ = "";
559 std::string interactive_start_ = "";
560 std::string replay_file_ = "";
561 InteractiveConsole* interactive_ = nullptr;
562 bool enter_interactive_ = false;
563 std::string interactive_msg_;
564 SimTime_t stop_at_ = 0;
565
566 uint32_t next_link_order_tag_ = 1;
567
568 /**
569 Gets the next value for the order field of the link. The ordering of events based on links will be based on
570 the order that configureLink() is called.
571 */
572 uint32_t getNextLinkOrderTag() { return next_link_order_tag_++; }
573
574 // OneShotManager
575 Core::OneShotManager one_shot_manager_;
576
577 /**
578 vector to hold offsets of component blobs in checkpoint files
579 */
580 std::vector<std::pair<ComponentId_t, uint64_t>> component_blob_offsets_;
581
582 pvt::TimeVortexSort tv_sort_;
583
584 /** TimeLord of the simulation */
586 /** Output */
587 static Output sim_output;
588
589
590 /** Statistics Engine */
592
593 /** Performance Tracking Information **/
594
595 void initializeProfileTools(const std::string& config);
596
597 std::map<std::string, SST::Profile::ProfileTool*> profile_tools;
598 // Maps the component profile points to profiler names
599 std::map<std::string, std::vector<std::string>> profiler_map;
600
601 template <typename T>
602 std::vector<T*> getProfileTool(std::string point)
603 {
604 std::vector<T*> ret;
605 try {
606 std::vector<std::string>& profilers = profiler_map.at(point);
607
608 for ( auto& x : profilers ) {
609 try {
610 SST::Profile::ProfileTool* val = profile_tools.at(x);
611
612 T* tool = dynamic_cast<T*>(val);
613 if ( !tool ) {
614 // Not the right type, fatal
615 Output::getDefaultObject().fatal(CALL_INFO_LONG, 1,
616 "ERROR: wrong type of profiling tool found (name = %s). Check to make sure the profiling "
617 "points enabled for this tool accept the type specified\n",
618 x.c_str());
619 }
620 ret.push_back(tool);
621 }
622 catch ( const std::out_of_range& e ) {
623 // This shouldn't happen. If it does, then something
624 // didn't get initialized correctly.
625 Output::getDefaultObject().fatal(CALL_INFO_LONG, 1,
626 "INTERNAL ERROR: ProfileTool referred to in profiler_map not found in profile_tools map\n");
627 return ret;
628 }
629 }
630 }
631 catch ( const std::out_of_range& e ) {
632 // point not turned on, return nullptr
633 return ret;
634 }
635
636
637 return ret;
638 }
639
640
641#if SST_PERFORMANCE_INSTRUMENTING
642 FILE* fp;
643#endif
644
645#if SST_PERIODIC_PRINT
646 uint64_t periodicCounter = 0;
647#endif
648
649#if SST_RUNTIME_PROFILING
650 uint64_t sumtime = 0;
651 uint64_t runtime = 0;
652 struct timeval start, end, diff;
653 struct timeval sumstart, sumend, sumdiff;
654#endif
655
656
657#if SST_EVENT_PROFILING
658 uint64_t rankLatency = 0; // Serialization time
659 uint64_t messageXferSize = 0;
660
661 uint64_t rankExchangeCounter = 0; // Num rank peer exchanges
662
663
664 // Profiling functions
665 void incrementSerialCounters(uint64_t count);
666
667#endif
668
669#if SST_HIGH_RESOLUTION_CLOCK
670 uint64_t clockDivisor = 1e9;
671 std::string clockResolution = "ns";
672#else
673 uint64_t clockDivisor = 1e6;
674 std::string clockResolution = "us";
675#endif
676
677 // Run mode for the simulation
678 SimulationRunMode runMode;
679
680 // Track current simulated time
681 SimTime_t currentSimCycle = 0;
682 int currentPriority = 0;
683 SimTime_t endSimCycle = 0;
684
685 // Rank information
686 RankInfo my_rank;
687 RankInfo num_ranks;
688
689 std::string output_directory;
690
691 double run_phase_start_time_;
692 double run_phase_total_time_;
693 double init_phase_start_time_;
694 double init_phase_total_time_;
695 double complete_phase_start_time_;
696 double complete_phase_total_time_;
697
698 static std::unordered_map<std::thread::id, Simulation*> instanceMap;
699 static std::vector<Simulation*> instanceVec_;
700
701 /******** Checkpoint/restart tracking data structures ***********/
702 std::map<LinkId_t, Link*> link_restart_tracking;
703 std::map<uintptr_t, uintptr_t> event_handler_restart_tracking;
704 uint32_t checkpoint_id_ = 0;
705 std::string checkpoint_prefix_ = "";
706 std::string globalOutputFileName = "";
707 std::string version_ = "";
708 std::string arch_ = "";
709 std::string os_ = "";
710 bool serial_restart_ = false;
711
712 // Config object used by the simulation
713 static Config config;
714 static StatsConfig* stats_config_;
715
716 void printSimulationState();
717
718 friend void wait_my_turn_start();
719 friend void wait_my_turn_end();
720
721private:
722 /**
723 * Returns the time of the next item to be executed
724 * that is in the TImeVortex of the Simulation
725 */
726 SimTime_t getNextActivityTime() const;
727};
728
729// Function to allow for easy serialization of threads while debugging
730// code. Can only be used when you can guarantee all threads will be
731// taking the same code path. If you can't guarantee that, then use a
732// spinlock to make sure only one person is in a given region at a
733// time. ONLY FOR DEBUG USE.
734void wait_my_turn_start(Core::ThreadSafe::Barrier& barrier, int thread, int total_threads);
735
736void wait_my_turn_end(Core::ThreadSafe::Barrier& barrier, int thread, int total_threads);
737
738} // namespace SST
739
740#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:98
A recurring event to trigger checkpoint generation.
Definition checkpointAction.h:69
Base classes for clock handlers.
Definition clock.h:146
A Clock class.
Definition clock.h:40
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:189
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:47
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:1460
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:461
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:587
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:1441
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:1837
std::vector< std::pair< ComponentId_t, uint64_t > > component_blob_offsets_
vector to hold offsets of component blobs in checkpoint files
Definition simulation.h:580
SST::Statistics::StatisticProcessingEngine stat_engine
Statistics Engine.
Definition simulation.h:591
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:1522
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:1484
static Factory * factory
Factory used to generate the simulation components.
Definition simulation.h:455
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:1472
uint32_t getNextLinkOrderTag()
Gets the next value for the order field of the link.
Definition simulation.h:572
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:2017
static TimeLord timeLord
TimeLord of the simulation.
Definition simulation.h:585
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
void registerClock_restart(SimTime_t factor, Clock::HandlerBase *handler, int priority)
Register a clock on a restart.
Definition simulation.cc:1453
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:1607
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:1547
void checkpoint_append_registry(const std::string &registry_name, const std::string &blob_name)
Append partitions registry information.
Definition simulation.cc:1995
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:446
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