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/elementinfo.h>
24 #include <sst/core/model/element_python.h>
25 #include <sst/core/statapi/statfieldinfo.h>
28 extern int main(
int argc,
char **argv);
31 namespace Statistics {
32 class StatisticOutput;
48 static Factory* getFactory() {
return instance; }
54 bool isPortNameValid(
const std::string &type,
const std::string port_name);
123 const std::string &statName,
const std::string &statSubId,
134 void requireLibrary(std::string &elemlib);
136 void getLoadedLibraryNames(std::set<std::string>& lib_names);
137 void loadUnloadedLibraries(
const std::set<std::string>& lib_names);
182 Module* LoadCoreModule_StatisticOutputs(std::string& type,
Params& params);
184 friend int ::main(
int argc,
char **argv);
187 typedef std::map<std::string, const ElementLibraryInfo*> eli_map_t;
190 typedef std::map<std::string, const ElementInfoGenerator*> eig_map_t;
192 Factory(std::string searchPaths);
197 void operator=(
Factory const&);
206 eli_map_t loaded_libraries;
207 eig_map_t found_generators;
209 std::string searchPaths;
212 std::string loadingComponentType;
214 std::pair<std::string, std::string> parseLoadName(
const std::string& wholename);
216 std::recursive_mutex factoryMutex;
238 std::string description;
240 std::vector<ElementInfoParam> valid_params;
241 std::vector<ElementInfoStatistic> valid_stats;
242 std::vector<ElementInfoPort2> valid_ports;
243 std::vector<ElementInfoSubComponentSlot> subcomp_slots;
247 componentAllocate alloc;
254 name(component->
name),
257 alloc(component->
alloc)
261 while ( NULL != p && NULL != p->
name ) {
262 valid_params.emplace_back(*p);
267 while ( NULL != po && NULL != po->
name ) {
268 valid_ports.emplace_back(po);
273 while ( NULL != s && NULL != s->
name ) {
274 valid_stats.emplace_back(*s);
279 while ( NULL != ss && NULL != ss->name ) {
280 subcomp_slots.emplace_back(*ss);
284 initialize_allowedKeys();
285 initialize_portnames();
286 initialize_statnames();
290 return (*alloc)(id,params);
293 const std::string getLibrary() {
return library; }
294 const std::string getName() {
return name; }
295 const std::string getDescription() {
return description; }
296 const std::vector<ElementInfoParam>& getValidParams() {
return valid_params; }
297 const std::vector<ElementInfoStatistic>& getValidStats() {
return valid_stats; }
298 const std::vector<ElementInfoPort2>& getValidPorts() {
return valid_ports; }
299 const std::vector<ElementInfoSubComponentSlot>& getSubComponentSlots() {
return subcomp_slots; }
301 uint32_t getCategory() {
return category; }
302 const std::vector<int>& getELICompiledVersion() {
static std::vector<int> vec = {-1, -1, -1};
304 const std::vector<int>& getVersion() {
static std::vector<int> vec = {-1, -1, -1};
306 const std::string getCompileFile() {
return "UNKNOWN"; }
307 const std::string getCompileDate() {
return "UNKNOWN"; }
320 std::string description;
322 std::vector<ElementInfoParam> valid_params;
323 std::vector<ElementInfoStatistic> valid_stats;
324 std::vector<ElementInfoPort2> valid_ports;
325 std::vector<ElementInfoSubComponentSlot> subcomp_slots;
327 std::string interface;
328 subcomponentAllocate alloc;
335 name(component->
name),
338 alloc(component->
alloc)
343 while ( NULL != p && NULL != p->
name ) {
344 valid_params.emplace_back(*p);
349 while ( NULL != po && NULL != po->
name ) {
350 valid_ports.emplace_back(po);
355 while ( NULL != s && NULL != s->
name ) {
356 valid_stats.emplace_back(*s);
361 while ( NULL != ss && NULL != ss->name ) {
362 subcomp_slots.emplace_back(*ss);
367 initialize_allowedKeys();
368 initialize_portnames();
369 initialize_statnames();
373 return (*alloc)(comp,params);
376 const std::string getLibrary() {
return library; }
377 const std::string getName() {
return name; }
378 const std::string getDescription() {
return description; }
379 const std::vector<ElementInfoParam>& getValidParams() {
return valid_params; }
380 const std::vector<ElementInfoStatistic>& getValidStats() {
return valid_stats; }
381 const std::vector<ElementInfoPort2>& getValidPorts() {
return valid_ports; }
382 const std::vector<ElementInfoSubComponentSlot>& getSubComponentSlots() {
return subcomp_slots; }
383 const std::string getInterface() {
return interface; }
385 const std::vector<int>& getELICompiledVersion() {
static std::vector<int> vec = {-1, -1, -1};
387 const std::vector<int>& getVersion() {
static std::vector<int> vec = {-1, -1, -1};
389 const std::string getCompileFile() {
return "UNKNOWN"; }
390 const std::string getCompileDate() {
return "UNKNOWN"; }
404 std::string description;
406 std::vector<ElementInfoParam> valid_params;
408 std::string interface;
410 moduleAllocate alloc;
411 moduleAllocateWithComponent allocWithComponent;
420 alloc(module->
alloc),
425 while ( NULL != p && NULL != p->
name ) {
426 valid_params.emplace_back(*p);
430 initialize_allowedKeys();
434 return (*allocWithComponent)(comp,params);
438 return (*alloc)(params);
441 const std::string getLibrary() {
return library; }
442 const std::string getName() {
return name; }
443 const std::string getDescription() {
return description; }
444 const std::vector<ElementInfoParam>& getValidParams() {
return valid_params; }
445 const std::string getInterface() {
return interface; }
447 const std::vector<int>& getELICompiledVersion() {
static std::vector<int> vec = {-1, -1, -1};
449 const std::vector<int>& getVersion() {
static std::vector<int> vec = {-1, -1, -1};
451 const std::string getCompileFile() {
return "UNKNOWN"; }
452 const std::string getCompileDate() {
return "UNKNOWN"; }
466 std::string description;
468 partitionFunction alloc;
482 return (*alloc)(total_ranks,my_rank,verbosity);
485 const std::string getLibrary()
override {
return library; }
486 const std::string getName()
override {
return name; }
487 const std::string getDescription()
override {
return description; }
489 const std::vector<int>& getELICompiledVersion()
override {
static std::vector<int> vec = {-1, -1, -1};
491 const std::vector<int>& getVersion()
override {
static std::vector<int> vec = {-1, -1, -1};
493 const std::string getCompileFile()
override {
return "UNKNOWN"; }
494 const std::string getCompileDate()
override {
return "UNKNOWN"; }
507 genPythonModuleFunction alloc;
524 const std::string getLibrary()
override {
return library; }
526 const std::vector<int>& getELICompiledVersion()
override {
static std::vector<int> vec = {-1, -1, -1};
528 const std::vector<int>& getVersion()
override {
static std::vector<int> vec = {-1, -1, -1};
530 const std::string getCompileFile()
override {
return "UNKNOWN"; }
531 const std::string getCompileDate()
override {
return "UNKNOWN"; }
537 #endif // SST_CORE_FACTORY_H
Definition: factory.h:233
const ElementInfoStatistic * stats
Definition: element.h:98
Output object provides consistent method for outputting 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)
Instantiate a new Statistic.
Definition: factory.cc:232
Definition: factory.h:315
Module * CreateCoreModuleWithComponent(std::string type, Component *comp, Params ¶ms)
Instantiate a new Module from within the SST core.
Definition: factory.cc:540
Component * CreateComponent(ComponentId_t id, std::string &componentname, Params ¶ms)
Attempt to create a new Component instantiation.
Definition: factory.cc:155
generateFunction GetGenerator(std::string name)
Return generator function.
Definition: factory.cc:657
void RequireEvent(std::string eventname)
Ensure that an element library containing the required event is loaded.
Definition: factory.cc:611
Definition: element_python.h:51
Describes a Component and its associated information.
Definition: element.h:49
componentAllocate alloc
Definition: element.h:53
Describes a Partitioner.
Definition: element.h:106
const char * description
Definition: element.h:51
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:112
Forms the base class for statistics output generation within the SST core.
Definition: statoutput.h:47
uint32_t category
Definition: element.h:56
const char * name
Definition: element.h:50
Describes all the parts of the Element Library.
Definition: element.h:127
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:702
Definition: elementinfo.h:120
moduleAllocate alloc
Definition: element.h:86
Statistics::StatisticOutput * CreateStatisticOutput(const std::string &statOutputType, const Params &statOutputParams)
Attempt to create a new Statistic Output instantiation.
Definition: factory.cc:190
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:302
Definition: factory.h:461
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:411
const ElementInfoStatistic * stats
Definition: element.h:57
Definition: elementinfo.h:97
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:534
Module * CreateModuleWithComponent(std::string type, Component *comp, Params ¶ms)
Instantiate a new Module.
Definition: factory.cc:547
Class to load Element Libraries.
Definition: elemLoader.h:24
Definition: elementinfo.h:140
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:375
Partition::SSTPartitioner * CreatePartitioner(std::string name, RankInfo total_ranks, RankInfo my_rank, int verbosity)
Return partitioner function.
Definition: factory.cc:633
const char * description
Definition: element.h:108
const char * name
Definition: elibase.h:41
Definition: elementinfo.h:133
Definition: factory.h:500
Definition: rankInfo.h:21
const char * name
Definition: elibase.h:32
Main component object for the simulation.
Definition: baseComponent.h:104
const ElementInfoParam * params
Definition: element.h:97
Describes Parameters to a Component.
Definition: elibase.h:40
partitionFunction func
Definition: element.h:110
const char * description
Definition: element.h:84
Definition: elementinfo.h:109
subcomponentAllocate alloc
Definition: element.h:96
moduleAllocateWithComponent alloc_with_comp
Definition: element.h:87
Base class for Partitioning graphs.
Definition: sstpart.h:31
const char * name
Definition: element.h:83
const char * provides
Definition: element.h:99
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:682
const char * name
Definition: elibase.h:49
const char * description
Definition: element.h:94
Class for instantiating Components, Links and the like out of element libraries.
Definition: factory.h:45
Base class for python modules in element libraries.
Definition: element_python.h:26
const ElementInfoParam * params
Definition: element.h:88
bool DoesSubComponentInfoStatisticNameExist(const std::string &type, const std::string &statisticName)
Determine if a statistic is defined in a subcomponents ElementInfoStatistic.
Definition: factory.cc:339
const ElementInfoParam * params
Definition: element.h:54
SubComponent * CreateSubComponent(std::string type, Component *comp, Params ¶ms)
Instantiate a new Module.
Definition: factory.cc:582
const char * name
Definition: element.h:107
Describes Ports that the Component can use.
Definition: elibase.h:48
const char * name
Definition: element.h:93
SubComponent is a class loadable through the factory which allows dynamic functionality to be added t...
Definition: subcomponent.h:29
Definition: factory.h:399
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:269
Module * CreateModule(std::string type, Params ¶ms)
Instantiate a new Module.
Definition: factory.cc:446