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];
265 template <
typename F, F>
struct check;
268 typedef long NotMatch;
270 typedef const std::vector<ElementInfoParam>& (*functionsig)();
272 template <
typename F>
static Match HasFunction(check<functionsig, &F::ELI_getParams >*);
273 template <
typename F>
static NotMatch HasFunction(...);
276 static bool const value = (
sizeof(HasFunction<T>(0)) ==
sizeof(Match) );
281 typename std::enable_if<checkForELI_getParamsFunction<T>::value,
const std::vector<ElementInfoParam>& >::type
282 ELI_templatedGetParams() {
283 return T::ELI_getParams();
287 typename std::enable_if<not checkForELI_getParamsFunction<T>::value, std::vector<ElementInfoParam>& >::type
288 ELI_templatedGetParams() {
289 static std::vector<ElementInfoParam> var;
300 template <
typename F, F>
struct check;
303 typedef long NotMatch;
305 typedef const std::vector<ElementInfoStatistic>& (*functionsig)();
307 template <
typename F>
static Match HasFunction(check<functionsig, &F::ELI_getStatistics>*);
308 template <
typename F>
static NotMatch HasFunction(...);
311 static bool const value = (
sizeof(HasFunction<T>(0)) ==
sizeof(Match) );
315 typename std::enable_if<checkForELI_getStatisticsFunction<T>::value,
const std::vector<ElementInfoStatistic>& >::type
316 ELI_templatedGetStatistics() {
317 return T::ELI_getStatistics();
321 typename std::enable_if<not checkForELI_getStatisticsFunction<T>::value,
const std::vector<ElementInfoStatistic>& >::type
322 ELI_templatedGetStatistics() {
323 static std::vector<ElementInfoStatistic> var;
334 template <
typename F, F>
struct check;
337 typedef long NotMatch;
339 typedef const std::vector<ElementInfoPort2>& (*functionsig)();
341 template <
typename F>
static Match HasFunction(check<functionsig, &F::ELI_getPorts>*);
342 template <
typename F>
static NotMatch HasFunction(...);
345 static bool const value = (
sizeof(HasFunction<T>(0)) ==
sizeof(Match) );
349 typename std::enable_if<checkForELI_getPortsFunction<T>::value,
const std::vector<ElementInfoPort2>& >::type
350 ELI_templatedGetPorts() {
351 return T::ELI_getPorts();
355 typename std::enable_if<not checkForELI_getPortsFunction<T>::value,
const std::vector<ElementInfoPort2>& >::type
356 ELI_templatedGetPorts() {
357 static std::vector<ElementInfoPort2> var;
368 template <
typename F, F>
struct check;
371 typedef long NotMatch;
373 typedef const std::vector<ElementInfoSubComponentSlot>& (*functionsig)();
375 template <
typename F>
static Match HasFunction(check<functionsig, &F::ELI_getSubComponentSlots>*);
376 template <
typename F>
static NotMatch HasFunction(...);
379 static bool const value = (
sizeof(HasFunction<T>(0)) ==
sizeof(Match) );
383 typename std::enable_if<checkForELI_getSubComponentSlotsFunction<T>::value,
const std::vector<ElementInfoSubComponentSlot>& >::type
384 ELI_templatedGetSubComponentSlots() {
385 return T::ELI_getSubComponentSlots();
389 typename std::enable_if<not checkForELI_getSubComponentSlotsFunction<T>::value,
const std::vector<ElementInfoSubComponentSlot>& >::type
390 ELI_templatedGetSubComponentSlots() {
391 static std::vector<ElementInfoSubComponentSlot> var;
402 template <
typename F, F>
struct check;
405 typedef long NotMatch;
409 template <
typename F>
static Match HasFunction(check<functionsig, &F::ELI_CustomCreate>*);
410 template <
typename F>
static NotMatch HasFunction(...);
413 static bool const value = (
sizeof(HasFunction<T>(0)) ==
sizeof(Match) );
417 typename std::enable_if<checkForELI_CustomCreateFunctionforComponent<T>::value,
Component* >::type
418 ELI_templatedCreateforComponent(ComponentId_t
id,
Params& params) {
419 return T::ELI_CustomCreate(
id, params);
423 typename std::enable_if<not checkForELI_CustomCreateFunctionforComponent<T>::value, Component* >::type
424 ELI_templatedCreateforComponent(ComponentId_t
id, Params& params) {
425 return new T(
id, params);
434 template <
typename F, F>
struct check;
437 typedef long NotMatch;
439 struct FunctionSignature
444 template <
typename F>
static Match HasFunction(check< typename FunctionSignature::function, &F::ELI_CustomCreate>*);
445 template <
typename F>
static NotMatch HasFunction(...);
448 static bool const value = (
sizeof(HasFunction<T>(0)) ==
sizeof(Match) );
452 typename std::enable_if<checkForELI_CustomCreateFunctionforSubComponent<T>::value,
SubComponent* >::type
454 return T::ELI_CustomCreate(comp, params);
458 typename std::enable_if<not checkForELI_CustomCreateFunctionforSubComponent<T>::value, SubComponent* >::type
459 ELI_templatedCreateforSubComponent(Component* comp, Params& params) {
460 return new T(comp, params);
468 class checkForCustomCreateComponent
470 template <
typename F, F>
struct check;
473 typedef long NotMatch;
482 struct FunctionSignature
484 typedef Component* (*function)(ComponentId_t,Params&);
489 template <
typename F>
static Match HasCustomCreate(check< typename FunctionSignature::function, &F::ELI_Custom_Create >*);
490 template <
typename F>
static NotMatch HasCustomCreate(...);
493 static bool const value = (
sizeof(HasCustomCreate<T>(0)) ==
sizeof(Match) );
504 template <
class T,
unsigned V1,
unsigned V2,
unsigned V3>
507 static const bool loaded;
512 initialize_allowedKeys();
513 initialize_portnames();
514 initialize_statnames();
519 return ELI_templatedCreateforComponent<T>(id,params);
522 static bool isLoaded() {
return loaded; }
523 const std::string getLibrary() {
return T::ELI_getLibrary(); }
524 const std::string getName() {
return T::ELI_getName(); }
525 const std::string getDescription() {
return T::ELI_getDescription(); }
526 const std::vector<ElementInfoParam>& getValidParams() {
return ELI_templatedGetParams<T>(); }
527 const std::vector<ElementInfoStatistic>& getValidStats() {
return ELI_templatedGetStatistics<T>(); }
528 const std::vector<ElementInfoPort2>& getValidPorts() {
return ELI_templatedGetPorts<T>(); }
529 const std::vector<ElementInfoSubComponentSlot>& getSubComponentSlots() {
return ELI_templatedGetSubComponentSlots<T>(); }
530 uint32_t getCategory() {
return T::ELI_getCategory(); };
531 const std::vector<int>& getELICompiledVersion() {
return T::ELI_getELICompiledVersion(); }
532 const std::vector<int>& getVersion() {
static std::vector<int> var = {V1,V2,V3};
return var; }
533 const std::string getCompileFile() {
return T::ELI_getCompileFile(); }
534 const std::string getCompileDate() {
return T::ELI_getCompileDate(); }
547 template <
class T,
unsigned V1,
unsigned V2,
unsigned V3>
550 static const bool loaded;
555 initialize_allowedKeys();
556 initialize_portnames();
557 initialize_statnames();
562 return ELI_templatedCreateforSubComponent<T>(comp,params);
565 static bool isLoaded() {
return loaded; }
566 const std::string getLibrary() {
return T::ELI_getLibrary(); }
567 const std::string getName() {
return T::ELI_getName(); }
568 const std::string getDescription() {
return T::ELI_getDescription(); }
569 const std::vector<ElementInfoParam>& getValidParams() {
return ELI_templatedGetParams<T>(); }
570 const std::vector<ElementInfoStatistic>& getValidStats() {
return ELI_templatedGetStatistics<T>(); }
571 const std::vector<ElementInfoPort2>& getValidPorts() {
return ELI_templatedGetPorts<T>(); }
572 const std::vector<ElementInfoSubComponentSlot>& getSubComponentSlots() {
return ELI_templatedGetSubComponentSlots<T>(); }
573 const std::string getInterface() {
return T::ELI_getInterface(); }
574 const std::vector<int>& getELICompiledVersion() {
return T::ELI_getELICompiledVersion(); }
575 const std::vector<int>& getVersion() {
static std::vector<int> var = {V1,V2,V3};
return var; }
576 const std::string getCompileFile() {
return T::ELI_getCompileFile(); }
577 const std::string getCompileDate() {
return T::ELI_getCompileDate(); }
589 template <
class T,
unsigned V1,
unsigned V2,
unsigned V3>
592 static const bool loaded;
597 initialize_allowedKeys();
601 return new T(comp,params);
605 return new T(params);
608 static bool isLoaded() {
return loaded; }
609 const std::string getLibrary() {
return T::ELI_getLibrary(); }
610 const std::string getName() {
return T::ELI_getName(); }
611 const std::string getDescription() {
return T::ELI_getDescription(); }
612 const std::vector<ElementInfoParam>& getValidParams() {
return ELI_templatedGetParams<T>(); }
613 const std::string getInterface() {
return T::ELI_getInterface(); }
614 const std::vector<int>& getELICompiledVersion() {
return T::ELI_getELICompiledVersion(); }
615 const std::vector<int>& getVersion() {
static std::vector<int> var = {V1,V2,V3};
return var; }
616 const std::string getCompileFile() {
return T::ELI_getCompileFile(); }
617 const std::string getCompileDate() {
return T::ELI_getCompileDate(); }
620 template <
class T,
unsigned V1,
unsigned V2,
unsigned V3>
623 static const bool loaded;
628 initialize_allowedKeys();
632 return new T(comp,params);
635 static bool isLoaded() {
return loaded; }
636 const std::string getLibrary() {
return T::ELI_getLibrary(); }
637 const std::string getName() {
return T::ELI_getName(); }
638 const std::string getDescription() {
return T::ELI_getDescription(); }
639 const std::vector<ElementInfoParam>& getValidParams() {
return ELI_templatedGetParams<T>(); }
640 const std::string getInterface() {
return T::ELI_getInterface(); }
641 const std::vector<int>& getELICompiledVersion() {
return T::ELI_getELICompiledVersion(); }
642 const std::vector<int>& getVersion() {
static std::vector<int> var = {V1,V2,V3};
return var; }
643 const std::string getCompileFile() {
return T::ELI_getCompileFile(); }
644 const std::string getCompileDate() {
return T::ELI_getCompileDate(); }
647 template <
class T,
unsigned V1,
unsigned V2,
unsigned V3>
650 static const bool loaded;
655 initialize_allowedKeys();
659 return new T(params);
662 static bool isLoaded() {
return loaded; }
663 const std::string getLibrary() {
return T::ELI_getLibrary(); }
664 const std::string getName() {
return T::ELI_getName(); }
665 const std::string getDescription() {
return T::ELI_getDescription(); }
666 const std::vector<ElementInfoParam>& getValidParams() {
return ELI_templatedGetParams<T>(); }
667 const std::string getInterface() {
return T::ELI_getInterface(); }
668 const std::vector<int>& getELICompiledVersion() {
return T::ELI_getELICompiledVersion(); }
669 const std::vector<int>& getVersion() {
static std::vector<int> var = {V1,V2,V3};
return var; }
670 const std::string getCompileFile() {
return T::ELI_getCompileFile(); }
671 const std::string getCompileDate() {
return T::ELI_getCompileDate(); }
677 template<
class T,
unsigned V1,
unsigned V2,
unsigned V3>
678 typename std::enable_if<std::is_constructible<T,Component*,Params&>::value &&
684 template<
class T,
unsigned V1,
unsigned V2,
unsigned V3>
685 typename std::enable_if<std::is_constructible<T,Component*,Params&>::value &&
686 not std::is_constructible<T,Params&>::value, ModuleElementInfo*>::type
688 return new ModuleDocWithComponent<T,V1,V2,V3>();
691 template<
class T,
unsigned V1,
unsigned V2,
unsigned V3>
692 typename std::enable_if<not std::is_constructible<T,Component*,Params&>::value &&
693 std::is_constructible<T,Params&>::value, ModuleElementInfo*>::type
695 return new ModuleDocWithoutComponent<T,V1,V2,V3>();
698 template<
class T,
unsigned V1,
unsigned V2,
unsigned V3>
const bool ModuleDoc<T,V1,V2,V3>::loaded = ElementLibraryDatabase::addModule(createModuleDoc<T,V1,V2,V3>());
706 template <
class T,
unsigned V1,
unsigned V2,
unsigned V3>
709 static const bool loaded;
714 return new T(total_ranks,my_rank,verbosity);
717 static bool isLoaded() {
return loaded; }
718 const std::string getDescription()
override {
return T::ELI_getDescription(); }
719 const std::string getName()
override {
return T::ELI_getName(); }
720 const std::string getLibrary()
override {
return T::ELI_getLibrary(); }
721 const std::vector<int>& getELICompiledVersion()
override {
return T::ELI_getELICompiledVersion(); }
722 const std::vector<int>& getVersion()
override {
static std::vector<int> var = {V1,V2,V3};
return var; }
723 const std::string getCompileFile()
override {
return T::ELI_getCompileFile(); }
724 const std::string getCompileDate()
override {
return T::ELI_getCompileDate(); }
733 template <
class T,
unsigned V1,
unsigned V2,
unsigned V3>
736 static const bool loaded;
744 if( instance == NULL ) instance =
new T(getLibrary());
748 static bool isLoaded() {
return loaded; }
749 const std::string getLibrary() {
return T::ELI_getLibrary(); }
750 const std::vector<int>& getELICompiledVersion() {
return T::ELI_getELICompiledVersion(); }
751 const std::vector<int>& getVersion() {
static std::vector<int> var = {V1,V2,V3};
return var; }
752 const std::string getCompileFile() {
return T::ELI_getCompileFile(); }
753 const std::string getCompileDate() {
return T::ELI_getCompileDate(); }
766 const unsigned major;
767 const unsigned minor;
768 const unsigned tertiary;
770 constexpr
unsigned getMajor() {
return major; }
771 constexpr
unsigned getMinor() {
return minor; }
772 constexpr
unsigned getTertiary() {
return tertiary; }
776 return ver.getMajor();
779 constexpr
unsigned SST_ELI_getMinorNumberFromVersion(SST_ELI_element_version_extraction ver) {
780 return ver.getMinor();
783 constexpr
unsigned SST_ELI_getTertiaryNumberFromVersion(SST_ELI_element_version_extraction ver) {
784 return ver.getTertiary();
792 #define SST_ELI_INSERT_COMPILE_INFO() \
793 static const std::string& ELI_getCompileDate() { \
794 static std::string time = __TIME__; \
795 static std::string date = __DATE__; \
796 static std::string date_time = date + " " + time; \
799 static const std::string ELI_getCompileFile() { \
802 static const std::vector<int>& ELI_getELICompiledVersion() { \
803 static const std::vector<int> var(SST::SST_ELI_VERSION); \
808 #define SST_ELI_REGISTER_COMPONENT(cls,lib,name,version,desc,cat) \
809 bool ELI_isLoaded() { \
810 return SST::ComponentDoc<cls,SST::SST_ELI_getMajorNumberFromVersion(version),SST::SST_ELI_getMinorNumberFromVersion(version),SST::SST_ELI_getTertiaryNumberFromVersion(version)>::isLoaded(); \
812 static const std::string ELI_getLibrary() { \
815 static const std::string ELI_getName() { \
818 static const std::string ELI_getDescription() { \
821 static const uint32_t ELI_getCategory() { \
824 SST_ELI_INSERT_COMPILE_INFO()
826 #define SST_ELI_ELEMENT_VERSION(...) {__VA_ARGS__}
829 #define SST_ELI_DOCUMENT_PARAMS(...) \
830 static const std::vector<SST::ElementInfoParam>& ELI_getParams() { \
831 static std::vector<SST::ElementInfoParam> var = { __VA_ARGS__ } ; \
836 #define SST_ELI_DOCUMENT_STATISTICS(...) \
837 static const std::vector<SST::ElementInfoStatistic>& ELI_getStatistics() { \
838 static std::vector<SST::ElementInfoStatistic> var = { __VA_ARGS__ } ; \
843 #define SST_ELI_DOCUMENT_PORTS(...) \
844 static const std::vector<SST::ElementInfoPort2>& ELI_getPorts() { \
845 static std::vector<SST::ElementInfoPort2> var = { __VA_ARGS__ } ; \
849 #define SST_ELI_DOCUMENT_SUBCOMPONENT_SLOTS(...) \
850 static const std::vector<SST::ElementInfoSubComponentSlot>& ELI_getSubComponentSlots() { \
851 static std::vector<SST::ElementInfoSubComponentSlot> var = { __VA_ARGS__ } ; \
856 #define SST_ELI_REGISTER_SUBCOMPONENT(cls,lib,name,version,desc,interface) \
857 bool ELI_isLoaded() { \
858 return SST::SubComponentDoc<cls,SST::SST_ELI_getMajorNumberFromVersion(version),SST::SST_ELI_getMinorNumberFromVersion(version),SST::SST_ELI_getTertiaryNumberFromVersion(version)>::isLoaded(); \
860 static const std::string ELI_getLibrary() { \
863 static const std::string ELI_getName() { \
866 static const std::string ELI_getDescription() { \
869 static const std::string ELI_getInterface() { \
872 static const std::vector<int>& ELI_getVersion() { \
873 static std::vector<int> var = version ; \
876 SST_ELI_INSERT_COMPILE_INFO()
880 #define SST_ELI_REGISTER_MODULE(cls,lib,name,version,desc,interface) \
881 bool ELI_isLoaded() { \
882 return SST::ModuleDoc<cls,SST::SST_ELI_getMajorNumberFromVersion(version),SST::SST_ELI_getMinorNumberFromVersion(version),SST::SST_ELI_getTertiaryNumberFromVersion(version)>::isLoaded(); \
884 static const std::string ELI_getLibrary() { \
887 static const std::string ELI_getName() { \
890 static const std::string ELI_getDescription() { \
893 static const std::string ELI_getInterface() { \
896 static const std::vector<int>& ELI_getVersion() { \
897 static std::vector<int> var = version ; \
900 SST_ELI_INSERT_COMPILE_INFO()
904 #define SST_ELI_REGISTER_PARTITIONER(cls,lib,name,version,desc) \
905 bool ELI_isLoaded() { \
906 return SST::PartitionerDoc<cls,SST::SST_ELI_getMajorNumberFromVersion(version),SST::SST_ELI_getMinorNumberFromVersion(version),SST::SST_ELI_getTertiaryNumberFromVersion(version)>::isLoaded(); \
908 static const std::string ELI_getLibrary() { \
911 static const std::string ELI_getName() { \
914 static const std::string ELI_getDescription() { \
917 static const std::vector<int>& ELI_getVersion() { \
918 static std::vector<int> var = version ; \
921 SST_ELI_INSERT_COMPILE_INFO()
924 #define SST_ELI_REGISTER_PYTHON_MODULE(cls,lib,version) \
925 bool ELI_isLoaded() { \
926 return SST::PythonModuleDoc<cls,SST::SST_ELI_getMajorNumberFromVersion(version),SST::SST_ELI_getMinorNumberFromVersion(version),SST::SST_ELI_getTertiaryNumberFromVersion(version)>::isLoaded(); \
928 static const std::string ELI_getLibrary() { \
931 static const std::vector<int>& ELI_getVersion() { \
932 static std::vector<int> var = version ; \
935 SST_ELI_INSERT_COMPILE_INFO()
940 #endif // SST_CORE_ELEMENTINFO_H
Definition: elementinfo.h:148
Definition: elementinfo.h:366
Definition: elementinfo.h:195
Definition: elementinfo.h:298
Definition: elementinfo.h:40
Main component object for the simulation.
Definition: component.h:32
Definition: elementinfo.h:120
Definition: elementinfo.h:621
Definition: elementinfo.h:707
Definition: elementinfo.h:97
Module is a tag class used with the loadModule function.
Definition: module.h:20
Definition: elementinfo.h:505
Definition: elementinfo.h:140
Definition: elementinfo.h:400
Definition: elementinfo.h:133
Definition: elementinfo.h:332
Definition: elementinfo.h:548
Definition: rankInfo.h:21
Definition: elementinfo.h:109
Definition: elementinfo.h:263
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:734
Definition: elementinfo.h:590
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:648
SubComponent is a class loadable through the factory which allows dynamic functionality to be added t...
Definition: subcomponent.h:29
Definition: elementinfo.h:432