SST
11.0.0
StructuralSimulationToolkit
|
The most important class for is SST::Component, the base class from which all simulation components inherit. At the very least, a component writer must create a class which inherits from SST::Component and which contains a constructor. This class should be created in a dynamic library (.so or .dylib file) and should include a C-style function which returns a pointer to a newly instantiated component.
SST::Component also contains useful functions for component setup (SST::Component::Setup() and SST::Component::Init()), cleanup (SST::Component::Finish()), controlling when the simulation stops (SST::Component::registerExit() and SST::Component::unregisterExit() ), and for handling time (such as SST::Component::getCurrentSimTime()).
SST components use event handling functors to handle interactions with other components (i.e. through an SST::Event sent over an SST::Link) and recurring events (i.e. component clock ticks). The Event Handler Class, SST::EventHandler, is templated to create either type of event handler by creating a functor which invokes a given member function whenever triggered. For example:
NICeventHandler = new Event::Handler<proc> (this, &proc::handle_nic_events); ... bool proc::handle_nic_events(Event *event) { ... }
creates an event handler which calls proc::handle_nic_events()
with an argument of type Event*
- the SST::Event to be processed. Similarly,
clockHandler = new Clock::Handler<proc>(this, &proc::preTic());
creates an clock handler which invokes the function proc::preTic()
at a regular interval.
Once created, an SST::EventHandler must be registered with the simulation core. This can be done with the SST::Component::configureLink() function for events coming from another component, or by SST::Component::registerClock(), for event handlers triggered by a clock. For example, the handlers created above could be registed in this way:
configureLink("mem0", NICeventHandler) registerClock( "1Ghz", clockHandler );
Note that SST::Component::registerClock() can have its period or frequency expressed in SI units in a string. The allowed units are specified in SST::TimeLord::getTimeConverter() function.
Also note that the SST::LinkMap::LinkAdd() function does not require an event handler if the recieving component uses the "event pull" mechanism with SST::Link::Recv().
SST::Component s use SST::Link to communicate by passing events. An SST::Link is specified in the Python file use to configure the simulation. For example,
comp_A = sst.Component("cA", "simpleElementExample.simpleComponent") comp_A.addParams({ "workPerCycle" : """1000""", "commSize" : """100""", }) comp_B = sst.Component("cB", "simpleElementExample.simpleComponent") comp_B.addParams({ "workPerCycle" : """1000""", "commSize" : """100""", }) link_AB = sst.Link("link_AB") link_AB.connect( (comp_A, "Slink", "10000ps"), (comp_B, "Nlink", "10000ps") )
specifies two components, comp_A
and comp_B
. These components are connected by an SST::Link. Each link.connect
contains a pair of structures which specify the endpoint, port name, and latency of the link.
Other commonly used SST::Link functions are: