12 #ifndef SST_CORE_BASECOMPONENT_H 13 #define SST_CORE_BASECOMPONENT_H 15 #include <sst/core/sst_types.h> 16 #include <sst/core/warnmacros.h> 21 #include <sst/core/statapi/statengine.h> 22 #include <sst/core/statapi/statbase.h> 23 #include <sst/core/event.h> 24 #include <sst/core/clock.h> 25 #include <sst/core/oneshot.h> 26 #include <sst/core/componentInfo.h> 27 #include <sst/core/simulation.h> 42 class SharedRegionMerger;
45 class SubComponentSlotInfo_impl;
56 virtual const std::string& getSlotName()
const = 0;
57 virtual bool isPopulated(
int slot_num)
const = 0;
58 virtual bool isAllPopulated()
const = 0;
59 virtual int getMaxPopulatedSlotNumber()
const = 0;
62 T* create(
int slot_num,
Params& params)
const {
68 T* cast_sub =
dynamic_cast<T*
>(sub);
69 if ( cast_sub == NULL ) {
73 "%s, index %d, which is not castable to correct time\n",
74 getSlotName().c_str(),slot_num);
80 void createAll(
Params& params, std::vector<T*>& vec,
bool insertNulls =
true)
const {
81 for (
int i = 0; i <= getMaxPopulatedSlotNumber(); ++i ) {
82 T* sub = create<T>(i, params);
83 if ( sub != NULL || insertNulls ) vec.push_back(sub);
88 T* create(
int slot_num)
const {
90 return create<T>(slot_num, empty);
94 void createAll(std::vector<T*>& vec,
bool insertNulls =
true)
const {
96 return createAll<T>(empty, vec, insertNulls);
114 inline ComponentId_t
getId()
const {
return my_info->id; }
124 inline const std::string&
getName()
const {
return my_info->getName(); }
129 virtual void init(
unsigned int UNUSED(phase)) {}
148 bool isPortConnected(
const std::string &name)
const;
231 TimeConverter* registerTimeBase( std::string base,
bool regAll =
true);
242 return getCurrentSimTime(defaultTimeBase);
246 SimTime_t getCurrentSimTime(std::string base);
249 SimTime_t getCurrentSimTimeNano()
const;
251 SimTime_t getCurrentSimTimeMicro()
const;
253 SimTime_t getCurrentSimTimeMilli()
const;
271 template <
typename T>
276 if (
false == doesComponentInfoStatisticExist(statName)) {
277 printf(
"Error: Statistic %s name %s is not found in ElementInfoStatistic, exiting...\n",
278 StatisticBase::buildStatisticFullName(getName().c_str(), statName, statSubId).c_str(),
283 StatisticBase* prevStat = StatisticProcessingEngine::getInstance()->isStatisticRegisteredWithEngine<T>(getName(), my_info->getID(), statName, statSubId);
284 if (NULL != prevStat) {
288 return registerStatisticCore<T>(statName, statSubId);
291 template <
typename T>
292 Statistic<T>* registerStatistic(
const char* statName,
const char* statSubId =
"")
294 return registerStatistic<T>(std::string(statName), std::string(statSubId));
325 SubComponent* loadNamedSubComponent(std::string name,
int slot_num);
328 SubComponentSlotInfo* getSubComponentSlotInfo(std::string name,
bool fatalOnEmptyIndex =
false);
332 return my_info->coordinates;
340 defaultTimeBase = tc;
353 SharedRegion* getLocalSharedRegion(
const std::string &key,
size_t size);
357 Simulation* getSimulation()
const {
return sim; }
360 virtual bool doesComponentInfoStatisticExist(
const std::string &statisticName)
const = 0;
362 uint8_t getComponentInfoStatisticEnableLevel(
const std::string &statisticName)
const;
364 std::string getComponentInfoStatisticUnits(
const std::string &statisticName)
const;
366 virtual Component* getTrueComponent()
const = 0;
381 void addSelfLink(std::string name);
383 template <
typename T>
384 Statistic<T>* registerStatisticCore(std::string statName, std::string statSubId =
"")
389 #include "sst/core/statapi/componentregisterstat_impl.h" 397 #endif // SST_CORE_BASECOMPONENT_H Output object provides consistant method for outputing data to stdout, stderr and/or sst debug file...
Definition: output.h:54
ComponentId_t getId() const
Returns unique component ID.
Definition: baseComponent.h:114
Definition: sharedRegion.h:77
virtual void printStatus(Output &UNUSED(out))
Called by the Simulation to request that the component print it's current status. ...
Definition: baseComponent.h:145
Main control class for a SST Simulation.
Definition: simulation.h:72
A class to convert between a component's view of time and the core's view of time.
Definition: timeConverter.h:25
Main component object for the simulation.
Definition: component.h:32
void fatal(uint32_t line, const char *file, const char *func, uint32_t exit_code, const char *format,...) const
Output the fatal message with formatting as specified by the format parameter.
Definition: output.cc:155
virtual void finish()
Called after simulation completes, but before objects are destroyed.
Definition: baseComponent.h:135
Forms the base class for statistics gathering within SST.
Definition: statbase.h:61
Utility class to define how to merge multiple pieces of shared memory regions Useful in the multi-MPI...
Definition: sharedRegion.h:30
Statistic< T > * registerStatistic(std::string statName, std::string statSubId="")
Registers a statistic.
Definition: baseComponent.h:272
virtual void emergencyShutdown(void)
Called when SIGINT or SIGTERM has been seen.
Definition: baseComponent.h:119
Forms the template defined base class for statistics gathering within SST.
Definition: statbase.h:294
static Output & getSimulationOutput()
Return the base simulation Output class instance.
Definition: simulation.h:176
virtual void setup()
Called after all components have been constructed and inialization has completed, but before simulati...
Definition: baseComponent.h:132
Module is a tag class used with the loadModule function.
Definition: module.h:20
Definition: baseComponent.cc:33
TimeConverter * defaultTimeBase
Timebase used if no other timebase is specified for calls like BaseComponent::getCurrentSimTime().
Definition: baseComponent.h:346
Functor classes for Clock handling.
Definition: clock.h:44
Main component object for the simulation.
Definition: baseComponent.h:104
SimTime_t getCurrentSimTime() const
return the time since the simulation began in the default timebase
Definition: baseComponent.h:241
virtual bool Status()
Currently unused function.
Definition: baseComponent.h:138
Parameter store.
Definition: params.h:45
Functor classes for Event handling.
Definition: event.h:86
Definition: componentInfo.h:34
Definition: baseComponent.h:47
Definition: componentInfo.h:30
An SST core component that handles timing and event processing informing all registered Statistics to...
Definition: statengine.h:49
Performs Unit math in full precision.
Definition: unitAlgebra.h:104
void setDefaultTimeBase(TimeConverter *tc)
Manually set the default detaulTimeBase.
Definition: baseComponent.h:339
SubComponent is a class loadable through the factory which allows dynamic functionality to be added t...
Definition: subcomponent.h:29
const std::vector< double > & getCoordinates() const
Retrieve the X,Y,Z coordinates of this component.
Definition: baseComponent.h:331
const std::string & getName() const
Returns component Name.
Definition: baseComponent.h:124
Link between two components.
Definition: link.h:33
virtual void init(unsigned int UNUSED(phase))
Used during the init phase.
Definition: baseComponent.h:129
Functor classes for OneShot handling.
Definition: oneshot.h:39