12 #ifndef SST_CORE_ELEMENTINFO_H
13 #define SST_CORE_ELEMENTINFO_H
15 #include <sst/core/sst_types.h>
16 #include <sst/core/warnmacros.h>
17 #include <sst/core/params.h>
22 #include <sst/core/elibase.h>
32 class SSTElementPythonModule;
38 const std::vector<int> SST_ELI_VERSION = {0, 9, 0};
43 virtual const std::string getLibrary() = 0;
44 virtual const std::string getDescription() = 0;
45 virtual const std::string getName() = 0;
46 virtual const std::vector<int>& getVersion() = 0;
47 virtual const std::string getCompileFile() = 0;
48 virtual const std::string getCompileDate() = 0;
50 virtual const std::vector<int>& getELICompiledVersion() = 0;
52 std::string getELIVersionString();
60 void initialize_allowedKeys();
64 virtual const std::vector<ElementInfoParam>& getValidParams() = 0;
68 std::string getParametersString();
75 std::vector<std::string> portnames;
76 std::vector<std::string> statnames;
78 void initialize_portnames();
79 void initialize_statnames();
83 virtual const std::vector<ElementInfoPort2>& getValidPorts() = 0;
84 virtual const std::vector<ElementInfoStatistic>& getValidStats() = 0;
85 virtual const std::vector<ElementInfoSubComponentSlot>& getSubComponentSlots() = 0;
87 const std::vector<std::string>& getPortnames() {
return portnames; }
88 const std::vector<std::string>& getStatnames() {
return statnames; }
90 std::string getStatisticsString();
91 std::string getPortsString();
92 std::string getSubComponentSlotString();
104 virtual uint32_t getCategory() = 0;
106 std::string toString();
114 virtual const std::string getInterface() = 0;
116 std::string toString();
126 virtual Module* create(
Params& UNUSED(params)) {
return NULL; }
127 virtual const std::string getInterface() = 0;
129 std::string toString();
137 std::string toString();
143 const std::string getDescription() {
return getLibrary() +
" python module"; };
144 const std::string getName() {
return getLibrary(); }
150 std::map<std::string,ComponentElementInfo*> components;
151 std::map<std::string,SubComponentElementInfo*> subcomponents;
152 std::map<std::string,ModuleElementInfo*> modules;
153 std::map<std::string,PartitionerElementInfo*> partitioners;
157 python_module(NULL) {}
163 bcei = getSubComponent(name);
168 if ( components.count(name) == 0 )
return NULL;
169 return components[name];
173 if ( subcomponents.count(name) == 0 )
return NULL;
174 return subcomponents[name];
178 if ( modules.count(name) == 0 )
return NULL;
179 return modules[name];
183 if ( partitioners.count(name) == 0 )
return NULL;
184 return partitioners[name];
188 return python_module;
191 std::string toString();
198 static std::map<std::string,LibraryInfo*> libraries;
200 static LibraryInfo* getLibrary(
const std::string &library) {
201 if ( libraries.count(library) == 0 ) {
204 return libraries[library];
209 LibraryInfo* library = getLibrary(comp->getLibrary());
210 library->components[comp->getName()] = comp;
215 LibraryInfo* library = getLibrary(comp->getLibrary());
216 library->subcomponents[comp->getName()] = comp;
221 LibraryInfo* library = getLibrary(comp->getLibrary());
222 library->modules[comp->getName()] = comp;
227 LibraryInfo* library = getLibrary(part->getLibrary());
228 library->partitioners[part->getName()] = part;
233 LibraryInfo* library = getLibrary(pymod->getLibrary());
234 if ( library->python_module == NULL ) {
235 library->python_module = pymod;
243 static std::string toString();
245 static LibraryInfo* getLibraryInfo(
const std::string &library) {
246 if ( libraries.count(library) == 0 )
return NULL;
247 return libraries[library];
267 static const bool loaded;
272 initialize_allowedKeys();
273 initialize_portnames();
274 initialize_statnames();
279 return T::ELI_create(
id,params);
282 static bool isLoaded() {
return loaded; }
283 const std::string getLibrary() {
return T::ELI_getLibrary(); }
284 const std::string getName() {
return T::ELI_getName(); }
285 const std::string getDescription() {
return T::ELI_getDescription(); }
286 const std::vector<ElementInfoParam>& getValidParams() {
return T::ELI_getParams(); }
287 const std::vector<ElementInfoStatistic>& getValidStats() {
return T::ELI_getStatistics(); }
288 const std::vector<ElementInfoPort2>& getValidPorts() {
return T::ELI_getPorts(); }
289 const std::vector<ElementInfoSubComponentSlot>& getSubComponentSlots() {
return T::ELI_getSubComponentSlots(); }
290 uint32_t getCategory() {
return T::ELI_getCategory(); };
291 const std::vector<int>& getELICompiledVersion() {
return T::ELI_getELICompiledVersion(); }
292 const std::vector<int>& getVersion() {
return T::ELI_getVersion(); }
293 const std::string getCompileFile() {
return T::ELI_getCompileFile(); }
294 const std::string getCompileDate() {
return T::ELI_getCompileDate(); }
308 static const bool loaded;
313 initialize_allowedKeys();
314 initialize_portnames();
315 initialize_statnames();
320 return T::ELI_create(comp,params);
323 static bool isLoaded() {
return loaded; }
324 const std::string getLibrary() {
return T::ELI_getLibrary(); }
325 const std::string getName() {
return T::ELI_getName(); }
326 const std::string getDescription() {
return T::ELI_getDescription(); }
327 const std::vector<ElementInfoParam>& getValidParams() {
return T::ELI_getParams(); }
328 const std::vector<ElementInfoStatistic>& getValidStats() {
return T::ELI_getStatistics(); }
329 const std::vector<ElementInfoPort2>& getValidPorts() {
return T::ELI_getPorts(); }
330 const std::vector<ElementInfoSubComponentSlot>& getSubComponentSlots() {
return T::ELI_getSubComponentSlots(); }
331 const std::string getInterface() {
return T::ELI_getInterface(); }
332 const std::vector<int>& getELICompiledVersion() {
return T::ELI_getELICompiledVersion(); }
333 const std::vector<int>& getVersion() {
return T::ELI_getVersion(); }
334 const std::string getCompileFile() {
return T::ELI_getCompileFile(); }
335 const std::string getCompileDate() {
return T::ELI_getCompileDate(); }
350 static const bool loaded;
355 initialize_allowedKeys();
359 return new T(comp,params);
363 return new T(params);
366 static bool isLoaded() {
return loaded; }
367 const std::string getLibrary() {
return T::ELI_getLibrary(); }
368 const std::string getName() {
return T::ELI_getName(); }
369 const std::string getDescription() {
return T::ELI_getDescription(); }
370 const std::vector<ElementInfoParam>& getValidParams() {
return T::ELI_getParams(); }
371 const std::string getInterface() {
return T::ELI_getInterface(); }
372 const std::vector<int>& getELICompiledVersion() {
return T::ELI_getELICompiledVersion(); }
373 const std::vector<int>& getVersion() {
return T::ELI_getVersion(); }
374 const std::string getCompileFile() {
return T::ELI_getCompileFile(); }
375 const std::string getCompileDate() {
return T::ELI_getCompileDate(); }
381 static const bool loaded;
386 initialize_allowedKeys();
390 return new T(comp,params);
393 static bool isLoaded() {
return loaded; }
394 const std::string getLibrary() {
return T::ELI_getLibrary(); }
395 const std::string getName() {
return T::ELI_getName(); }
396 const std::string getDescription() {
return T::ELI_getDescription(); }
397 const std::vector<ElementInfoParam>& getValidParams() {
return T::ELI_getParams(); }
398 const std::string getInterface() {
return T::ELI_getInterface(); }
399 const std::vector<int>& getELICompiledVersion() {
return T::ELI_getELICompiledVersion(); }
400 const std::vector<int>& getVersion() {
return T::ELI_getVersion(); }
401 const std::string getCompileFile() {
return T::ELI_getCompileFile(); }
402 const std::string getCompileDate() {
return T::ELI_getCompileDate(); }
408 static const bool loaded;
413 initialize_allowedKeys();
417 return new T(params);
420 static bool isLoaded() {
return loaded; }
421 const std::string getLibrary() {
return T::ELI_getLibrary(); }
422 const std::string getName() {
return T::ELI_getName(); }
423 const std::string getDescription() {
return T::ELI_getDescription(); }
424 const std::vector<ElementInfoParam>& getValidParams() {
return T::ELI_getParams(); }
425 const std::string getInterface() {
return T::ELI_getInterface(); }
426 const std::vector<int>& getELICompiledVersion() {
return T::ELI_getELICompiledVersion(); }
427 const std::vector<int>& getVersion() {
return T::ELI_getVersion(); }
428 const std::string getCompileFile() {
return T::ELI_getCompileFile(); }
429 const std::string getCompileDate() {
return T::ELI_getCompileDate(); }
436 typename std::enable_if<std::is_constructible<T,Component*,Params&>::value &&
443 typename std::enable_if<std::is_constructible<T,Component*,Params&>::value &&
444 not std::is_constructible<T,Params&>::value, ModuleElementInfo*>::type
446 return new ModuleDocWithComponent<T>();
450 typename std::enable_if<not std::is_constructible<T,Component*,Params&>::value &&
451 std::is_constructible<T,Params&>::value, ModuleElementInfo*>::type
453 return new ModuleDocWithoutComponent<T>();
456 template<
class T>
const bool ModuleDoc<T>::loaded = ElementLibraryDatabase::addModule(createModuleDoc<T>());
467 static const bool loaded;
472 return new T(total_ranks,my_rank,verbosity);
475 static bool isLoaded() {
return loaded; }
476 const std::string getDescription()
override {
return T::ELI_getDescription(); }
477 const std::string getName()
override {
return T::ELI_getName(); }
478 const std::string getLibrary()
override {
return T::ELI_getLibrary(); }
479 const std::vector<int>& getELICompiledVersion()
override {
return T::ELI_getELICompiledVersion(); }
480 const std::vector<int>& getVersion()
override {
return T::ELI_getVersion(); }
481 const std::string getCompileFile()
override {
return T::ELI_getCompileFile(); }
482 const std::string getCompileDate()
override {
return T::ELI_getCompileDate(); }
494 static const bool loaded;
502 if( instance == NULL ) instance =
new T(getLibrary());
506 static bool isLoaded() {
return loaded; }
507 const std::string getLibrary() {
return T::ELI_getLibrary(); }
508 const std::vector<int>& getELICompiledVersion() {
return T::ELI_getELICompiledVersion(); }
509 const std::vector<int>& getVersion() {
return T::ELI_getVersion(); }
510 const std::string getCompileFile() {
return T::ELI_getCompileFile(); }
511 const std::string getCompileDate() {
return T::ELI_getCompileDate(); }
521 #define SST_ELI_INSERT_COMPILE_INFO() \
522 static const std::string& ELI_getCompileDate() { \
523 static std::string time = __TIME__; \
524 static std::string date = __DATE__; \
525 static std::string date_time = date + " " + time; \
528 static const std::string ELI_getCompileFile() { \
531 static const std::vector<int>& ELI_getELICompiledVersion() { \
532 static const std::vector<int> var(SST_ELI_VERSION); \
537 #define SST_ELI_REGISTER_COMPONENT_CUSTOM_CREATE(cls,lib,name,desc,cat) \
538 friend class ComponentDoc<cls>; \
539 bool ELI_isLoaded() { \
540 return ComponentDoc<cls>::isLoaded(); \
542 static const std::string ELI_getLibrary() { \
545 static const std::string ELI_getName() { \
548 static const std::string ELI_getDescription() { \
551 static const uint32_t ELI_getCategory() { \
554 SST_ELI_INSERT_COMPILE_INFO()
556 #define SST_ELI_REGISTER_COMPONENT(cls,lib,name,desc,cat) \
557 static Component* ELI_create(ComponentId_t id, Params& params) { \
558 return new cls(id,params); \
560 SST_ELI_REGISTER_COMPONENT_CUSTOM_CREATE(cls,lib,name,desc,cat)
563 #define SST_ELI_DOCUMENT_VERSION(major,minor,tertiary) \
564 static const std::vector<int>& ELI_getVersion() { \
565 static std::vector<int> var = { major, minor, tertiary } ; \
569 #define SST_ELI_DOCUMENT_PARAMS(...) \
570 static const std::vector<ElementInfoParam>& ELI_getParams() { \
571 static std::vector<ElementInfoParam> var = { __VA_ARGS__ } ; \
576 #define SST_ELI_DOCUMENT_STATISTICS(...) \
577 static const std::vector<ElementInfoStatistic>& ELI_getStatistics() { \
578 static std::vector<ElementInfoStatistic> var = { __VA_ARGS__ } ; \
583 #define SST_ELI_DOCUMENT_PORTS(...) \
584 static const std::vector<ElementInfoPort2>& ELI_getPorts() { \
585 static std::vector<ElementInfoPort2> var = { __VA_ARGS__ } ; \
589 #define SST_ELI_DOCUMENT_SUBCOMPONENT_SLOTS(...) \
590 static const std::vector<ElementInfoSubComponentSlot>& ELI_getSubComponentSlots() { \
591 static std::vector<ElementInfoSubComponentSlot> var = { __VA_ARGS__ } ; \
596 #define SST_ELI_REGISTER_SUBCOMPONENT_CUSTOM_CREATE(cls,lib,name,desc,interface) \
597 friend class SubComponentDoc<cls>; \
598 bool ELI_isLoaded() { \
599 return SubComponentDoc<cls>::isLoaded(); \
601 static const std::string ELI_getLibrary() { \
604 static const std::string ELI_getName() { \
607 static const std::string ELI_getDescription() { \
610 static const std::string ELI_getInterface() { \
613 SST_ELI_INSERT_COMPILE_INFO()
615 #define SST_ELI_REGISTER_SUBCOMPONENT(cls,lib,name,desc,interface) \
616 static SubComponent* ELI_create(Component* comp, Params& params) { \
617 return new cls(comp,params); \
619 SST_ELI_REGISTER_SUBCOMPONENT_CUSTOM_CREATE(cls,lib,name,desc,interface)
622 #define SST_ELI_REGISTER_MODULE(cls,lib,name,desc,interface) \
623 friend class ModuleDoc<cls>; \
624 bool ELI_isLoaded() { \
625 return ModuleDoc<cls>::isLoaded(); \
627 static const std::string ELI_getLibrary() { \
630 static const std::string ELI_getName() { \
633 static const std::string ELI_getDescription() { \
636 static const std::string ELI_getInterface() { \
639 SST_ELI_INSERT_COMPILE_INFO()
643 #define SST_ELI_REGISTER_PARTITIONER(cls,lib,name,desc) \
644 friend class PartitionerDoc<cls>; \
645 bool ELI_isLoaded() { \
646 return PartitionerDoc<cls>::isLoaded(); \
648 static const std::string ELI_getLibrary() { \
651 static const std::string ELI_getName() { \
654 static const std::string ELI_getDescription() { \
657 SST_ELI_INSERT_COMPILE_INFO()
661 #define SST_ELI_REGISTER_PYTHON_MODULE(cls,lib) \
662 friend class PythonModuleDoc<cls>; \
663 bool ELI_isLoaded() { \
664 return PythonModuleDoc<cls>::isLoaded(); \
666 static const std::string ELI_getLibrary() { \
669 SST_ELI_INSERT_COMPILE_INFO()
674 #endif // SST_CORE_ELEMENTINFO_H
Definition: elementinfo.h:148
Definition: elementinfo.h:195
Definition: elementinfo.h:40
Main component object for the simulation.
Definition: component.h:32
Definition: elementinfo.h:120
Definition: elementinfo.h:379
Definition: elementinfo.h:465
Definition: elementinfo.h:97
Module is a tag class used with the loadModule function.
Definition: module.h:20
Definition: elementinfo.h:265
Definition: elementinfo.h:140
Definition: elementinfo.h:133
Definition: elementinfo.h:306
Definition: rankInfo.h:21
Definition: elementinfo.h:109
Definition: elementinfo.h:72
Base class for Partitioning graphs.
Definition: sstpart.h:31
Definition: elementinfo.h:55
Parameter store.
Definition: params.h:45
Definition: elementinfo.h:492
Definition: elementinfo.h:348
Base class for python modules in element libraries.
Definition: element_python.h:26
std::set< key_type, KeyCompare > KeySet_t
Definition: params.h:94
Definition: elementinfo.h:406
SubComponent is a class loadable through the factory which allows dynamic functionality to be added t...
Definition: subcomponent.h:29