Navigation: Home | Downloads | Getting SST | Documentation | Support
SST provides a python module to allow interaction with the simulation build system. The python module is defined in cpython and is only available in the python interpreter launched within a running SST executable. The module is accessed by importing the sst module. This can be done in a number of ways. The two most common being:
import sst
from sst import *
Within this module, there are a number of available classes and global functions. The available classes are: Component
, SubComponent
, Link
, StatisticOutput
and StatisticGroup
. The global functions are divided between general functions and functions operating on or returning one of the available objects. This document will first discuss the available classes in the SST python module and will then document the global functions.
There are 5 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.
A Component is created by instancing an sst.Component class. The user initialization function is:
Parameters:
name: name of the Component. The name can be used to get a handle to the Component later in the python code. The name is also available to the c++ implementation of the Component
type: type of the Component in the lib.element format (for example, merlin.hr_router)
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. This name can be used to get a handle to the SubComponent later in the python code. See setSubComponent function description below.
Inserts a subcomponent of the specified type into the indicated slot name and index.
Parameters:
slot_name: name of the slot in which the SubComponent should be loaded.
type: type of the SubComponent in the lib.element format (for example, merlin.linkcontrol)
slot_index: slot index in which the SubComponent should be inserted. This defaults to 0 and is not required if only one SubComponent is being loaded into the specified slot. Each SubComponent must be loaded into a unique slot_index and some (Sub)Components will require the indices to be linear with no gaps.
Return value: the function returns an sst.SubComponent object
Adds a parameter to the Params object for the Component/SubComponent
Parameters:
key: name of the parameter
value: value of the parameter. This can be almost any python object and the __str__ method will be called to get a string representation. A list can be passed to this call when the find_array function is used in the C++ class to retrieve the parameters.
Return value: none
Adds multiple parameters to the Params object for the Component/SubComponent
Parameters:
Return value: none
Connects a link to the specified port with the specified latency on the link. You can also connect a link by using Link.connect(). If a default latency is specified on the Link, then the latency parameter is optional, however, if no default latency is set on the Link, the latency parameter to addLink is required.
Parameters:
link: sst.Link object that will be connected to the port
port: name of the port to connect the link to
latency: latency of the link from the perspective of this Component/SubComponent sending an event. This parameter is optional and the call will use the default latency set on the link if it's not specified in the call. If provided, must include units (e.g., "ns").
Return value: none
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:
Return value: full name of Component/SubComponent
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:
Return value: type of Component/SubComponent
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" below for more information.
Parameters:
level: statistic load level for the component
apply_to_children: If set to True, will recursively enable specified statistics on all currently instanced SubComponent descendants. SubComponents created after this call will not have their load level set
Enables all statistics for the Component/SubComponent on which the call is made. See "General Notes on Statistics" below for more information.
Parameters:
stat_params_dict: Python dictionary that specified the statistic parameters. All statistics will get the same set of parameters
apply_to_children: If set to True, will recursively enable specified statistics on all currently instanced SubComponent descendants. SubComponents created after this call will not have their statistics enabled.
Call example:
comp.enableAllStatistics({
"type":"sst.AccumulatorStatistic",
"rate":"0ns"
})
Enables a list of statistics for the component on which the call is made. See "General Notes on Statistics" below for more information.
Parameters:
stat_list: list of statistics to be enabled. If only one stat is to be enabled, you may pass a single string instead of a list.
stat_params_dict: Python dictionary that specified the statistic parameters. All statistics will get the same set of parameters
apply_to_children: If set to True, will recursively enable specified statistics on all currently instanced SubComponent descendants. SubComponents created after this call will not have their statistics enabled.
Documentation forthcoming
Sets the rank the Component should be assigned to. This information is only used if the partitioner is set to sst.self.
Parameters:
mpi_rank: MPI rank the Component should be assigned to
thread: thread the Component should be assigned to
Return value: none
Sets the weight of the Component. The weight is used by some partitioners to help balance Components across ranks.
Parameters:
Return value: none
The Link object is used to connect Component/SubComponents together to form the simulation. The Link is created using:
Parameters:
name: Name of the link
latency: default latency for the link, optional. Must include units (e.g., "ns"). This will be used if no latency is specified in calls to Link.connect() or (Sub)Component.addLink().
Connects two ports using the link object. If a default latency is specified on the Link, then the latency parameters are optional, however, if no default latency is set on the Link, the latency parameters to connect are required.
Parameters:
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.
comp: Component/SubComponent object that the port is a part of
port: port to connect to
latency: latency of link from the perspective of the corresponding Component/SubComponent sending an event. This is optional, and if not specified, the default latency of the link will be used. If no latency is set, either in the call or as a default, the call will fatal.
Return value: none
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. This must be used with care, as you can easily get into a situation where too many components are on the same rank.
Parameters:
Return value: former value of no_cut variable
Documentation forthcoming
Documentation forthcoming
Sets the specified program option for the simulation. These mirror the options available on the sst command line. Parameters set in the python file will be overwritten by options set on the command line. Use sst –help to get a list of available options.
Parameters:
option: configuration option to set
value: value to set option to
Sets the specified program options for the simulation. These mirror the options available on the sst command line. Parameters set in the python file will be overwritten by options set on the command line. Use sst –help to get a list of available options.
Parameters:
Returns a dictionary with the current values of the program options. This will include all program options, not just those set in the python file.
Parameters:
Return value: python dictionary with program options and values
Returns the number of physical MPI ranks in the simulation
Parameters:
Return value: number of MPI ranks in the simulation
Returns the threads per rank specified for the simulation
Parameters:
Return value: number of threads per MPI rank in the simulation
Sets the number of threads per rank for the simulation. This value is overwritten if -n is specified on the command line.
Parameters:
Pushes a name prefix onto the name stack. This prefix will be added on the names of all Components and Links. The names in the stack are separated by a period. Example, if pushNamePrefix("base") and pushNamePrefix("next") were called in that order, the prefixed name would be "base.next". Prefixes can be popped from the stack using popNamePrefix().
Parameters:
Pops a prefix from the name stack. See pushNamePrefix for how name stacks are used.
Causes the simulation to exit.
In many cases, Component and SubComponents will be created using library functions and the user will not have direct access to their handles. In some instances, the provided python modules will have accessor functions that can provide handles to these elements. If this is not provided by the library, the user can call the findComponentByName() function to get a handle to the desired element. The function can find handles for both Components and SubComponents. The use of this function presupposes a knowledge of the naming convention of the elements in the build functions of the library.
Parameters:
Return value: the function will return a handle to the Component/SubComponent with the provided name, or None if the name is not found.
The following functions are used to enable statistics on Components and SubComponents using the name or type of the element. See "General Notes on Statistics" below for more information.
Enables all statistics for all Components in the simulation that have already been instanced.
Parameters:
Enables all statistics for the Component named in the call. This call works for both Components and SubComponents.
Parameters:
name: name of the Component or SubComponent on which to enable all statistics. The name for SubComponents is described above. Slot indexes are optional in cases where only one SubComponent has been added to a slot, but you can also use [0] in all cases, even when the actual name will not display this way. If a component with the provided name is not found, the function will call fatal().
stat_params_dict: Python dictionary that specifies the statistic parameters. All statistics will get the same set of parameters.
apply_to_children: If set to True, will recursively enable all statistics on all SubComponent descendants of named element.
Enables a statistic for the component on which the call is made.
Parameters:
name: name of the Component or SubComponent on which to enable all statistics. The name for SubComponents is described above. Slot indexes are optional in cases where only one SubComponent has been added to a slot, but you can also use [0] in all cases, even when the actual name will not display this way. If a component with the provided name is not found, the function will call fatal().
stat: statistic to be enabled
stat_params_dict: Python dictionary that specified the statistic parameters
apply_to_children: If set to True, will recursively enable specified statistic on all SubComponent descendants.
Enables a list of statistics for the component on which the call is made.
Parameters:
name: name of the Component or SubComponent on which to enable the statistics. The name for SubComponents is described above. Slot indexes are optional in cases where only one SubComponent has been added to a slot, but you can also use [0] in all cases, even when the actual name will not display this way. If a component with the provided name is not found, the function will call fatal().
stat_list: list of statistics to be enabled. If only one stat is to be enabled, you may pass a single string instead of a list.
stat_params_dict: Python dictionary that specified the statistic parameters
apply_to_children: If set to True, will recursively enable specified statistics on all SubComponent descendants.
Enables all statistics for all previously instanced Components/SubComponents of the type specified in the call. This call works for both Components and SubComponents.
Parameters:
type: type of the Component or SubComponent on which to enable all statistics. All previously instanced elements of this type will have their statistics enabled.
stat_params_dict: Python dictionary that specified the statistic parameters. All statistics will get the same set of parameters
apply_to_children: If set to True, will recursively enable all statistics on all SubComponent descendants.
Enables a list of statistics for the component on which the call is made.
Parameters:
type: type of the Component or SubComponent on which to enable all statistics. All previously instanced elements of this type will have their statistics enabled.
stat: statistic to be enabled
stat_params_dict: Python dictionary that specified the statistic parameters
apply_to_children: If set to True, will recursively enable specified statistic on all SubComponent descendants.
Enables a list of statistics for the component on which the call is made.
Parameters:
type: type of the Component or SubComponent on which to enable all statistics. All previously instanced elements of this type will have their statistics enabled.
stat_list: list of statistics to be enabled. If only one stat is to be enabled, you may pass a single string instead of a list.
stat_params_dict: Python dictionary that specified the statistic parameters
apply_to_children: If set to True, will recursively enable specified statistic on all SubComponent descendants.
Sets the statistic load level for the named component.
Parameters:
name: name of the Component or SubComponent on which to enable all statistics. The name for SubComponents is described above. Slot indexes are optional in cases where only one SubComponent has been added to a slot, but you can also use [0] in all cases, even when the actual name will not display this way. If a component with the provided name is not found, the function will call fatal().
level: statistic load level for the component
apply_to_children: If set to True, will recursively enable specified statistic on all SubComponent descendants.
Sets the statistic load level for all components of the specified type.
Parameters:
type: type of the Component or SubComponent on which to enable all statistics. All previously instanced elements of this type will have their level set.
level: statistic load level for the components
apply_to_children: If set to True, will recursively enable specified statistic on all SubComponent descendants.
Set the global statistic load level. This level is used if individual load levels are not set. Also, the load level is only used for statistics not specifically enabled (i.e., not enabled using one of the enableAllStatistics variants).
Parameters:
Return the global load level
Parameters:
Return Value: value of global load level
Sets the global StatisticOutput to be of the module type specified
Parameters:
Set the specified option for the StatisticOutput object.
Parameters:
option: option to set
value: value to set option to
Set the specified options for the StatisticOutput object
Parameters:
There are a number of ways to enable statistics on Components and SubComponents. There are a set of functions that can be called directly on Component/SubComponent handles and a set of functions that are provided by the sst python module that use name or type to find the elements on which to enable statistics. There may also be specific methods provided by element library python modules.
It is possible to set load levels both globally and per Component/SubComponent. Each statistic defined in Components/SubComponents has a load level assigned to it in order to help with finer grained control with using the enableAllStatistics* functions. Load levels only apply to statistics not explicitly enabled. Also, local load levels will override global load levels.
The precedence for enabling statistics is as follows:
If a statistic is explicitly enabled (does not use one of the enableAllStatistics* functions), it will be enabled. Else, if the set load level meets the minimum for a statistic and all statistics for the component have been enabled, the statistic will be enabled. The local load level will be used, if set, otherwise the global load level will be used.
Statistic parameters
Statistic parameters are used to pass the parameters to the statistics subsystem and to the statistics themselves and are specified in a python dictionary. In addition to statistic specific parameters, the following parameters are supported:
type: type of statistic
rate: collection rate of statistic. Stats will be dumped at this interval. A rate of "0ns" will cause the stats to be dumped only at the end of simulation.
startat: Time that statistic should start recording statistics
stopat: Time that statistic should stop recording statistics
resetOnRead: If set to true, statistics will reset when written out. Default is False.