12#ifndef SST_CORE_PORTMODULE_H
13#define SST_CORE_PORTMODULE_H
15#include "sst/core/eli/elementinfo.h"
16#include "sst/core/event.h"
17#include "sst/core/link.h"
18#include "sst/core/statapi/statbase.h"
19#include "sst/core/statapi/statengine.h"
26using namespace SST::Statistics;
51 public Event::HandlerBase::InterceptPoint,
62 SST_ELI_DECLARE_INFO_EXTERN(
216 const std::string& getName()
const;
244 [[deprecated(
"Use of shared TimeConverter objects is deprecated. Use 'getCurrentSimTime(TimeConverter& timebase)' "
245 "(i.e., no pointer) instead.")]]
296 void fatal(uint32_t line,
const char* file,
const char* func,
int exit_code,
const char* format, ...) const
297 __attribute__((format(printf, 6, 7)));
322 void sst_assert(
bool condition, uint32_t line, const
char* file, const
char* func,
int exit_code,
323 const
char* format, ...) const __attribute__((format(printf, 7, 8)));
337 template <typename T>
339 SST::
Params& params, const std::
string& stat_name, const std::
string& stat_sub_id =
"")
341 return registerStatistic_impl<T>(params, stat_name, stat_sub_id);
344 template <
typename T>
348 return registerStatistic_impl<T>(empty, stat_name, stat_sub_id);
351 virtual std::string getEliType()
const {
return ""; }
354 friend class BaseComponent;
359 BaseComponent* component_ =
nullptr;
367 void vfatal(uint32_t line,
const char* file,
const char* func,
int exit_code,
const char* format, va_list arg)
const
368 __attribute__((format(printf, 6, 0)));
373 template <
typename T>
374 Statistics::Statistic<T>* registerStatistic_impl(
375 SST::Params& params,
const std::string& stat_name,
const std::string& stat_sub_id)
378 uint8_t level = getStatisticValidityAndLevel(stat_name);
379 if ( level == 255 ) {
380 fatal(__LINE__, __FILE__,
"registerStatistic", 1,
381 "attempting to register a statistic '%s' that is not found in ELI", stat_name.c_str());
386 std::tie(enabled, cfg_params) = isStatisticEnabled(stat_name, level);
389 cfg_params.
insert(params);
390 auto stat = getStatEngine()->createStatistic<T>(component_, stat_name, stat_sub_id, cfg_params);
391 stat->setPortModName(id_.first, id_.second);
395 return getStatEngine()->createDisabledStatistic<T>();
403 Statistics::StatisticProcessingEngine* getStatEngine()
const;
408 uint8_t getStatisticValidityAndLevel(
const std::string& statistic_name)
const;
414 std::pair<bool, Params> isStatisticEnabled(
const std::string& statistic_name,
const uint8_t min_level);
420#define SST_ELI_REGISTER_PORTMODULE(cls, lib, name, version, desc) \
421 SST_ELI_REGISTER_DERIVED(SST::PortModule,cls,lib,name,ELI_FORWARD_AS_ONE(version),desc) \
422 std::string getEliType() const override \
424 std::string ret(lib); \
425 return ret + "." + name; \
Main component object for the simulation.
Definition baseComponent.h:67
Definition serializable.h:25
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition serializer.h:43
Definition attributeInfo.h:42
Definition paramsInfo.h:41
Definition statsInfo.h:41
Base class for Events - Items sent across links to communicate between components.
Definition event.h:41
Attach point for inspecting, modifying or dropping events sent on the Link.
Definition link.h:74
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
void insert(const std::string &key, const std::string &value, bool overwrite=true)
Add a key/value pair into the param object.
Definition params.cc:171
PortModules are modules that can be attached to the send and/or receive side of ports.
Definition portModule.h:54
virtual uintptr_t registerHandlerIntercept(const AttachPointMetaData &mdata) override
Function that will be called when a handler is registered with recieves (i.e.
Definition portModule.cc:55
virtual bool installOnReceive()
Called to determine if the PortModule should be installed on receives.
Definition portModule.h:204
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 portModule.cc:203
virtual bool installOnSend()
Called to determine if the PortModule should be installed on sends.
Definition portModule.h:214
virtual void serializeHandlerInterceptPointKey(SST::Core::Serialization::serializer &ser, uintptr_t &key) override
Function that will be called to handle the key returned from registerHandlerIntercept,...
Definition portModule.cc:61
virtual void interceptHandler(uintptr_t key, Event *&data, bool &cancel) override=0
Function that will be called before the event handler to let the attach point intercept the data.
SimTime_t getCurrentSimTimeMicro() const
Utility function to return the time since the simulation began in microseconds.
Definition portModule.cc:136
virtual uintptr_t registerLinkAttachTool(const AttachPointMetaData &mdata) override
Function that will be called when a PortModule is registered on sends (i.e.
Definition portModule.cc:41
UnitAlgebra getCoreTimeBase() const
Get the core timebase.
Definition portModule.cc:82
SimTime_t getCurrentSimTimeMilli() const
Utility function to return the time since the simulation began in milliseconds.
Definition portModule.cc:142
UnitAlgebra getElapsedSimTime() const
Return the elapsed simulation time as a time.
Definition portModule.cc:100
virtual void serializeEventAttachPointKey(SST::Core::Serialization::serializer &ser, uintptr_t &key) override
Function that will be called to handle the key returned from registerLinkAttachTool,...
Definition portModule.cc:47
SimTime_t getCurrentSimCycle() const
Return the current simulation time as a cycle count.
Definition portModule.cc:88
SimTime_t getCurrentSimTimeNano() const
Utility function to return the time since the simulation began in nanoseconds.
Definition portModule.cc:130
int getCurrentPriority() const
Return the current priority.
Definition portModule.cc:94
Output & getSimulationOutput() const
Return the base simulation Output class instance.
Definition portModule.cc:106
virtual void eventSent(uintptr_t key, Event *&ev) override=0
Function that will be called when an event is sent on a link with registered PortModules.
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 portModule.cc:194
Statistics::Statistic< T > * registerStatistic(SST::Params ¶ms, const std::string &stat_name, const std::string &stat_sub_id="")
Registers a statistic.
Definition portModule.h:338
SimTime_t getCurrentSimTime(TimeConverter *tc) const
Return the simulated time since the simulation began in units specified by the parameter.
Definition portModule.cc:118
Forms the template defined base class for statistics gathering within SST.
Definition statbase.h:369
A class to convert between a component's view of time and the core's view of time.
Definition timeConverter.h:31
Performs Unit math in full precision.
Definition unitAlgebra.h:107