SST 15.0
Structural Simulation Toolkit
baseComponent.h
1// Copyright 2009-2025 NTESS. Under the terms
2// of Contract DE-NA0003525 with NTESS, the U.S.
3// Government retains certain rights in this software.
4//
5// Copyright (c) 2009-2025, NTESS
6// All rights reserved.
7//
8// This file is part of the SST software package. For license
9// information, see the LICENSE file in the top level directory of the
10// distribution.
11
12#ifndef SST_CORE_BASECOMPONENT_H
13#define SST_CORE_BASECOMPONENT_H
14
15#include "sst/core/clock.h"
16#include "sst/core/componentInfo.h"
17#include "sst/core/eli/elementinfo.h"
18#include "sst/core/event.h"
19#include "sst/core/factory.h"
20#include "sst/core/oneshot.h"
21#include "sst/core/portModule.h"
22#include "sst/core/profile/componentProfileTool.h"
23#include "sst/core/serialization/serializable_base.h"
24#include "sst/core/serialization/serialize.h"
25#include "sst/core/sst_types.h"
26#include "sst/core/statapi/statbase.h"
27#include "sst/core/statapi/statengine.h"
28#include "sst/core/warnmacros.h"
29
30#include <functional>
31#include <map>
32#include <string>
33#include <vector>
34
35using namespace SST::Statistics;
36
37namespace SST {
38
39class Component;
41class Clock;
42class Link;
43class LinkMap;
44class Module;
45class Params;
46class Simulation;
47class Simulation_impl;
48class SubComponent;
50class TimeConverter;
51class UnitAlgebra;
52class WatchPoint;
53
54namespace Core::Serialization::pvt {
56}
57
58/**
59 * Main component object for the simulation.
60 */
62{
63
64 friend class Component;
65 friend class ComponentExtension;
66 friend class ComponentInfo;
67 friend class SubComponent;
68 friend class SubComponentSlotInfo;
69
70protected:
71 using StatCreateFunction =
73 const std::string& /*type*/, const std::string& /*name*/, const std::string& /*subId*/, Params&)>;
74
75 BaseComponent() = default; // For serialization only
76
77public:
78 explicit BaseComponent(ComponentId_t id);
79 virtual ~BaseComponent();
80
81 BaseComponent(const BaseComponent&) = delete;
82 BaseComponent& operator=(const BaseComponent&) = delete;
83
84 const std::string& getType() const { return my_info->getType(); }
85
86 /** Returns unique component ID */
87 inline ComponentId_t getId() const { return my_info->id_; }
88
89 /** Returns Component Statistic load level */
90 inline uint8_t getStatisticLoadLevel() const { return my_info->statLoadLevel; }
91
92 /** Called when SIGINT or SIGTERM has been seen.
93 * Allows components opportunity to clean up external state.
94 */
95 virtual void emergencyShutdown() {}
96
97 /** Returns Component/SubComponent Name */
98 inline const std::string& getName() const { return my_info->getName(); }
99
100 /** Returns the name of the parent Component, or, if called on a
101 * Component, the name of that Component. */
102 inline const std::string& getParentComponentName() const { return my_info->getParentComponentName(); }
103
104 /** Used during the init phase. The method will be called each
105 phase of initialization. Initialization ends when no components
106 have sent any data. */
107 virtual void init(unsigned int UNUSED(phase)) {}
108 /** Used during the complete phase after the end of simulation.
109 The method will be called each phase of complete. Complete phase
110 ends when no components have sent any data. */
111 virtual void complete(unsigned int UNUSED(phase)) {}
112 /** Called after all components have been constructed and
113 initialization has completed, but before simulation time has
114 begun. */
115 virtual void setup() {}
116 /** Called after complete phase, but before objects are
117 destroyed. A good place to print out statistics. */
118 virtual void finish() {}
119
120 /** Currently unused function */
121 virtual bool Status() { return 0; }
122
123 /**
124 * Called by the Simulation to request that the component
125 * print it's current status. Useful for debugging.
126 * @param out The Output class which should be used to print component status.
127 */
128 virtual void printStatus(Output& UNUSED(out)) { return; }
129
130 /** Get the core timebase */
132 /** Return the current simulation time as a cycle count*/
133 SimTime_t getCurrentSimCycle() const;
134 /** Return the current priority */
135 int getCurrentPriority() const;
136 /** Return the elapsed simulation time as a time */
138 /** Return the end simulation time as a cycle count*/
139 SimTime_t getEndSimCycle() const;
140 /** Return the end simulation time as a time */
142 /** Get this instance's parallel rank */
143 RankInfo getRank() const;
144 /** Get the number of parallel ranks in the simulation */
145 RankInfo getNumRanks() const;
146 /** Return the base simulation Output class instance */
148
149 /**
150 Return the simulated time since the simulation began in units specified by
151 the parameter.
152
153 @param tc TimeConverter specifying the units
154 */
155 [[deprecated("Use of shared TimeConverter objects is deprecated. Use 'getCurrentSimTime(TimeConverter tc)' "
156 "(i.e., no pointer) instead.")]]
157 SimTime_t getCurrentSimTime(TimeConverter* tc) const;
158 SimTime_t getCurrentSimTime(TimeConverter tc) const;
159
160 /**
161 Return the simulated time since the simulation began in the
162 default timebase
163 */
164 inline SimTime_t getCurrentSimTime() const { return getCurrentSimTime(my_info->defaultTimeBase); }
165
166 /**
167 Return the simulated time since the simulation began in
168 timebase specified
169
170 @param base Timebase frequency in SI Units
171 */
172 SimTime_t getCurrentSimTime(const std::string& base) const;
173
174 /** Utility function to return the time since the simulation began in nanoseconds */
175 SimTime_t getCurrentSimTimeNano() const;
176 /** Utility function to return the time since the simulation began in microseconds */
177 SimTime_t getCurrentSimTimeMicro() const;
178 /** Utility function to return the time since the simulation began in milliseconds */
179 SimTime_t getCurrentSimTimeMilli() const;
180
181 /** Get the amount of real-time spent executing the run phase of
182 * the simulation.
183 *
184 * @return real-time in seconds spent executing the run phase
185 */
186 double getRunPhaseElapsedRealTime() const;
187
188 /** Get the amount of real-time spent executing the init phase of
189 * the simulation.
190 *
191 * @return real-time in seconds spent executing the init phase
192 */
193 double getInitPhaseElapsedRealTime() const;
194
195 /** Get the amount of real-time spent executing the complete phase of
196 * the simulation.
197 *
198 * @return real-time in seconds spent executing the complete phase
199 */
200 double getCompletePhaseElapsedRealTime() const;
201
202
203 /** Add a watch point to all handlers in the Component Tree
204 */
205 void addWatchPoint(WatchPoint* pt);
206
207 /** Remove a watch point from all handlers in the Component Tree
208 */
210
211
212private:
213 /** Recursively add Watch point to myself and all my children
214 */
215 void addWatchPointRecursive(WatchPoint* pt);
216
217 /** Recursively removes a Watch point from myself and all my
218 * children
219 */
220 void removeWatchPointRecursive(WatchPoint* pt);
221
222protected:
223 /** Check to see if the run mode was set to INIT
224 @return true if simulation run mode is set to INIT
225 */
226 bool isSimulationRunModeInit() const;
227
228 /** Check to see if the run mode was set to RUN
229 @return true if simulation run mode is set to RUN
230 */
231 bool isSimulationRunModeRun() const;
232
233 /** Check to see if the run mode was set to BOTH
234 @return true if simulation run mode is set to BOTH
235 */
236 bool isSimulationRunModeBoth() const;
237
238 /** Returns the output directory of the simulation
239 * @return Directory in which simulation outputs should be
240 * placed. Returns empty string if output directory not set by
241 * user.
242 */
243 std::string& getOutputDirectory() const;
244
245 /** Signifies that a library is required for this simulation.
246 * Causes the Factory to verify that the required library is
247 * loaded.
248 *
249 * NOTE: This function should rarely be required, as most
250 * dependencies are automatically detected in the simulator core.
251 * However, if the component uses an event from another library
252 * that is not wholly defined in a header file, this call may be
253 * required to ensure that all the code from the event is loaded.
254 * Similarly, if you use a class from another library that does
255 * not have ELI information, this call may also be required to
256 * make sure all dependencies are loaded.
257 *
258 * @param name Name of library this BaseComponent depends on
259 */
260 void requireLibrary(const std::string& name);
261
262
263 /** Determine if a port name is connected to any links */
264 bool isPortConnected(const std::string& name) const;
265
266 /** Configure a Link
267 * @param name - Port Name on which the link to configure is attached.
268 * @param time_base - Time Base of the link. If nullptr is passed in, then it
269 * will use the Component defaultTimeBase
270 * @param handler - Optional Handler to be called when an Event is received
271 * @return A pointer to the configured link, or nullptr if an error occured.
272 */
273
274 [[deprecated(
275 "Use of shared TimeConverter objects is deprecated. Use 'configureLink(const std::string& name, TimeConverter "
276 "time_base, EventHandlerBase* handler)' (i.e., no TimeConverter pointer) instead.")]]
277 Link* configureLink(const std::string& name, TimeConverter* time_base, Event::HandlerBase* handler = nullptr);
278 Link* configureLink(const std::string& name, TimeConverter time_base, Event::HandlerBase* handler = nullptr);
279 /** Configure a Link
280 * @param name - Port Name on which the link to configure is attached.
281 * @param time_base - Time Base of the link as a string
282 * @param handler - Optional Handler to be called when an Event is received
283 * @return A pointer to the configured link, or nullptr if an error occured.
284 */
285 Link* configureLink(const std::string& name, const std::string& time_base, Event::HandlerBase* handler = nullptr);
286 /** Configure a Link
287 * @param name - Port Name on which the link to configure is attached.
288 * @param time_base - Time Base of the link as a UnitAlgebra
289 * @param handler - Optional Handler to be called when an Event is received
290 * @return A pointer to the configured link, or nullptr if an error occured.
291 */
292 Link* configureLink(const std::string& name, const UnitAlgebra& time_base, Event::HandlerBase* handler = nullptr);
293 /** Configure a Link
294 * @param name - Port Name on which the link to configure is attached.
295 * @param handler - Optional Handler to be called when an Event is received
296 * @return A pointer to the configured link, or nullptr if an error occured.
297 */
298 Link* configureLink(const std::string& name, Event::HandlerBase* handler = nullptr);
299
300 /** Configure a SelfLink (Loopback link)
301 * @param name - Name of the self-link port
302 * @param time_base - Time Base of the link. If nullptr is passed in, then it
303 * will use the Component defaultTimeBase
304 * @param handler - Optional Handler to be called when an Event is received
305 * @return A pointer to the configured link, or nullptr if an error occured.
306 */
307 [[deprecated("Use of shared TimeConverter objects is deprecated. Use 'configureSelfLink(const std::string& name, "
308 "TimeConverter time_base, EventHandlerBase* handler)' (i.e., no TimeConverter pointer) instead.")]]
309 Link* configureSelfLink(const std::string& name, TimeConverter* time_base, Event::HandlerBase* handler = nullptr);
310 Link* configureSelfLink(const std::string& name, TimeConverter time_base, Event::HandlerBase* handler = nullptr);
311
312 /** Configure a SelfLink (Loopback link)
313 * @param name - Name of the self-link port
314 * @param time_base - Time Base of the link as a string
315 * @param handler - Optional Handler to be called when an Event is received
316 * @return A pointer to the configured link, or nullptr if an error occured.
317 */
319 const std::string& name, const std::string& time_base, Event::HandlerBase* handler = nullptr);
320 /** Configure a SelfLink (Loopback link)
321 * @param name - Name of the self-link port
322 * @param time_base - Time Base of the link as a UnitAlgebra
323 * @param handler - Optional Handler to be called when an Event is received
324 * @return A pointer to the configured link, or nullptr if an error occured.
325 */
327 const std::string& name, const UnitAlgebra& time_base, Event::HandlerBase* handler = nullptr);
328 /** Configure a SelfLink (Loopback link)
329 * @param name - Name of the self-link port
330 * @param handler - Optional Handler to be called when an Event is received
331 * @return A pointer to the configured link, or nullptr if an error occured.
332 */
333 Link* configureSelfLink(const std::string& name, Event::HandlerBase* handler = nullptr);
334
335 /** Registers a clock for this component.
336 @param freq Frequency for the clock in SI units
337 @param handler Pointer to Clock::HandlerBase which is to be invoked
338 at the specified interval
339 @param regAll Should this clock period be used as the default
340 time base for all of the links connected to this component
341 @return the TimeConverter object representing the clock frequency
342 */
343 TimeConverter* registerClock(const std::string& freq, Clock::HandlerBase* handler, bool regAll = true);
344
345 /** Registers a clock for this component.
346 @param freq Frequency for the clock as a UnitAlgebra object
347 @param handler Pointer to Clock::HandlerBase which is to be invoked
348 at the specified interval
349 @param regAll Should this clock period be used as the default
350 time base for all of the links connected to this component
351 @return the TimeConverter object representing the clock frequency
352 */
353 TimeConverter* registerClock(const UnitAlgebra& freq, Clock::HandlerBase* handler, bool regAll = true);
354
355 /** Registers a clock for this component.
356 @param tc TimeConverter object specifying the clock frequency
357 @param handler Pointer to Clock::HandlerBase which is to be invoked
358 at the specified interval
359 @param regAll Should this clock period be used as the default
360 time base for all of the links connected to this component
361 @return the TimeConverter object representing the clock frequency
362 */
363 [[deprecated(
364 "Use of shared TimeConverter objects is deprecated. Use 'registerClock(TimeConverter tc, Clock::HandlerBase* "
365 "handler, bool regAll)' (i.e., no TimeConverter pointer) instead.")]]
366 TimeConverter* registerClock(TimeConverter* tc, Clock::HandlerBase* handler, bool regAll = true);
367 TimeConverter* registerClock(TimeConverter tc, Clock::HandlerBase* handler, bool regAll = true);
368
369 /** Removes a clock handler from the component */
370 [[deprecated("Use of shared TimeConverter objects is deprecated. Use 'unregisterClock(TimeConverter tc, "
371 "Clock::HandlerBase* handler)' (i.e., no TimeConverter pointer) instead.")]]
374
375 /** Reactivates an existing Clock and Handler
376 * @return time of next time clock handler will fire
377 *
378 * Note: If called after the simulation run loop (e.g., in finish() or complete()),
379 * will return the next time of the clock past when the simulation ended. There can
380 * be a small lag between simulation end and detection of simulation end during which
381 * clocks can run a few extra cycles. As a result, the return value just prior to
382 * simulation end may be greater than the value returned after simulation end.
383 */
384 [[deprecated("Use of shared TimeConverter objects is deprecated. Use 'reregisterClock(TimeConverter freq, "
385 "Clock::HandlerBase* handler)' (i.e., no TimeConverter pointer) instead.")]]
386 Cycle_t reregisterClock(TimeConverter* freq, Clock::HandlerBase* handler);
387 Cycle_t reregisterClock(TimeConverter freq, Clock::HandlerBase* handler);
388
389 /** Returns the next Cycle that the TimeConverter would fire
390 If called prior to the simulation run loop, next Cycle is 0.
391 If called after the simulation run loop completes (e.g., during
392 complete() or finish()), next Cycle is one past the end time of
393 the simulation. See Note in reregisterClock() for additional guidance
394 when calling this function after simulation ends.
395 */
396 [[deprecated(
397 "Use of shared TimeConverter objects is deprecated. Use 'getNextClockCycle(TimeConverter freq)' (i.e., "
398 "no TimeConverter pointer) instead.")]]
399 Cycle_t getNextClockCycle(TimeConverter* freq);
400 Cycle_t getNextClockCycle(TimeConverter freq);
401
402 /** Registers a default time base for the component and optionally
403 sets the the component's links to that timebase. Useful for
404 components which do not have a clock, but would like a default
405 timebase.
406 @param base Frequency for the clock in SI units
407 @param regAll Should this clock period be used as the default
408 time base for all of the links connected to this component
409 */
410 TimeConverter* registerTimeBase(const std::string& base, bool regAll = true);
411
412 TimeConverter* getTimeConverter(const std::string& base) const;
413 TimeConverter* getTimeConverter(const UnitAlgebra& base) const;
414
415 bool isStatisticShared(const std::string& statName, bool include_me = false)
416 {
417 if ( include_me ) {
418 if ( doesComponentInfoStatisticExist(statName) ) {
419 return true;
420 }
421 }
422 if ( my_info->sharesStatistics() ) {
423 return my_info->parent_info->component->isStatisticShared(statName, true);
424 }
425 else {
426 return false;
427 }
428 }
429
430 void initiateInteractive(const std::string& msg);
431
432private:
433 ImplementSerializable(SST::BaseComponent)
434 void serialize_order(SST::Core::Serialization::serializer& ser) override;
435
436
437 /**
438 Handles the profile points, default time base, handler tracking
439 and checkpointing.
440 */
441 void registerClock_impl(TimeConverter* tc, Clock::HandlerBase* handler, bool regAll);
442
443 /**
444 Handles default timebase setup
445 */
446 Link* configureLink_impl(const std::string& name, SimTime_t time_base, Event::HandlerBase* handler = nullptr);
447
448 template <typename T>
449 Statistics::Statistic<T>* createStatistic(
450 SST::Params& params, StatisticId_t id, const std::string& name, const std::string& statSubId)
451 {
452 /* I would prefer to avoid this std::function with dynamic cast,
453 * but the code is just a lot cleaner and avoids many unnecessary template instantiations
454 * doing it this way. At some point in the future, we would need to clean up
455 * the rule around enabling all statistics to make this better
456 */
457
458 StatCreateFunction create = [=](BaseComponent* comp, Statistics::StatisticProcessingEngine* engine,
459 const std::string& type, const std::string& name, const std::string& subId,
460 SST::Params& params) -> Statistics::StatisticBase* {
461 return engine->createStatistic<T>(comp, type, name, subId, params);
462 };
463
464 // We follow two distinct paths depending on if it is enable all, versus explicitly enabled
465 // Enable all is "scoped" to the (sub)component
466 // Explicitly enabled stats are assigned component-unique IDs and can be shared across subcomponents
467 // so creation and management happens in the parent component
468 Statistics::StatisticBase* base_stat =
469 id == STATALL_ID ? createEnabledAllStatistic(params, name, statSubId, std::move(create))
470 : getParentComponent()->createExplicitlyEnabledStatistic(
471 params, id, name, statSubId, std::move(create));
472
473 // Ugh, dynamic casts hurt my eyes, but I must do this
474 auto* statistic = dynamic_cast<Statistics::Statistic<T>*>(base_stat);
475 if ( statistic ) {
476 return statistic;
477 }
478 else {
479 fatal(__LINE__, __FILE__, "createStatistic", 1, "failed to cast created statistic '%s' to expected type",
480 name.c_str());
481 return nullptr; // avoid compiler warnings
482 }
483 }
484
485 template <typename T>
486 Statistics::Statistic<T>* createNullStatistic(
487 SST::Params& params, const std::string& name, const std::string& statSubId = "")
488 {
489 auto* engine = getStatEngine();
490 return engine->createStatistic<T>(my_info->component, "sst.NullStatistic", name, statSubId, params);
491 }
492
493 template <typename T>
494 Statistics::Statistic<T>* registerStatistic(
495 SST::Params& params, const std::string& statName, const std::string& statSubId, bool inserting)
496 {
497 if ( my_info->enabled_stat_names_ ) {
498 auto iter = my_info->enabled_stat_names_->find(statName);
499 if ( iter != my_info->enabled_stat_names_->end() ) {
500 // valid, enabled statistic
501 // During initialization, the component should have assigned a mapping between
502 // the local name and globally unique stat ID
503 StatisticId_t id = iter->second;
504 return createStatistic<T>(params, id, statName, statSubId);
505 }
506 }
507
508 // if we got here, this is not a stat we explicitly enabled
509 if ( inserting || doesComponentInfoStatisticExist(statName) ) {
510 // this is a statistic that I registered
511 if ( my_info->enabled_all_stats_ ) {
512 return createStatistic<T>(params, STATALL_ID, statName, statSubId);
513 }
514 else if ( my_info->parent_info && my_info->canInsertStatistics() ) {
515 // I did not explicitly enable nor enable all
516 // but I can insert statistics into my parent
517 // and my parent may have enabled all
518 return my_info->parent_info->component->registerStatistic<T>(params, statName, statSubId, true);
519 }
520 else {
521 // I did not enable, I cannot insert into parent - so send back null stat
522 return my_info->component->createNullStatistic<T>(params, statName, statSubId);
523 }
524 }
525 else if ( my_info->parent_info && my_info->sharesStatistics() ) {
526 // this is not a statistic that I registered
527 // but my parent can share statistics, maybe they enabled
528 return my_info->parent_info->component->registerStatistic<T>(params, statName, statSubId, false);
529 }
530 else {
531 // not a valid stat and I won't be able to share my parent's statistic
532 fatal(__LINE__, __FILE__, "registerStatistic", 1, "attempting to register unknown statistic '%s'",
533 statName.c_str());
534 return nullptr; // get rid of warning
535 }
536 }
537
538protected:
539 /** Registers a statistic.
540 If Statistic is allowed to run (controlled by Python runtime parameters),
541 then a statistic will be created and returned. If not allowed to run,
542 then a NullStatistic will be returned. In either case, the returned
543 value should be used for all future Statistic calls. The type of
544 Statistic and the Collection Rate is set by Python runtime parameters.
545 If no type is defined, then an Accumulator Statistic will be provided
546 by default. If rate set to 0 or not provided, then the statistic will
547 output results only at end of sim (if output is enabled).
548 @param params Parameter set to be passed to the statistic constructor.
549 @param statName Primary name of the statistic. This name must match the
550 defined ElementInfoStatistic in the component, and must also
551 be enabled in the Python input file.
552 @param statSubId An additional sub name for the statistic
553 @return Either a created statistic of desired type or a NullStatistic
554 depending upon runtime settings.
555 */
556 template <typename T>
558 SST::Params& params, const std::string& statName, const std::string& statSubId = "")
559 {
560 return registerStatistic<T>(params, statName, statSubId, false);
561 }
562
563 template <typename T>
564 Statistics::Statistic<T>* registerStatistic(const std::string& statName, const std::string& statSubId = "")
565 {
566 SST::Params empty {};
567 return registerStatistic<T>(empty, statName, statSubId, false);
568 }
569
570 template <typename... Args>
571 Statistics::Statistic<std::tuple<Args...>>* registerMultiStatistic(
572 const std::string& statName, const std::string& statSubId = "")
573 {
574 SST::Params empty {};
575 return registerStatistic<std::tuple<Args...>>(empty, statName, statSubId, false);
576 }
577
578 template <typename... Args>
579 Statistics::Statistic<std::tuple<Args...>>* registerMultiStatistic(
580 SST::Params& params, const std::string& statName, const std::string& statSubId = "")
581 {
582 return registerStatistic<std::tuple<Args...>>(params, statName, statSubId, false);
583 }
584
585 template <typename T>
586 Statistics::Statistic<T>* registerStatistic(const char* statName, const char* statSubId = "")
587 {
588 return registerStatistic<T>(std::string(statName), std::string(statSubId));
589 }
590
591 /** Called by the Components and Subcomponent to perform a statistic Output.
592 * @param stat - Pointer to the statistic.
593 * @param EndOfSimFlag - Indicates that the output is occurring at the end of simulation.
594 */
595 void performStatisticOutput(Statistics::StatisticBase* stat);
596
597 /** Performs a global statistic Output.
598 * This routine will force ALL Components and Subcomponents to output their statistic information.
599 * This may lead to unexpected results if the statistic counts or data is reset on output.
600 * NOTE: Currently, this function will only output statistics that are on the same rank.
601 */
603
604 /** Registers a profiling point.
605 This function will register a profiling point.
606 @param point Point to resgister
607 @return Either a pointer to a created T::ProfilePoint or nullptr if not enabled.
608 */
609 template <typename T>
610 typename T::ProfilePoint* registerProfilePoint(const std::string& pointName)
611 {
612 std::string full_point_name = getType() + "." + pointName;
613 auto tools = getComponentProfileTools(full_point_name);
614 if ( tools.size() == 0 ) return nullptr;
615
616 typename T::ProfilePoint* ret = new typename T::ProfilePoint();
617 for ( auto* x : tools ) {
618 T* tool = dynamic_cast<T*>(x);
619 if ( nullptr == tool ) {
620 // Not the right type, fatal
621 fatal(CALL_INFO_LONG, 1, "ERROR: wrong type of profiling tool for profiling point %s)\n",
622 pointName.c_str());
623 }
624 ret->registerProfilePoint(tool, pointName, getId(), getName(), getType());
625 }
626 return ret;
627 }
628
629 /** Loads a module from an element Library
630 * @param type Fully Qualified library.moduleName
631 * @param params Parameters the module should use for configuration
632 * @return handle to new instance of module, or nullptr on failure.
633 */
634 template <class T, class... ARGS>
635 T* loadModule(const std::string& type, Params& params, ARGS... args)
636 {
637
638 // Check to see if this can be loaded with new API or if we have to fallback to old
639 return Factory::getFactory()->CreateWithParams<T>(type, params, params, args...);
640 }
641
642protected:
643 // When you direct load, the ComponentExtension does not need any
644 // ELI information and if it has any, it will be ignored. The
645 // extension will be loaded as if it were part of the parent
646 // BaseComponent and will share all that components ELI
647 // information.
648 template <class T, class... ARGS>
649 T* loadComponentExtension(ARGS... args)
650 {
651 ComponentExtension* ret = new T(my_info->id_, args...);
652 return static_cast<T*>(ret);
653 }
654
655 /**
656 Check to see if a given element type is loadable with a particular API
657
658 @param name - Name of element to check in lib.name format
659 @return True if loadable as the API specified as the template parameter
660 */
661 template <class T>
662 bool isSubComponentLoadableUsingAPI(const std::string& type)
663 {
664 return Factory::getFactory()->isSubComponentLoadableUsingAPI<T>(type);
665 }
666
667 /**
668 Check to see if the element type loaded by the user into the.
669 specified slot is loadable with a particular API. This will
670 only check slot index 0. If you need to check other slots,
671 please use the SubComponentSlotInfo.
672
673 @param slot_name - Name of slot to check
674 @return True if loadable as the API specified as the template parameter
675 */
676 template <class T>
677 bool isUserSubComponentLoadableUsingAPI(const std::string& slot_name)
678 {
679 // Get list of ComponentInfo objects and make sure that there is
680 // only one SubComponent put into this slot
681 // const std::vector<ComponentInfo>& subcomps = my_info->getSubComponents();
682 const std::map<ComponentId_t, ComponentInfo>& subcomps = my_info->getSubComponents();
683 int sub_count = 0;
684 int index = -1;
685 for ( auto& ci : subcomps ) {
686 if ( ci.second.getSlotName() == slot_name ) {
687 index = ci.second.getSlotNum();
688 sub_count++;
689 }
690 }
691
692 if ( sub_count > 1 ) {
693 SST::Output outXX("SubComponentSlotWarning: ", 0, 0, Output::STDERR);
694 outXX.fatal(CALL_INFO, 1,
695 "Error: ComponentSlot \"%s\" in component \"%s\" only allows for one SubComponent, %d provided.\n",
696 slot_name.c_str(), my_info->getType().c_str(), sub_count);
697 }
698
699 return isUserSubComponentLoadableUsingAPIByIndex<T>(slot_name, index);
700 }
701
702 /**
703 Loads an anonymous subcomponent (not defined in input file to
704 SST run).
705
706 @param type tyupe of subcomponent to load in lib.name format
707 @param slot_name name of the slot to load subcomponent into
708 @param slot_num index of the slot to load subcomponent into
709 @param share_flags Share flags to be used by subcomponent
710 @param params Params object to be passed to subcomponent
711 @param args Arguments to be passed to constructor. This
712 signature is defined in the API definition
713
714 For ease in backward compatibility to old API, this call will
715 try to load using new API and will fallback to old if
716 unsuccessful.
717 */
718 template <class T, class... ARGS>
719 T* loadAnonymousSubComponent(const std::string& type, const std::string& slot_name, int slot_num,
720 uint64_t share_flags, Params& params, ARGS... args)
721 {
722
723 share_flags = share_flags & ComponentInfo::USER_FLAGS;
724 ComponentId_t cid = my_info->addAnonymousSubComponent(my_info, type, slot_name, slot_num, share_flags);
725 ComponentInfo* sub_info = my_info->findSubComponent(cid);
726
727 // This shouldn't happen since we just put it in, but just in case
728 if ( sub_info == nullptr ) return nullptr;
729
730 // Check to see if this can be loaded with new API or if we have to fallback to old
732 auto ret = Factory::getFactory()->CreateWithParams<T>(type, params, sub_info->id_, params, args...);
733 return ret;
734 }
735 return nullptr;
736 }
737
738 /**
739 Loads a user defined subcomponent (defined in input file to SST
740 run). This version does not allow share flags (set to
741 SHARE_NONE) or constructor arguments.
742
743 @param slot_name name of the slot to load subcomponent into
744
745 For ease in backward compatibility to old API, this call will
746 try to load using new API and will fallback to old if
747 unsuccessful.
748 */
749 template <class T>
750 T* loadUserSubComponent(const std::string& slot_name)
751 {
752 return loadUserSubComponent<T>(slot_name, ComponentInfo::SHARE_NONE);
753 }
754
755 /**
756 Loads a user defined subcomponent (defined in input file to SST
757 run).
758
759 @param slot_name name of the slot to load subcomponent into
760 @param share_flags Share flags to be used by subcomponent
761 @param args Arguments to be passed to constructor. This
762 signature is defined in the API definition
763
764 For ease in backward compatibility to old API, this call will
765 try to load using new API and will fallback to old if
766 unsuccessful.
767 */
768 template <class T, class... ARGS>
769 T* loadUserSubComponent(const std::string& slot_name, uint64_t share_flags, ARGS... args)
770 {
771
772 // Get list of ComponentInfo objects and make sure that there is
773 // only one SubComponent put into this slot
774 // const std::vector<ComponentInfo>& subcomps = my_info->getSubComponents();
775 const std::map<ComponentId_t, ComponentInfo>& subcomps = my_info->getSubComponents();
776 int sub_count = 0;
777 int index = -1;
778 for ( auto& ci : subcomps ) {
779 if ( ci.second.getSlotName() == slot_name ) {
780 index = ci.second.getSlotNum();
781 sub_count++;
782 }
783 }
784
785 if ( sub_count > 1 ) {
786 SST::Output outXX("SubComponentSlotWarning: ", 0, 0, Output::STDERR);
787 outXX.fatal(CALL_INFO, 1,
788 "Error: ComponentSlot \"%s\" in component \"%s\" only allows for one SubComponent, %d provided.\n",
789 slot_name.c_str(), my_info->getType().c_str(), sub_count);
790 }
791
792 return loadUserSubComponentByIndex<T, ARGS...>(slot_name, index, share_flags, args...);
793 }
794
795 /** Convenience function for reporting fatal conditions. The
796 function will create a new Output object and call fatal()
797 using the supplied parameters. Before calling
798 Output::fatal(), the function will also print other
799 information about the (sub)component that called fatal and
800 about the simulation state.
801
802 From Output::fatal: Message will be sent to the output
803 location and to stderr. The output will be prepended with the
804 expanded prefix set in the object.
805 NOTE: fatal() will call MPI_Abort(exit_code) to terminate simulation.
806
807 @param line Line number of calling function (use CALL_INFO macro)
808 @param file File name calling function (use CALL_INFO macro)
809 @param func Function name calling function (use CALL_INFO macro)
810 @param exit_code The exit code used for termination of simulation.
811 will be passed to MPI_Abort()
812 @param format Format string. All valid formats for printf are available.
813 @param ... Arguments for format.
814 */
815 [[noreturn]]
816 void fatal(uint32_t line, const char* file, const char* func, int exit_code, const char* format, ...) const
817 __attribute__((format(printf, 6, 7)));
818
819 /** Convenience function for testing for and reporting fatal
820 conditions. If the condition holds, fatal() will be called,
821 otherwise, the function will return. The function will create
822 a new Output object and call fatal() using the supplied
823 parameters. Before calling Output::fatal(), the function will
824 also print other information about the (sub)component that
825 called fatal and about the simulation state.
826
827 From Output::fatal: Message will be sent to the output
828 location and to stderr. The output will be prepended with the
829 expanded prefix set in the object.
830 NOTE: fatal() will call MPI_Abort(exit_code) to terminate simulation.
831
832 @param condition on which to call fatal(); fatal() is called
833 if the bool is false.
834 @param line Line number of calling function (use CALL_INFO macro)
835 @param file File name calling function (use CALL_INFO macro)
836 @param func Function name calling function (use CALL_INFO macro)
837 @param exit_code The exit code used for termination of simulation.
838 will be passed to MPI_Abort()
839 @param format Format string. All valid formats for printf are available.
840 @param ... Arguments for format.
841 */
842 void sst_assert(bool condition, uint32_t line, const char* file, const char* func, int exit_code,
843 const char* format, ...) const __attribute__((format(printf, 7, 8)));
844
845private:
846 SimTime_t processCurrentTimeWithUnderflowedBase(const std::string& base) const;
847
848 void configureCollectionMode(Statistics::StatisticBase* statistic, const std::string& name);
849
850 /**
851 * @brief findExplicitlyEnabledStatistic
852 * @param params
853 * @param id
854 * @param name
855 * @param statSubId
856 * @return that matching stat if the stat already was created for the given ID, otherwise nullptr
857 */
858 Statistics::StatisticBase* createExplicitlyEnabledStatistic(SST::Params& params, StatisticId_t id,
859 const std::string& name, const std::string& statSubId, StatCreateFunction create);
860
861 /**
862 * @brief createStatistic Helper function used by both enable all and explicit enable
863 * @param cpp_params Any parameters given in C++ specific to this statistic
864 * @param python_params Any parameters given in Python for this statistic
865 * @param name The name (different from type) for this statistic
866 * @param statSubId An optional sub ID for this statistic if multiple stats might have the same name
867 * @param create A type-erased factory for creating stats of a particulary type T
868 * @return The statistic created
869 */
870 Statistics::StatisticBase* createStatistic(SST::Params& cpp_params, const SST::Params& python_params,
871 const std::string& name, const std::string& statSubId, bool check_load_level, StatCreateFunction create);
872
873 Statistics::StatisticBase* createEnabledAllStatistic(
874 SST::Params& params, const std::string& name, const std::string& statSubId, StatCreateFunction create);
875
876 void configureAllowedStatParams(SST::Params& params);
877
878 void setDefaultTimeBaseForLinks(TimeConverter tc);
879
880 void pushValidParams(Params& params, const std::string& type);
881
882 template <class T, class... ARGS>
883 T* loadUserSubComponentByIndex(const std::string& slot_name, int slot_num, int share_flags, ARGS... args)
884 {
885
886 share_flags = share_flags & ComponentInfo::USER_FLAGS;
887
888 // Check to see if the slot exists
889 ComponentInfo* sub_info = my_info->findSubComponent(slot_name, slot_num);
890 if ( sub_info == nullptr ) return nullptr;
891 sub_info->share_flags = share_flags;
892 sub_info->parent_info = my_info;
893
894 if ( isSubComponentLoadableUsingAPI<T>(sub_info->type) ) {
895 auto ret = Factory::getFactory()->CreateWithParams<T>(
896 sub_info->type, *sub_info->params, sub_info->id_, *sub_info->params, args...);
897 return ret;
898 }
899 return nullptr;
900 }
901
902 template <class T>
903 bool isUserSubComponentLoadableUsingAPIByIndex(const std::string& slot_name, int slot_num)
904 {
905 // Check to see if the slot exists
906 ComponentInfo* sub_info = my_info->findSubComponent(slot_name, slot_num);
907 if ( sub_info == nullptr ) return false;
908
909 return isSubComponentLoadableUsingAPI<T>(sub_info->type);
910 }
911
912 // Utility function used by fatal and sst_assert
913 [[noreturn]]
914 void vfatal(uint32_t line, const char* file, const char* func, int exit_code, const char* format, va_list arg) const
915 __attribute__((format(printf, 6, 0)));
916
917 // Get the statengine from Simulation_impl
918 StatisticProcessingEngine* getStatEngine();
919
920public:
921 SubComponentSlotInfo* getSubComponentSlotInfo(const std::string& name, bool fatalOnEmptyIndex = false);
922
923 /** Retrieve the X,Y,Z coordinates of this component */
924 const std::vector<double>& getCoordinates() const { return my_info->coordinates; }
925
926protected:
929
930 bool isAnonymous() { return my_info->isAnonymous(); }
931
932 bool isUser() { return my_info->isUser(); }
933
934 /** Manually set the default defaultTimeBase */
935 [[deprecated("Use of shared TimeConverter objects is deprecated. Use 'setDefaultTimeBase(TimeConverter tc)' "
936 "(i.e., no TimeConverter pointer) instead.")]]
938 {
939 my_info->defaultTimeBase = tc;
940 }
941
942 /** Manually set the default defaultTimeBase */
943 void setDefaultTimeBase(TimeConverter tc) { my_info->defaultTimeBase = tc; }
944
945 // Can change this back to inline once we move completely away
946 // from TimeConverter*
947 TimeConverter* getDefaultTimeBase(); // { return my_info->defaultTimeBase; }
948 const TimeConverter* getDefaultTimeBase() const; // { return my_info->defaultTimeBase; }
949
950 bool doesSubComponentExist(const std::string& type);
951
952 // Does the statisticName exist in the ElementInfoStatistic
953 bool doesComponentInfoStatisticExist(const std::string& statisticName) const;
954 // Return the EnableLevel for the statisticName from the ElementInfoStatistic
955 uint8_t getComponentInfoStatisticEnableLevel(const std::string& statisticName) const;
956 // Return the Units for the statisticName from the ElementInfoStatistic
957 // std::string getComponentInfoStatisticUnits(const std::string& statisticName) const;
958
959 std::vector<Profile::ComponentProfileTool*> getComponentProfileTools(const std::string& point);
960
961private:
963
964
965 ComponentInfo* my_info = nullptr;
966 Simulation_impl* sim_ = nullptr;
967 bool isExtension = false;
968
969 // Need to track clock handlers for checkpointing. We need to
970 // know what clock handlers we have registered with the core
971 std::vector<Clock::HandlerBase*> clock_handlers;
972
973 void addSelfLink(const std::string& name);
974 Link* getLinkFromParentSharedPort(const std::string& port, std::vector<ConfigPortModule>& port_modules);
975
976 using StatNameMap = std::map<std::string, std::map<std::string, Statistics::StatisticBase*>>;
977
978 std::vector<PortModule*> portModules;
979 std::map<StatisticId_t, Statistics::StatisticBase*> m_explicitlyEnabledSharedStats;
980 std::map<StatisticId_t, StatNameMap> m_explicitlyEnabledUniqueStats;
981 StatNameMap m_enabled_all_stats_;
982
983 BaseComponent* getParentComponent()
984 {
985 ComponentInfo* base_info = my_info;
986 while ( base_info->parent_info ) {
987 base_info = base_info->parent_info;
988 }
989 return base_info->component;
990 }
991};
992
993/**
994 Used to load SubComponents when multiple SubComponents are loaded
995 into a single slot (will also also work when a single SubComponent
996 is loaded).
997 */
998class SubComponentSlotInfo
999{
1000
1001 BaseComponent* comp;
1002 std::string slot_name;
1003 int max_slot_index;
1004
1005public:
1006 ~SubComponentSlotInfo() {}
1007
1008 SubComponentSlotInfo(BaseComponent* comp, const std::string& slot_name) :
1009 comp(comp),
1010 slot_name(slot_name)
1011 {
1012 const std::map<ComponentId_t, ComponentInfo>& subcomps = comp->my_info->getSubComponents();
1013
1014 // Look for all subcomponents with the right slot name
1015 max_slot_index = -1;
1016 for ( auto& ci : subcomps ) {
1017 if ( ci.second.getSlotName() == slot_name ) {
1018 if ( ci.second.getSlotNum() > static_cast<int>(max_slot_index) ) {
1019 max_slot_index = ci.second.getSlotNum();
1020 }
1021 }
1022 }
1023 }
1024
1025 const std::string& getSlotName() const { return slot_name; };
1026
1027 bool isPopulated(int slot_num) const
1028 {
1029 if ( slot_num > max_slot_index ) return false;
1030 if ( comp->my_info->findSubComponent(slot_name, slot_num) == nullptr ) return false;
1031 return true;
1032 }
1033
1034 bool isAllPopulated() const
1035 {
1036 for ( int i = 0; i < max_slot_index; ++i ) {
1037 if ( comp->my_info->findSubComponent(slot_name, i) == nullptr ) return false;
1038 }
1039 return true;
1040 }
1041
1042 int getMaxPopulatedSlotNumber() const { return max_slot_index; }
1043
1044 /**
1045 Check to see if the element type loaded by the user into the
1046 specified slot index is loadable with a particular API.
1047
1048 @param slot_num Slot index to check
1049 @return True if loadable as the API specified as the template parameter
1050 */
1051 template <class T>
1052 bool isLoadableUsingAPI(int slot_num)
1053 {
1054 return comp->isUserSubComponentLoadableUsingAPIByIndex<T>(slot_name, slot_num);
1055 }
1056
1057 // Create functions that support the new API
1058
1059 /**
1060 Create a user defined subcomponent (defined in input file to
1061 SST run). This call will pass SHARE_NONE to the new
1062 subcomponent and will not take constructor arguments. If
1063 constructor arguments are needed for the API that is being
1064 loaded, the full call to create will need to be used
1065 create(slot_num, share_flags, args...).
1066
1067 @param slot_num Slot index from which to load subcomponent
1068
1069 This function supports the new API, but is identical to an
1070 existing API call. It will try to load using new API and will
1071 fallback to old if unsuccessful.
1072 */
1073 template <typename T>
1074 T* create(int slot_num) const
1075 {
1076 Params empty;
1077 return comp->loadUserSubComponentByIndex<T>(slot_name, slot_num, ComponentInfo::SHARE_NONE);
1078 // return private_create<T>(slot_num, empty);
1079 }
1080
1081 /**
1082 Create a user defined subcomponent (defined in input file to SST
1083 run).
1084
1085 @param slot_num Slot index from which to load subcomponent
1086 @param share_flags Share flags to be used by subcomponent
1087 @param args Arguments to be passed to constructor. This
1088 signature is defined in the API definition
1089
1090 For ease in backward compatibility to old API, this call will
1091 try to load using new API and will fallback to old if
1092 unsuccessful.
1093 */
1094 template <class T, class... ARGS>
1095 T* create(int slot_num, uint64_t share_flags, ARGS... args) const
1096 {
1097 return comp->loadUserSubComponentByIndex<T, ARGS...>(slot_name, slot_num, share_flags, args...);
1098 }
1099
1100 /**
1101 Create all user defined subcomponents (defined in input file to SST
1102 run) for the slot.
1103
1104 @param vec Vector of T* that will hold the pointers to the new
1105 subcomponents. If an index is not occupied, a nullptr will be
1106 put in it's place. All components will be added to the end of
1107 the vector, so index N will be at vec.length() + N, where
1108 vec.length() is the length of the vector when it is passed to
1109 the call.
1110 @param share_flags Share flags to be used by subcomponent
1111 @param args Arguments to be passed to constructor. This
1112 signature is defined in the API definition
1113
1114 For ease in backward compatibility to old API, this call will
1115 try to load using new API and will fallback to old if
1116 unsuccessful.
1117 */
1118 template <typename T, class... ARGS>
1119 void createAll(std::vector<T*>& vec, uint64_t share_flags, ARGS... args) const
1120 {
1121 for ( int i = 0; i <= getMaxPopulatedSlotNumber(); ++i ) {
1122 T* sub = create<T>(i, share_flags, args...);
1123 vec.push_back(sub);
1124 }
1125 }
1126
1127 /**
1128 Create all user defined subcomponents (defined in input file to SST
1129 run) for the slot.
1130
1131 @param vec Vector of pair<int,T*> that will hold the pointers
1132 to the new subcomponents. The int will hold the index from
1133 which the subcomponent wass loaded. Unoccupied indexes will be
1134 skipped. All components will be added to the end of the
1135 vector.
1136 @param share_flags Share flags to be used by subcomponent
1137 @param args Arguments to be passed to constructor. This
1138 signature is defined in the API definition
1139
1140 For ease in backward compatibility to old API, this call will
1141 try to load using new API and will fallback to old if
1142 unsuccessful.
1143 */
1144 template <typename T, class... ARGS>
1145 void createAllSparse(std::vector<std::pair<int, T*>>& vec, uint64_t share_flags, ARGS... args) const
1146 {
1147 for ( int i = 0; i <= getMaxPopulatedSlotNumber(); ++i ) {
1148 T* sub = create<T>(i, share_flags, args...);
1149 if ( sub != nullptr ) vec.push_back(i, sub);
1150 }
1151 }
1152
1153 /**
1154 Create all user defined subcomponents (defined in input file to SST
1155 run) for the slot.
1156
1157 @param vec Vector of T* that will hold the pointers
1158 to the new subcomponents. Unoccupied indexes will be
1159 skipped. All components will be added to the end of the
1160 vector.
1161 @param share_flags Share flags to be used by subcomponent
1162 @param args Arguments to be passed to constructor. This
1163 signature is defined in the API definition
1164
1165 For ease in backward compatibility to old API, this call will
1166 try to load using new API and will fallback to old if
1167 unsuccessful.
1168 */
1169 template <typename T, class... ARGS>
1170 void createAllSparse(std::vector<T*>& vec, uint64_t share_flags, ARGS... args) const
1171 {
1172 for ( int i = 0; i <= getMaxPopulatedSlotNumber(); ++i ) {
1173 T* sub = create<T>(i, share_flags, args...);
1174 if ( sub != nullptr ) vec.push_back(sub);
1175 }
1176 }
1177};
1178
1179namespace Core::Serialization {
1180
1181namespace pvt {
1183{
1184public:
1185 static void size_basecomponent(serializable_base* s, serializer& ser);
1186
1187 static void pack_basecomponent(serializable_base* s, serializer& ser);
1188
1189 static void unpack_basecomponent(serializable_base*& s, serializer& ser);
1190
1191 static void map_basecomponent(serializable_base*& s, serializer& ser, const std::string& name);
1192};
1193
1194} // namespace pvt
1195
1196
1197template <class T>
1198class serialize_impl<T*, std::enable_if_t<std::is_base_of_v<SST::BaseComponent, T>>>
1199{
1200 void operator()(T*& s, serializer& ser, ser_opt_t UNUSED(options))
1201 {
1202 serializable_base* sp = static_cast<serializable_base*>(s);
1203 switch ( ser.mode() ) {
1204 case serializer::SIZER:
1205 pvt::SerializeBaseComponentHelper::size_basecomponent(sp, ser);
1206 break;
1207 case serializer::PACK:
1208 pvt::SerializeBaseComponentHelper::pack_basecomponent(sp, ser);
1209 break;
1210 case serializer::UNPACK:
1211 pvt::SerializeBaseComponentHelper::unpack_basecomponent(sp, ser);
1212 break;
1213 case serializer::MAP:
1214 pvt::SerializeBaseComponentHelper::map_basecomponent(sp, ser, ser.getMapName());
1215 break;
1216 }
1217 s = static_cast<T*>(sp);
1218 }
1219
1220 SST_FRIEND_SERIALIZE();
1221};
1222
1223} // namespace Core::Serialization
1224
1225} // namespace SST
1226
1227#endif // SST_CORE_BASECOMPONENT_H
Main component object for the simulation.
Definition baseComponent.h:62
bool isSimulationRunModeInit() const
Check to see if the run mode was set to INIT.
Definition baseComponent.cc:635
SimTime_t getCurrentSimTimeMilli() const
Utility function to return the time since the simulation began in milliseconds.
Definition baseComponent.cc:608
TimeConverter * registerTimeBase(const std::string &base, bool regAll=true)
Registers a default time base for the component and optionally sets the the component's links to that...
Definition baseComponent.cc:218
virtual void complete(unsigned int UNUSED(phase))
Used during the complete phase after the end of simulation.
Definition baseComponent.h:111
void requireLibrary(const std::string &name)
Signifies that a library is required for this simulation.
Definition baseComponent.cc:659
bool isSimulationRunModeRun() const
Check to see if the run mode was set to RUN.
Definition baseComponent.cc:641
Link * configureLink(const std::string &name, TimeConverter *time_base, Event::HandlerBase *handler=nullptr)
Configure a Link.
Definition baseComponent.cc:398
Link * configureSelfLink(const std::string &name, TimeConverter *time_base, Event::HandlerBase *handler=nullptr)
Configure a SelfLink (Loopback link)
Definition baseComponent.cc:461
void setDefaultTimeBase(TimeConverter tc)
Manually set the default defaultTimeBase.
Definition baseComponent.h:943
bool isPortConnected(const std::string &name) const
Determine if a port name is connected to any links.
Definition baseComponent.cc:244
void fatal(uint32_t line, const char *file, const char *func, int exit_code, const char *format,...) const
Convenience function for reporting fatal conditions.
Definition baseComponent.cc:702
double getRunPhaseElapsedRealTime() const
Get the amount of real-time spent executing the run phase of the simulation.
Definition baseComponent.cc:617
void removeWatchPoint(WatchPoint *pt)
Remove a watch point from all handlers in the Component Tree.
Definition baseComponent.cc:1052
T * loadUserSubComponent(const std::string &slot_name)
Loads a user defined subcomponent (defined in input file to SST run).
Definition baseComponent.h:750
const std::string & getName() const
Returns Component/SubComponent Name.
Definition baseComponent.h:98
Statistics::Statistic< T > * registerStatistic(SST::Params &params, const std::string &statName, const std::string &statSubId="")
Registers a statistic.
Definition baseComponent.h:557
virtual void setup()
Called after all components have been constructed and initialization has completed,...
Definition baseComponent.h:115
Cycle_t getNextClockCycle(TimeConverter *freq)
Returns the next Cycle that the TimeConverter would fire If called prior to the simulation run loop,...
Definition baseComponent.cc:200
uint8_t getStatisticLoadLevel() const
Returns Component Statistic load level.
Definition baseComponent.h:90
UnitAlgebra getCoreTimeBase() const
Get the core timebase.
Definition baseComponent.cc:489
std::string & getOutputDirectory() const
Returns the output directory of the simulation.
Definition baseComponent.cc:653
double getCompletePhaseElapsedRealTime() const
Get the amount of real-time spent executing the complete phase of the simulation.
Definition baseComponent.cc:629
void performStatisticOutput(Statistics::StatisticBase *stat)
Called by the Components and Subcomponent to perform a statistic Output.
Definition baseComponent.cc:931
int getCurrentPriority() const
Return the current priority.
Definition baseComponent.cc:501
double getInitPhaseElapsedRealTime() const
Get the amount of real-time spent executing the init phase of the simulation.
Definition baseComponent.cc:623
void performGlobalStatisticOutput()
Performs a global statistic Output.
Definition baseComponent.cc:937
bool isSubComponentLoadableUsingAPI(const std::string &type)
Check to see if a given element type is loadable with a particular API.
Definition baseComponent.h:662
const std::vector< double > & getCoordinates() const
Retrieve the X,Y,Z coordinates of this component.
Definition baseComponent.h:924
T::ProfilePoint * registerProfilePoint(const std::string &pointName)
Registers a profiling point.
Definition baseComponent.h:610
const std::string & getParentComponentName() const
Returns the name of the parent Component, or, if called on a Component, the name of that Component.
Definition baseComponent.h:102
virtual void init(unsigned int UNUSED(phase))
Used during the init phase.
Definition baseComponent.h:107
Output & getSimulationOutput() const
Return the base simulation Output class instance.
Definition baseComponent.cc:537
SimTime_t getCurrentSimTime() const
Return the simulated time since the simulation began in the default timebase.
Definition baseComponent.h:164
UnitAlgebra getElapsedSimTime() const
Return the elapsed simulation time as a time.
Definition baseComponent.cc:507
SimTime_t getCurrentSimTimeMicro() const
Utility function to return the time since the simulation began in microseconds.
Definition baseComponent.cc:600
void addWatchPoint(WatchPoint *pt)
Add a watch point to all handlers in the Component Tree.
Definition baseComponent.cc:1004
RankInfo getNumRanks() const
Get the number of parallel ranks in the simulation.
Definition baseComponent.cc:531
UnitAlgebra getEndSimTime() const
Return the end simulation time as a time.
Definition baseComponent.cc:519
void sst_assert(bool condition, uint32_t line, const char *file, const char *func, int exit_code, const char *format,...) const
Convenience function for testing for and reporting fatal conditions.
Definition baseComponent.cc:711
bool isSimulationRunModeBoth() const
Check to see if the run mode was set to BOTH.
Definition baseComponent.cc:647
RankInfo getRank() const
Get this instance's parallel rank.
Definition baseComponent.cc:525
virtual void emergencyShutdown()
Called when SIGINT or SIGTERM has been seen.
Definition baseComponent.h:95
TimeConverter * registerClock(const std::string &freq, Clock::HandlerBase *handler, bool regAll=true)
Registers a clock for this component.
Definition baseComponent.cc:156
void setDefaultTimeBase(TimeConverter *tc)
Manually set the default defaultTimeBase.
Definition baseComponent.h:937
T * loadUserSubComponent(const std::string &slot_name, uint64_t share_flags, ARGS... args)
Loads a user defined subcomponent (defined in input file to SST run).
Definition baseComponent.h:769
SimTime_t getCurrentSimTimeNano() const
Utility function to return the time since the simulation began in nanoseconds.
Definition baseComponent.cc:592
T * loadAnonymousSubComponent(const std::string &type, const std::string &slot_name, int slot_num, uint64_t share_flags, Params &params, ARGS... args)
Loads an anonymous subcomponent (not defined in input file to SST run).
Definition baseComponent.h:719
void unregisterClock(TimeConverter *tc, Clock::HandlerBase *handler)
Removes a clock handler from the component.
Definition baseComponent.cc:212
ComponentId_t getId() const
Returns unique component ID.
Definition baseComponent.h:87
Cycle_t reregisterClock(TimeConverter *freq, Clock::HandlerBase *handler)
Reactivates an existing Clock and Handler.
Definition baseComponent.cc:194
bool isUserSubComponentLoadableUsingAPI(const std::string &slot_name)
Check to see if the element type loaded by the user into the.
Definition baseComponent.h:677
virtual void finish()
Called after complete phase, but before objects are destroyed.
Definition baseComponent.h:118
SimTime_t getEndSimCycle() const
Return the end simulation time as a cycle count.
Definition baseComponent.cc:513
virtual bool Status()
Currently unused function.
Definition baseComponent.h:121
SimTime_t getCurrentSimCycle() const
Return the current simulation time as a cycle count.
Definition baseComponent.cc:495
virtual void printStatus(Output &UNUSED(out))
Called by the Simulation to request that the component print it's current status.
Definition baseComponent.h:128
T * loadModule(const std::string &type, Params &params, ARGS... args)
Loads a module from an element Library.
Definition baseComponent.h:635
A Clock class.
Definition clock.h:34
SSTHandlerBase< bool, Cycle_t > HandlerBase
Base handler for clock functions.
Definition clock.h:43
ComponentExtension is a class that can be loaded using loadComponentExtension<T>(....
Definition componentExtension.h:29
Definition componentInfo.h:42
Main component object for the simulation.
Definition component.h:31
Definition serializable_base.h:119
Base serialize class.
Definition serialize.h:110
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition serializer.h:45
SSTHandlerBase< void, Event * > HandlerBase
Base handler for event delivery.
Definition event.h:40
Maps port names to the Links that are connected to it.
Definition linkMap.h:29
Module is a tag class used with the loadModule function.
Definition module.h:26
Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file.
Definition output.h:54
void fatal(uint32_t line, const char *file, const char *func, int exit_code, const char *format,...) const
Output the fatal message with formatting as specified by the format parameter.
Definition output.cc:154
@ STDERR
Definition output.h:61
Parameter store.
Definition params.h:58
Definition rankInfo.h:24
Main control class for a SST Simulation.
Definition simulation_impl.h:87
Forms the base class for statistics gathering within SST.
Definition statbase.h:49
An SST core component that handles timing and event processing informing all registered Statistics to...
Definition statengine.h:58
Forms the template defined base class for statistics gathering within SST.
Definition statbase.h:373
Used to load SubComponents when multiple SubComponents are loaded into a single slot (will also also ...
Definition baseComponent.h:999
T * create(int slot_num) const
Create a user defined subcomponent (defined in input file to SST run).
Definition baseComponent.h:1074
void createAllSparse(std::vector< std::pair< int, T * > > &vec, uint64_t share_flags, ARGS... args) const
Create all user defined subcomponents (defined in input file to SST run) for the slot.
Definition baseComponent.h:1145
bool isLoadableUsingAPI(int slot_num)
Check to see if the element type loaded by the user into the specified slot index is loadable with a ...
Definition baseComponent.h:1052
void createAll(std::vector< T * > &vec, uint64_t share_flags, ARGS... args) const
Create all user defined subcomponents (defined in input file to SST run) for the slot.
Definition baseComponent.h:1119
T * create(int slot_num, uint64_t share_flags, ARGS... args) const
Create a user defined subcomponent (defined in input file to SST run).
Definition baseComponent.h:1095
void createAllSparse(std::vector< T * > &vec, uint64_t share_flags, ARGS... args) const
Create all user defined subcomponents (defined in input file to SST run) for the slot.
Definition baseComponent.h:1170
SubComponent is a class loadable through the factory which allows dynamic functionality to be added t...
Definition subcomponent.h:29
A class to convert between a component's view of time and the core's view of time.
Definition timeConverter.h:28
Performs Unit math in full precision.
Definition unitAlgebra.h:107
Class that can attach to Clock and Event Handlers to monitor the state of variables.
Definition watchPoint.h:27