12 #ifndef SST_CORE_ELI_ELEMENTINFO_H 13 #define SST_CORE_ELI_ELEMENTINFO_H 15 #include "sst/core/eli/attributeInfo.h" 16 #include "sst/core/eli/categoryInfo.h" 17 #include "sst/core/eli/defaultInfo.h" 18 #include "sst/core/eli/elementbuilder.h" 19 #include "sst/core/eli/elibase.h" 20 #include "sst/core/eli/interfaceInfo.h" 21 #include "sst/core/eli/paramsInfo.h" 22 #include "sst/core/eli/portsInfo.h" 23 #include "sst/core/eli/profilePointInfo.h" 24 #include "sst/core/eli/simpleInfo.h" 25 #include "sst/core/eli/statsInfo.h" 26 #include "sst/core/eli/subcompSlotInfo.h" 27 #include "sst/core/params.h" 28 #include "sst/core/sst_types.h" 29 #include "sst/core/warnmacros.h" 43 namespace Statistics {
61 static T*
get(
const std::string& elemlib,
const std::string& elem)
63 if ( !infos_ )
return nullptr;
65 auto libiter = infos_->find(elemlib);
66 if ( libiter != infos_->end() ) {
67 auto& submap = libiter->second;
68 auto elemiter = submap.find(elem);
69 if ( elemiter != submap.end() ) {
return elemiter->second; }
74 static void add(
const std::string& elemlib,
const std::string& elem, T* info)
77 infos_ = std::unique_ptr<std::map<std::string, std::map<std::string, T*>>>(
78 new std::map<std::string, std::map<std::string, T*>>);
81 (*infos_)[elemlib][elem] = info;
85 static std::unique_ptr<std::map<std::string, std::map<std::string, T*>>> infos_;
90 template <
class Policy,
class... Policies>
96 template <
class... Args>
97 BuilderInfoImpl(
const std::string& elemlib,
const std::string& elem, Args&&... args) :
99 Parent(elemlib, elem, args...)
104 template <
class XMLNode>
105 void outputXML(XMLNode* node)
107 Policy::outputXML(node);
108 Parent::outputXML(node);
111 void toString(std::ostream& os)
const 113 Policy::toString(os);
114 Parent::toString(os);
122 template <
class... Args>
126 template <
class XMLNode>
127 void outputXML(XMLNode* UNUSED(node))
130 void toString(std::ostream& UNUSED(os))
const {}
133 template <
class Base,
class T>
136 static bool isLoaded() {
return loaded; }
138 static const bool loaded;
141 template <
class Base>
145 using BaseInfo =
typename Base::BuilderInfo;
147 InfoLibrary(
const std::string& name) : name_(name) {}
149 BaseInfo* getInfo(
const std::string& name)
151 auto iter = infos_.find(name);
152 if ( iter == infos_.end() ) {
return nullptr; }
158 bool hasInfo(
const std::string& name)
const {
return infos_.find(name) != infos_.end(); }
160 int numEntries()
const {
return infos_.size(); }
162 const std::map<std::string, BaseInfo*>& getMap()
const {
return infos_; }
164 void readdInfo(
const std::string& name, BaseInfo* info) { infos_[name] = info; }
166 bool addInfo(
const std::string& elem, BaseInfo* info)
168 readdInfo(elem, info);
170 addLoader(name_, elem, info);
175 void addLoader(
const std::string& lib,
const std::string& name, BaseInfo* info);
177 std::map<std::string, BaseInfo*> infos_;
182 template <
class Base>
187 using BaseInfo =
typename Library::BaseInfo;
188 using Map = std::map<std::string, Library*>;
190 static std::vector<std::string> getRegisteredElementNames()
195 std::vector<std::string> ret;
197 for (
auto x : (*libraries) ) {
198 for (
auto& y : x.second->getMap() ) {
199 ret.push_back(x.first +
"." + y.first);
205 static Library* getLibrary(
const std::string& name)
207 if ( !libraries ) { libraries =
new Map; }
208 auto iter = libraries->find(name);
209 if ( iter == libraries->end() ) {
210 auto* info =
new Library(name);
211 (*libraries)[name] = info;
221 static Map* libraries;
224 template <
class Base>
227 template <
class Base,
class Info>
230 InfoLoader(
const std::string& elemlib,
const std::string& elem, Info* info) :
239 if ( !lib->hasInfo(elem_) ) { lib->readdInfo(elem_, info_); }
243 std::string elemlib_;
248 template <
class Base>
256 template <
class Base>
267 return Base::template addDerivedInfo<T>(T::ELI_getLibrary(), T::ELI_getName());
270 template <
class Base,
class T>
282 static std::vector<std::string> getRegisteredElementNames()
288 void force_instantiate_bool(
bool b,
const char* name);
293 static bool ELI_isLoaded() {
return T::ELI_isLoaded(); }
304 const unsigned major;
305 const unsigned minor;
306 const unsigned tertiary;
308 constexpr
unsigned getMajor()
const {
return major; }
309 constexpr
unsigned getMinor()
const {
return minor; }
310 constexpr
unsigned getTertiary()
const {
return tertiary; }
316 return ver.getMajor();
320 SST_ELI_getMinorNumberFromVersion(SST_ELI_element_version_extraction ver)
322 return ver.getMinor();
326 SST_ELI_getTertiaryNumberFromVersion(SST_ELI_element_version_extraction ver)
328 return ver.getTertiary();
335 #define SST_ELI_DECLARE_INFO(...) \ 336 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<__VA_ARGS__, SST::ELI::ProvidesDefaultInfo, void>; \ 337 template <class BuilderImpl> \ 338 static bool addInfo(const std::string& elemlib, const std::string& elem, BuilderImpl* info) \ 340 return ::SST::ELI::InfoDatabase::getLibrary<__LocalEliBase>(elemlib)->addInfo(elem, info); \ 342 SST_ELI_DECLARE_INFO_COMMON() 344 #define SST_ELI_DECLARE_DEFAULT_INFO() \ 345 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<SST::ELI::ProvidesDefaultInfo, void>; \ 346 template <class BuilderImpl> \ 347 static bool addInfo(const std::string& elemlib, const std::string& elem, BuilderImpl* info) \ 349 return ::SST::ELI::InfoDatabase::getLibrary<__LocalEliBase>(elemlib)->addInfo(elem, info); \ 351 SST_ELI_DECLARE_INFO_COMMON() 353 #define SST_ELI_DECLARE_INFO_EXTERN(...) \ 354 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<SST::ELI::ProvidesDefaultInfo, __VA_ARGS__, void>; \ 355 static bool addInfo(const std::string& elemlib, const std::string& elem, BuilderInfo* info); \ 356 SST_ELI_DECLARE_INFO_COMMON() 358 #define SST_ELI_DECLARE_DEFAULT_INFO_EXTERN() \ 359 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<SST::ELI::ProvidesDefaultInfo, void>; \ 360 static bool addInfo(const std::string& elemlib, const std::string& elem, BuilderInfo* info); \ 361 SST_ELI_DECLARE_INFO_COMMON() 363 #define SST_ELI_DEFINE_INFO_EXTERN(base) \ 364 bool base::addInfo(const std::string& elemlib, const std::string& elem, BuilderInfo* info) \ 366 return ::SST::ELI::InfoDatabase::getLibrary<__LocalEliBase>(elemlib)->addInfo(elem, info); \ 369 #define SST_ELI_EXTERN_DERIVED(base, cls, lib, name, version, desc) \ 370 bool ELI_isLoaded(); \ 371 SST_ELI_DEFAULT_INFO(lib, name, ELI_FORWARD_AS_ONE(version), desc) 378 #ifdef __INTEL_COMPILER 379 #define SST_ELI_FORCE_INSTANTIATION(base, cls) \ 381 struct ELI_ForceRegister \ 383 ELI_ForceRegister() \ 385 bool b = SST::ELI::InstantiateBuilder<base, cls>::isLoaded() && \ 386 SST::ELI::InstantiateBuilderInfo<base, cls>::isLoaded(); \ 387 SST::ELI::force_instantiate_bool(b, #cls); \ 390 ELI_ForceRegister<cls> force_instantiate; 395 #define SST_ELI_EXPORT(cls) template class SST::ELI::ForceExport<cls>; 397 #define SST_ELI_FORCE_INSTANTIATION(base, cls) 398 #define SST_ELI_EXPORT(cls) 409 #define SST_ELI_REGISTER_DERIVED(base, cls, lib, name, version, desc) \ 410 [[maybe_unused]] static constexpr int __EliDerivedLevel = \ 411 std::is_same<base, cls>::value ? __EliBaseLevel : __EliBaseLevel + 1; \ 412 static bool ELI_isLoaded() \ 414 return SST::ELI::InstantiateBuilder<base, cls>::isLoaded() && \ 415 SST::ELI::InstantiateBuilderInfo<base, cls>::isLoaded(); \ 417 SST_ELI_FORCE_INSTANTIATION(base, cls) \ 418 SST_ELI_DEFAULT_INFO(lib, name, ELI_FORWARD_AS_ONE(version), desc) 420 #define SST_ELI_REGISTER_EXTERN(base, cls) \ 421 bool cls::ELI_isLoaded() \ 423 return SST::ELI::InstantiateBuilder<base, cls>::isLoaded() && \ 424 SST::ELI::InstantiateBuilderInfo<base, cls>::isLoaded(); \ 429 #endif // SST_CORE_ELI_ELEMENTINFO_H Definition: elementinfo.h:228
Forms the base class for statistics gathering within SST.
Definition: statbase.h:45
Definition: elementinfo.h:134
Definition: elementinfo.h:273
Forms the template defined base class for statistics gathering within SST.
Definition: elementinfo.h:45
Definition: elementinfo.h:183
Definition: elementinfo.h:257
Definition: elementinfo.h:91
Definition: elementinfo.h:291
Definition: elibase.h:134
Definition: elementinfo.h:142
Definition: rankInfo.h:21
Definition: elementinfo.h:58
Base class for python modules in element libraries.
Definition: element_python.h:128
static bool addLoader(const std::string &lib, const std::string &name, LibraryLoader *loader)
Definition: elibase.cc:28