12 #ifndef SST_CORE_ELI_ELEMENTINFO_H
13 #define SST_CORE_ELI_ELEMENTINFO_H
15 #include "sst/core/eli/categoryInfo.h"
16 #include "sst/core/eli/defaultInfo.h"
17 #include "sst/core/eli/elementbuilder.h"
18 #include "sst/core/eli/elibase.h"
19 #include "sst/core/eli/interfaceInfo.h"
20 #include "sst/core/eli/paramsInfo.h"
21 #include "sst/core/eli/portsInfo.h"
22 #include "sst/core/eli/simpleInfo.h"
23 #include "sst/core/eli/statsInfo.h"
24 #include "sst/core/eli/subcompSlotInfo.h"
25 #include "sst/core/params.h"
26 #include "sst/core/sst_types.h"
27 #include "sst/core/warnmacros.h"
40 namespace Statistics {
58 static T*
get(
const std::string& elemlib,
const std::string& elem)
60 if ( !infos_ )
return nullptr;
62 auto libiter = infos_->find(elemlib);
63 if ( libiter != infos_->end() ) {
64 auto& submap = libiter->second;
65 auto elemiter = submap.find(elem);
66 if ( elemiter != submap.end() ) {
return elemiter->second; }
71 static void add(
const std::string& elemlib,
const std::string& elem, T* info)
74 infos_ = std::unique_ptr<std::map<std::string, std::map<std::string, T*>>>(
75 new std::map<std::string, std::map<std::string, T*>>);
78 (*infos_)[elemlib][elem] = info;
82 static std::unique_ptr<std::map<std::string, std::map<std::string, T*>>> infos_;
87 template <
class Policy,
class... Policies>
93 template <
class... Args>
94 BuilderInfoImpl(
const std::string& elemlib,
const std::string& elem, Args&&... args) :
96 Parent(elemlib, elem, args...)
101 template <
class XMLNode>
102 void outputXML(XMLNode* node)
104 Policy::outputXML(node);
105 Parent::outputXML(node);
108 void toString(std::ostream& os)
const
110 Parent::toString(os);
111 Policy::toString(os);
119 template <
class... Args>
123 template <
class XMLNode>
124 void outputXML(XMLNode* UNUSED(node))
127 void toString(std::ostream& UNUSED(os))
const {}
130 template <
class Base,
class T>
133 static bool isLoaded() {
return loaded; }
135 static const bool loaded;
138 template <
class Base>
142 using BaseInfo =
typename Base::BuilderInfo;
144 InfoLibrary(
const std::string& name) : name_(name) {}
146 BaseInfo* getInfo(
const std::string& name)
148 auto iter = infos_.find(name);
149 if ( iter == infos_.end() ) {
return nullptr; }
155 bool hasInfo(
const std::string& name)
const {
return infos_.find(name) != infos_.end(); }
157 int numEntries()
const {
return infos_.size(); }
159 const std::map<std::string, BaseInfo*>& getMap()
const {
return infos_; }
161 void readdInfo(
const std::string& name, BaseInfo* info) { infos_[name] = info; }
163 bool addInfo(
const std::string& elem, BaseInfo* info)
165 readdInfo(elem, info);
167 addLoader(name_, elem, info);
172 void addLoader(
const std::string& lib,
const std::string& name, BaseInfo* info);
174 std::map<std::string, BaseInfo*> infos_;
179 template <
class Base>
184 using BaseInfo =
typename Library::BaseInfo;
185 using Map = std::map<std::string, Library*>;
187 static std::vector<std::string> getRegisteredElementNames()
192 std::vector<std::string> ret;
194 for (
auto x : (*libraries) ) {
195 for (
auto& y : x.second->getMap() ) {
196 ret.push_back(x.first +
"." + y.first);
202 static Library* getLibrary(
const std::string& name)
204 if ( !libraries ) { libraries =
new Map; }
205 auto iter = libraries->find(name);
206 if ( iter == libraries->end() ) {
207 auto* info =
new Library(name);
208 (*libraries)[name] = info;
218 static Map* libraries;
221 template <
class Base>
224 template <
class Base,
class Info>
227 InfoLoader(
const std::string& elemlib,
const std::string& elem, Info* info) :
236 if ( !lib->hasInfo(elem_) ) { lib->readdInfo(elem_, info_); }
240 std::string elemlib_;
245 template <
class Base>
253 template <
class Base>
264 return Base::template addDerivedInfo<T>(T::ELI_getLibrary(), T::ELI_getName());
267 template <
class Base,
class T>
279 static std::vector<std::string> getRegisteredElementNames()
285 void force_instantiate_bool(
bool b,
const char* name);
290 static bool ELI_isLoaded() {
return T::ELI_isLoaded(); }
301 const unsigned major;
302 const unsigned minor;
303 const unsigned tertiary;
305 constexpr
unsigned getMajor()
const {
return major; }
306 constexpr
unsigned getMinor()
const {
return minor; }
307 constexpr
unsigned getTertiary()
const {
return tertiary; }
313 return ver.getMajor();
317 SST_ELI_getMinorNumberFromVersion(SST_ELI_element_version_extraction ver)
319 return ver.getMinor();
323 SST_ELI_getTertiaryNumberFromVersion(SST_ELI_element_version_extraction ver)
325 return ver.getTertiary();
332 #define SST_ELI_DECLARE_INFO(...) \
333 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<__VA_ARGS__, SST::ELI::ProvidesDefaultInfo, void>; \
334 template <class BuilderImpl> \
335 static bool addInfo(const std::string& elemlib, const std::string& elem, BuilderImpl* info) \
337 return ::SST::ELI::InfoDatabase::getLibrary<__LocalEliBase>(elemlib)->addInfo(elem, info); \
339 SST_ELI_DECLARE_INFO_COMMON()
341 #define SST_ELI_DECLARE_DEFAULT_INFO() \
342 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<SST::ELI::ProvidesDefaultInfo, void>; \
343 template <class BuilderImpl> \
344 static bool addInfo(const std::string& elemlib, const std::string& elem, BuilderImpl* info) \
346 return ::SST::ELI::InfoDatabase::getLibrary<__LocalEliBase>(elemlib)->addInfo(elem, info); \
348 SST_ELI_DECLARE_INFO_COMMON()
350 #define SST_ELI_DECLARE_INFO_EXTERN(...) \
351 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<SST::ELI::ProvidesDefaultInfo, __VA_ARGS__, void>; \
352 static bool addInfo(const std::string& elemlib, const std::string& elem, BuilderInfo* info); \
353 SST_ELI_DECLARE_INFO_COMMON()
355 #define SST_ELI_DECLARE_DEFAULT_INFO_EXTERN() \
356 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<SST::ELI::ProvidesDefaultInfo, void>; \
357 static bool addInfo(const std::string& elemlib, const std::string& elem, BuilderInfo* info); \
358 SST_ELI_DECLARE_INFO_COMMON()
360 #define SST_ELI_DEFINE_INFO_EXTERN(base) \
361 bool base::addInfo(const std::string& elemlib, const std::string& elem, BuilderInfo* info) \
363 return ::SST::ELI::InfoDatabase::getLibrary<__LocalEliBase>(elemlib)->addInfo(elem, info); \
366 #define SST_ELI_EXTERN_DERIVED(base, cls, lib, name, version, desc) \
367 bool ELI_isLoaded(); \
368 SST_ELI_DEFAULT_INFO(lib, name, ELI_FORWARD_AS_ONE(version), desc)
375 #ifdef __INTEL_COMPILER
376 #define SST_ELI_FORCE_INSTANTIATION(base, cls) \
378 struct ELI_ForceRegister \
380 ELI_ForceRegister() \
382 bool b = SST::ELI::InstantiateBuilder<base, cls>::isLoaded() && \
383 SST::ELI::InstantiateBuilderInfo<base, cls>::isLoaded(); \
384 SST::ELI::force_instantiate_bool(b, #cls); \
387 ELI_ForceRegister<cls> force_instantiate;
392 #define SST_ELI_EXPORT(cls) template class SST::ELI::ForceExport<cls>;
394 #define SST_ELI_FORCE_INSTANTIATION(base, cls)
395 #define SST_ELI_EXPORT(cls)
406 #define SST_ELI_REGISTER_DERIVED(base, cls, lib, name, version, desc) \
407 static constexpr int __EliDerivedLevel = std::is_same<base, cls>::value ? __EliBaseLevel : __EliBaseLevel + 1; \
408 static bool ELI_isLoaded() \
410 return SST::ELI::InstantiateBuilder<base, cls>::isLoaded() && \
411 SST::ELI::InstantiateBuilderInfo<base, cls>::isLoaded(); \
413 SST_ELI_FORCE_INSTANTIATION(base, cls) \
414 SST_ELI_DEFAULT_INFO(lib, name, ELI_FORWARD_AS_ONE(version), desc)
416 #define SST_ELI_REGISTER_EXTERN(base, cls) \
417 bool cls::ELI_isLoaded() \
419 return SST::ELI::InstantiateBuilder<base, cls>::isLoaded() && \
420 SST::ELI::InstantiateBuilderInfo<base, cls>::isLoaded(); \
425 #endif // SST_CORE_ELI_ELEMENTINFO_H
Definition: elementinfo.h:225
Forms the base class for statistics gathering within SST.
Definition: statbase.h:63
Definition: elementinfo.h:131
Definition: elementinfo.h:270
Forms the template defined base class for statistics gathering within SST.
Definition: elementinfo.h:42
Definition: elementinfo.h:180
Definition: elementinfo.h:254
Definition: elementinfo.h:88
Definition: elementinfo.h:288
Definition: elibase.h:119
Definition: elementinfo.h:139
Definition: rankInfo.h:21
Definition: elementinfo.h:55
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