12 #ifndef _SST_CORE_FACTORY_H
13 #define _SST_CORE_FACTORY_H
15 #include <sst/core/sst_types.h>
20 #include <sst/core/params.h>
21 #include <sst/core/elemLoader.h>
22 #include <sst/core/element.h>
23 #include <sst/core/model/element_python.h>
24 #include <sst/core/statapi/statfieldinfo.h>
27 extern int main(
int argc,
char **argv);
30 namespace Statistics {
31 class StatisticOutput;
47 static Factory* getFactory() {
return instance; }
53 bool isPortNameValid(
const std::string &type,
const std::string port_name);
122 const std::string &statName,
const std::string &statSubId,
133 void requireLibrary(std::string &elemlib);
135 void getLoadedLibraryNames(std::set<std::string>& lib_names);
136 void loadUnloadedLibraries(
const std::set<std::string>& lib_names);
181 Module* LoadCoreModule_StatisticOutputs(std::string& type,
Params& params);
183 friend int ::main(
int argc,
char **argv);
185 struct ComponentInfo {
188 std::vector<std::string> ports;
189 std::vector<std::string> statNames;
190 std::vector<std::string> statUnits;
191 std::vector<uint8_t> statEnableLevels;
192 std::vector<std::string> subcomponentslots;
197 component(component), params(params)
200 while ( NULL != p && NULL != p->
name ) {
201 ports.push_back(p->
name);
206 while ( NULL != s && NULL != s->
name ) {
207 statNames.push_back(s->
name);
208 statUnits.push_back(s->
units);
214 while ( NULL != ss && NULL != ss->name ) {
215 subcomponentslots.push_back(ss->name);
220 ComponentInfo(
const ComponentInfo& old) : component(old.component), params(old.params), ports(old.ports),
221 statNames(old.statNames), statUnits(old.statUnits), statEnableLevels(old.statEnableLevels),
222 subcomponentslots(old.subcomponentslots)
225 ComponentInfo& operator=(
const ComponentInfo& old)
227 component = old.component;
230 statNames = old.statNames;
231 statUnits = old.statUnits;
232 statEnableLevels = old.statEnableLevels;
233 subcomponentslots = old.subcomponentslots;
248 ModuleInfo(
const ModuleInfo& old) : module(old.module), params(old.params)
251 ModuleInfo& operator=(
const ModuleInfo& old)
259 struct SubComponentInfo {
262 std::vector<std::string> statNames;
263 std::vector<std::string> statUnits;
264 std::vector<uint8_t> statEnableLevels;
265 std::vector<std::string> ports;
266 std::vector<std::string> subcomponentslots;
268 SubComponentInfo() {}
274 while ( NULL != s && NULL != s->
name ) {
275 statNames.push_back(s->
name);
276 statUnits.push_back(s->
units);
282 while ( NULL != p && NULL != p->
name ) {
283 ports.push_back(p->
name);
288 while ( NULL != ss && NULL != ss->name ) {
289 subcomponentslots.push_back(ss->name);
294 SubComponentInfo(
const SubComponentInfo& old) : subcomponent(old.subcomponent), params(old.params), statNames(old.statNames), statUnits(old.statUnits), statEnableLevels(old.statEnableLevels), subcomponentslots(old.subcomponentslots)
297 SubComponentInfo& operator=(
const SubComponentInfo& old)
299 subcomponent = old.subcomponent;
301 statNames = old.statNames;
302 statUnits = old.statUnits;
303 statEnableLevels = old.statEnableLevels;
304 subcomponentslots = subcomponentslots;
309 typedef std::map<std::string, const ElementLibraryInfo*> eli_map_t;
310 typedef std::map<std::string, ComponentInfo> eic_map_t;
311 typedef std::map<std::string, const ElementInfoEvent*> eie_map_t;
312 typedef std::map<std::string, ModuleInfo> eim_map_t;
313 typedef std::map<std::string, SubComponentInfo> eis_map_t;
314 typedef std::map<std::string, const ElementInfoPartitioner*> eip_map_t;
315 typedef std::map<std::string, const ElementInfoGenerator*> eig_map_t;
317 Factory(std::string searchPaths);
322 void operator=(
Factory const&);
333 eli_map_t loaded_libraries;
334 eic_map_t found_components;
335 eie_map_t found_events;
336 eim_map_t found_modules;
337 eis_map_t found_subcomponents;
338 eip_map_t found_partitioners;
339 eig_map_t found_generators;
340 std::string searchPaths;
342 std::string loadingComponentType;
344 std::pair<std::string, std::string> parseLoadName(
const std::string& wholename);
346 std::recursive_mutex factoryMutex;
355 #endif // SST_CORE_FACTORY_H
const ElementInfoStatistic * stats
Definition: element.h:98
Output object provides consistant method for outputing data to stdout, stderr and/or sst debug file...
Definition: output.h:54
Statistics::StatisticBase * CreateStatistic(BaseComponent *comp, const std::string &type, const std::string &statName, const std::string &statSubId, Params ¶ms, Statistics::StatisticFieldInfo::fieldType_t fieldType)
Instatiate a new Statistic.
Definition: factory.cc:263
Module * CreateCoreModuleWithComponent(std::string type, Component *comp, Params ¶ms)
Instantiate a new Module from within the SST core.
Definition: factory.cc:698
Component * CreateComponent(ComponentId_t id, std::string &componentname, Params ¶ms)
Attempt to create a new Component instantiation.
Definition: factory.cc:164
generateFunction GetGenerator(std::string name)
Return generator function.
Definition: factory.cc:849
void RequireEvent(std::string eventname)
Ensure that an element library containing the required event is loaded.
Definition: factory.cc:798
Describes a Component and its associated information.
Definition: element.h:49
bool isPortNameValid(const std::string &type, const std::string port_name)
Get a list of allowed ports for a given component type.
Definition: factory.cc:109
Forms the base class for statistics output generation within the SST core.
Definition: statoutput.h:47
Describes all the parts of the Element Library.
Definition: element.h:130
Main component object for the simulation.
Definition: component.h:32
bool hasLibrary(std::string elemlib)
Checks to see if library exists and can be loaded.
Definition: factory.cc:921
Statistics::StatisticOutput * CreateStatisticOutput(const std::string &statOutputType, const Params &statOutputParams)
Attempt to create a new Statistic Output instantiation.
Definition: factory.cc:221
Forms the base class for statistics gathering within SST.
Definition: statbase.h:61
bool DoesComponentInfoStatisticNameExist(const std::string &type, const std::string &statisticName)
Determine if a statistic is defined in a components ElementInfoStatistic.
Definition: factory.cc:363
std::string GetComponentInfoStatisticUnits(const std::string &type, const std::string &statisticName)
Get the units of a statistic defined in the component's ElementInfoStatistic.
Definition: factory.cc:527
const ElementInfoStatistic * stats
Definition: element.h:57
Describes Statistics used by a Component.
Definition: elibase.h:31
Module is a tag class used with the loadModule function.
Definition: module.h:20
Module * CreateCoreModule(std::string type, Params ¶ms)
Instantiate a new Module from within the SST core.
Definition: factory.cc:679
Module * CreateModuleWithComponent(std::string type, Component *comp, Params ¶ms)
Instatiate a new Module.
Definition: factory.cc:705
Class to load Element Libraries.
Definition: elemLoader.h:24
uint8_t GetComponentInfoStatisticEnableLevel(const std::string &type, const std::string &statisticName)
Get the enable level of a statistic defined in the component's ElementInfoStatistic.
Definition: factory.cc:466
Partition::SSTPartitioner * CreatePartitioner(std::string name, RankInfo total_ranks, RankInfo my_rank, int verbosity)
Return partitioner function.
Definition: factory.cc:817
Definition: rankInfo.h:21
const char * name
Definition: elibase.h:32
Main component object for the simulation.
Definition: baseComponent.h:104
Describes Parameters to a Component.
Definition: elibase.h:40
Base class for Partitioning graphs.
Definition: sstpart.h:31
Describes a Module.
Definition: element.h:82
const ElementInfoPort * ports
Definition: element.h:55
Parameter store.
Definition: params.h:45
const ElementInfoPort * ports
Definition: element.h:100
SSTElementPythonModule * getPythonModule(std::string name)
Return Python Module creation function.
Definition: factory.cc:874
const char * name
Definition: elibase.h:49
const uint8_t enableLevel
Definition: elibase.h:35
Class for instantiating Components, Links and the like out of element libraries.
Definition: factory.h:44
Base class for python modules in element libraries.
Definition: element_python.h:26
std::set< key_type, KeyCompare > KeySet_t
Definition: params.h:94
bool DoesSubComponentInfoStatisticNameExist(const std::string &type, const std::string &statisticName)
Determine if a statistic is defined in a subcomponents ElementInfoStatistic.
Definition: factory.cc:415
SubComponent * CreateSubComponent(std::string type, Component *comp, Params ¶ms)
Instatiate a new Module.
Definition: factory.cc:753
Describes Ports that the Component can use.
Definition: elibase.h:48
SubComponent is a class loadable through the factory which allows dynamic functionality to be added t...
Definition: subcomponent.h:29
const char * units
Definition: elibase.h:34
fieldType_t
Supported Field Types.
Definition: statfieldinfo.h:36
bool DoesSubComponentSlotExist(const std::string &type, const std::string &slotName)
Determine if a SubComponentSlot is defined in a components ElementInfoStatistic.
Definition: factory.cc:300
Module * CreateModule(std::string type, Params ¶ms)
Instatiate a new Module.
Definition: factory.cc:586