Core Python Module

There are five classes available in SST: Component, SubComponent, Link, StatisticGroup and StatisticOutput. The Component and SubComponent classes share many of the same functions and will be covered together.

Component/SubComponent Classes

The Component and SubComponent Python classes represent the Component and SubComponent C++ classes that are used to implement the simulation models used in SST. They are similar, and have similar APIs, but SubComponents can only exist inside of Components. Subsequently, Components are instanced directly, but SubComponents are only instanced through a Component or another SubComponent.

The figures below show the main structures of the Component/SubComponent objects. The right image illustrates the arbitrary nesting capability of SubComponents.

Main structures of the Component and SubComponent objects Component with SubComponents loaded, showing that SubComponents can be arbitrarily nested

An instance of Component is created using:


Component(name, element_type)

Creates a new Component object.

Parameters


A SubComponent is created by calling setSubComponent() on either a Component or SubComponent object. Instancing a SubComponent in this way creates a User SubComponent and allows the user to specify the parameters and statistics directly on the SubComponent. The name of the SubComponent is automatically generated using the name of the parent Component and the slot_name(s) in which SubComponents are loaded. If more than one SubComponent is loaded into a slot, the slot_name is also indexed using square brackets (e.g. [0]). This name can be used to get a handle to the SubComponent later in the Python code. See setSubComponent function description below.


setSubComponent(slot_name, element_type, slot_index = 0)

Inserts a SubComponent of the specified type into the indicated slot name and index and creates a new SubComponent object

Parameters


Functions Common to Component and SubComponent

The following functions are available to both Component and SubComponent classes.


addParam(key, value)

Adds a parameter to the Params object for the Component/SubComponent.

Parameters



addParams(params)

Adds multiple parameters to the Params object for the Component/SubComponent.

Parameters



Connects a link to the specified port with the specified latency on the link. You can also connect a link by using Link.connect().

Parameters



getFullName()

Returns the full name of the Component/SubComponent. For Components, the name is the one supplied by the user at the time the Component was created. For SubComponents, the name is automatically generated from the parent Component and slot name. At each level, the name is generated as the parent’s name plus the slot name, separated by a colon. The slot number is appended in square brackets:

Parent:slot[index]

This holds true for SubComponents of SubComponents, the slotname and index are just appended to the parent name:

Parent:slot[index]:slot[index]

Parameters



getType()

Returns the type of the component in lib.element format. This is simply the type supplied to either the Component constructor or setSubComponent() call.

Parameters



setStatistic(stat_name, stat_obj=None)

Sets the statistic object to use in the specified statistic slot.

Parameters



setStatisticLoadLevel(level, apply_to_children=False)

Sets the load level for this statistic. This overrides the default load level. Load levels are not used for statistics that are explicitly enabled (i.e. does not use one of the “All” variants for enabling statistics). See General Notes on Statistics for more information.

Parameters



enableAllStatistics(stat_params_dict, apply_to_children=False)

Enables all statistics for the Component/SubComponent on which the call is made. See General Notes on Statistics for more information.

Parameters



enableStatistics(stat_list, stat_params_dict, apply_to_children=False)

Enables a list of statistics for the component on which the call is made. See General Notes on Statistics for more information.

Parameters



setCoordinates(x, y=0.0, z=0.0)

Sets the x, y, z coordinates for this element. This is for use with visualization.

Parameters


Functions Unique to Component

The following functions are unique to Components, and, therefore, are not available to SubComponents.


setRank(mpi_rank, thread = 0)

Sets the rank the Component should be assigned to. This information is only used if the partitioner is set to sst.self.

Parameters



setWeight(weight)

Sets the weight of the Component. The weight is used by some partitioners to help balance Components across ranks.

Parameters


Link Class

The Link object is used to connect Component/SubComponents together to form the simulation. The Link is created using:


Link(name, latency=None)

Creats a new Link object

Parameters



connect((comp1, port1, latency1=default), (comp2, port2, latency2=default))

Connects two ports using the link object.

Actual parameters are two tuples representing the information for the ports to be connected. The fields in the tuple are (comp, port, latency) as describe below.

Parameters



setNoCut()*

Tell the simulator that this link should not be “cut” by a partition boundary. In effect, it will guarantee that the two Components connected by this link will be on the same rank when using an autotmatic partitioning scheme (this attribute is ignored if the self partitioner is used). This must be used with care, as you can easily get into a situation where too many components are on the same rank.

Parameters


Statistic

A Statistic object is created using the setStatistic() function in a Component or SubComponent.

The following functions are also available to configure the statistics object.


addParam(key, value)

Adds a parameter to the statistics Params

Parameters



addParams(params)

Adds multiple parameters to the Params object for the Statistic.

Parameters


StatisticOutput

The StatisticOutput object is used to configure the output type and options for statistics and is for use with StatisticGroup. For the global statistics output, see the global functions: setStatisticOutput(), setStatisticOutputOption() and setStatisticOutputOptions().

The StatisticOutput object is created using:


StatisticOutput(type, params=None)

Constructor for StatisticOutput

Parameters



addParam(key, value)

Adds a parameter to the Params object for the StatisticOutput.

Parameters



addParams(params)

Adds multiple parameters to the Params object for the StatisticOutput.

Parameters


StatisticGroup

The StatisticsGroup object is used to group Statistics object together to be written to the same StatisticOutput object.

NOTE: The StatisticGroup object had limited use in the past and is evolving to include new functionality. This is the proposed functionality of the class and may not be the final API for the object.

A StatisticGroup is creating using:


StatisticGroup(name)

Constructor for StatisticGroup

Parameters



addStatistic(stat)

Adds a statistic to the group.

Parameters



addComponent(comp)

Add a component to the group

Parameters



setOutput(output)

Configure how the Statistics in the group should be written

Parameters



setFrequency(interval)

Set the frequency or rate (e.g.: “10ms”, “25kHz”) to write out the statistics.

Parameters