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"
19 #include "sst/core/eli/paramsInfo.h"
20 #include "sst/core/eli/statsInfo.h"
21 #include "sst/core/eli/defaultInfo.h"
22 #include "sst/core/eli/portsInfo.h"
23 #include "sst/core/eli/subcompSlotInfo.h"
24 #include "sst/core/eli/interfaceInfo.h"
25 #include "sst/core/eli/categoryInfo.h"
26 #include "sst/core/eli/elementbuilder.h"
31 #include "sst/core/eli/elibase.h"
41 namespace Statistics {
57 static T*
get(
const std::string& elemlib,
const std::string& elem){
58 if (!infos_)
return nullptr;
60 auto libiter = infos_->find(elemlib);
61 if (libiter != infos_->end()){
62 auto& submap = libiter->second;
63 auto elemiter = submap.find(elem);
64 if (elemiter != submap.end()){
65 return elemiter->second;
71 static void add(
const std::string& elemlib,
const std::string& elem, T* info){
73 infos_ = std::unique_ptr<std::map<std::string, std::map<std::string, T*>>>(
74 new std::map<std::string, std::map<std::string, T*>>);
77 (*infos_)[elemlib][elem] = info;
81 static std::unique_ptr<std::map<std::string, std::map<std::string, T*>>> infos_;
83 template <
class T> std::unique_ptr<std::map<std::string,std::map<std::string,T*>>>
DataBase<T>::infos_;
86 template <
class Policy,
class... Policies>
92 const std::string& elem,
94 : Policy(args...),
Parent(elemlib, elem, args...)
99 template <
class XMLNode>
void outputXML(XMLNode* node){
100 Policy::outputXML(node);
101 Parent::outputXML(node);
104 void toString(std::ostream& os)
const {
105 Parent::toString(os);
106 Policy::toString(os);
116 template <
class XMLNode>
void outputXML(XMLNode* UNUSED(node)){}
118 void toString(std::ostream& UNUSED(os))
const {}
122 template <
class Base,
class T>
124 static bool isLoaded() {
128 static const bool loaded;
134 using BaseInfo =
typename Base::BuilderInfo;
141 BaseInfo* getInfo(
const std::string& name) {
142 auto iter = infos_.find(name);
143 if (iter == infos_.end()){
150 bool hasInfo(
const std::string& name)
const {
151 return infos_.find(name) != infos_.end();
154 int numEntries()
const {
155 return infos_.size();
158 const std::map<std::string, BaseInfo*>& getMap()
const {
162 void readdInfo(
const std::string& name, BaseInfo* info){
166 bool addInfo(
const std::string& elem, BaseInfo* info){
167 readdInfo(elem, info);
169 addLoader(name_, elem, info);
174 void addLoader(
const std::string& lib,
const std::string& name, BaseInfo* info);
176 std::map<std::string, BaseInfo*> infos_;
181 template <
class Base>
185 using BaseInfo=
typename Library::BaseInfo;
186 using Map=std::map<std::string,Library*>;
188 static Library* getLibrary(
const std::string& name){
192 auto iter = libraries->find(name);
193 if (iter == libraries->end()){
194 auto* info =
new Library(name);
195 (*libraries)[name] = info;
204 static Map* libraries;
207 template <
class Base>
typename InfoLibraryDatabase<Base>::Map*
210 template <
class Base,
class Info>
213 const std::string& elem,
215 elemlib_(elemlib), elem_(elem), info_(info)
219 void load()
override {
221 if (!lib->hasInfo(elem_)){
222 lib->readdInfo(elem_, info_);
226 std::string elemlib_;
244 template <
class T>
static bool add(){
245 return Base::template addDerivedInfo<T>(T::ELI_getLibrary(), T::ELI_getName());
259 void force_instantiate_bool(
bool b,
const char* name);
262 static bool ELI_isLoaded() {
263 return T::ELI_isLoaded();
275 const unsigned major;
276 const unsigned minor;
277 const unsigned tertiary;
279 constexpr
unsigned getMajor()
const {
return major; }
280 constexpr
unsigned getMinor()
const {
return minor; }
281 constexpr
unsigned getTertiary()
const {
return tertiary; }
285 return ver.getMajor();
288 constexpr
unsigned SST_ELI_getMinorNumberFromVersion(SST_ELI_element_version_extraction ver) {
289 return ver.getMinor();
292 constexpr
unsigned SST_ELI_getTertiaryNumberFromVersion(SST_ELI_element_version_extraction ver) {
293 return ver.getTertiary();
301 #define SST_ELI_DECLARE_INFO(...) \
302 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<__VA_ARGS__,SST::ELI::ProvidesDefaultInfo,void>; \
303 template <class BuilderImpl> static bool addInfo(const std::string& elemlib, const std::string& elem, \
304 BuilderImpl* info){ \
305 return ::SST::ELI::InfoDatabase::getLibrary<__LocalEliBase>(elemlib)->addInfo(elem,info); \
307 SST_ELI_DECLARE_INFO_COMMON()
310 #define SST_ELI_DECLARE_DEFAULT_INFO() \
311 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<SST::ELI::ProvidesDefaultInfo,void>; \
312 template <class BuilderImpl> static bool addInfo(const std::string& elemlib, const std::string& elem, \
313 BuilderImpl* info){ \
314 return ::SST::ELI::InfoDatabase::getLibrary<__LocalEliBase>(elemlib)->addInfo(elem,info); \
316 SST_ELI_DECLARE_INFO_COMMON()
319 #define SST_ELI_DECLARE_INFO_EXTERN(...) \
320 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<SST::ELI::ProvidesDefaultInfo,__VA_ARGS__,void>; \
321 static bool addInfo(const std::string& elemlib, const std::string& elem, BuilderInfo* info); \
322 SST_ELI_DECLARE_INFO_COMMON()
324 #define SST_ELI_DECLARE_DEFAULT_INFO_EXTERN() \
325 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<SST::ELI::ProvidesDefaultInfo,void>; \
326 static bool addInfo(const std::string& elemlib, const std::string& elem, BuilderInfo* info); \
327 SST_ELI_DECLARE_INFO_COMMON()
329 #define SST_ELI_DEFINE_INFO_EXTERN(base) \
330 bool base::addInfo(const std::string& elemlib, const std::string& elem, BuilderInfo* info){ \
331 return ::SST::ELI::InfoDatabase::getLibrary<__LocalEliBase>(elemlib)->addInfo(elem,info); \
334 #define SST_ELI_EXTERN_DERIVED(base,cls,lib,name,version,desc) \
335 bool ELI_isLoaded(); \
336 SST_ELI_DEFAULT_INFO(lib,name,ELI_FORWARD_AS_ONE(version),desc)
343 #ifdef __INTEL_COMPILER
344 #define SST_ELI_FORCE_INSTANTIATION(base,cls) \
346 struct ELI_ForceRegister { \
347 ELI_ForceRegister(){ \
348 bool b = SST::ELI::InstantiateBuilder<base,cls>::isLoaded() \
349 && SST::ELI::InstantiateBuilderInfo<base,cls>::isLoaded(); \
350 SST::ELI::force_instantiate_bool(b, #cls); \
353 ELI_ForceRegister<cls> force_instantiate;
358 #define SST_ELI_EXPORT(cls) \
359 template class SST::ELI::ForceExport<cls>;
361 #define SST_ELI_FORCE_INSTANTIATION(base,cls)
362 #define SST_ELI_EXPORT(cls)
366 #define SST_ELI_REGISTER_DERIVED(base,cls,lib,name,version,desc) \
367 static bool ELI_isLoaded() { \
368 return SST::ELI::InstantiateBuilder<base,cls>::isLoaded() \
369 && SST::ELI::InstantiateBuilderInfo<base,cls>::isLoaded(); \
371 SST_ELI_FORCE_INSTANTIATION(base,cls) \
372 SST_ELI_DEFAULT_INFO(lib,name,ELI_FORWARD_AS_ONE(version),desc)
374 #define SST_ELI_REGISTER_EXTERN(base,cls) \
375 bool cls::ELI_isLoaded(){ \
376 return SST::ELI::InstantiateBuilder<base,cls>::isLoaded() \
377 && SST::ELI::InstantiateBuilderInfo<base,cls>::isLoaded(); \
383 #endif // SST_CORE_ELEMENTINFO_H
Definition: elementinfo.h:211
Forms the base class for statistics gathering within SST.
Definition: statbase.h:64
Definition: elementinfo.h:123
Definition: elementinfo.h:252
Forms the template defined base class for statistics gathering within SST.
Definition: elementinfo.h:42
Definition: elementinfo.h:182
Definition: elementinfo.h:238
Definition: elementinfo.h:87
Definition: elementinfo.h:261
Definition: elibase.h:107
Definition: elementinfo.h:131
Definition: rankInfo.h:21
Definition: elementinfo.h:55
Base class for python modules in element libraries.
Definition: element_python.h:133
static bool addLoader(const std::string &lib, const std::string &name, LibraryLoader *loader)
Definition: elibase.cc:29