SST  7.2.0
StructuralSimulationToolkit
elementinfo.h
1 // Copyright 2009-2017 Sandia Corporation. Under the terms
2 // of Contract DE-NA0003525 with Sandia Corporation, the U.S.
3 // Government retains certain rights in this software.
4 //
5 // Copyright (c) 2009-2017, Sandia Corporation
6 // All rights reserved.
7 //
8 // This file is part of the SST software package. For license
9 // information, see the LICENSE file in the top level directory of the
10 // distribution.
11 
12 #ifndef SST_CORE_ELEMENTINFO_H
13 #define SST_CORE_ELEMENTINFO_H
14 
15 #include <sst/core/sst_types.h>
16 #include <sst/core/warnmacros.h>
17 #include <sst/core/params.h>
18 
19 #include <string>
20 #include <vector>
21 
22 #include <sst/core/elibase.h>
23 
24 namespace SST {
25 class Component;
26 class Module;
27 class SubComponent;
28 namespace Partition {
29  class SSTPartitioner;
30 }
31 class RankInfo;
32 class SSTElementPythonModule;
33 
34 /****************************************************
35  Base classes for templated documentation classes
36 *****************************************************/
37 
38 const std::vector<int> SST_ELI_VERSION = {0, 9, 0};
39 
41 
42 public:
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;
49 
50  virtual const std::vector<int>& getELICompiledVersion() = 0;
51 
52  std::string getELIVersionString();
53 };
54 
56 
57 protected:
58  Params::KeySet_t allowedKeys;
59 
60  void initialize_allowedKeys();
61 
62 public:
63 
64  virtual const std::vector<ElementInfoParam>& getValidParams() = 0;
65 
66  const Params::KeySet_t& getParamNames() { return allowedKeys; }
67 
68  std::string getParametersString();
69 
70 };
71 
73 
74 protected:
75  std::vector<std::string> portnames;
76  std::vector<std::string> statnames;
77 
78  void initialize_portnames();
79  void initialize_statnames();
80 
81 public:
82 
83  virtual const std::vector<ElementInfoPort2>& getValidPorts() = 0;
84  virtual const std::vector<ElementInfoStatistic>& getValidStats() = 0;
85  virtual const std::vector<ElementInfoSubComponentSlot>& getSubComponentSlots() = 0;
86 
87  const std::vector<std::string>& getPortnames() { return portnames; }
88  const std::vector<std::string>& getStatnames() { return statnames; }
89 
90  std::string getStatisticsString();
91  std::string getPortsString();
92  std::string getSubComponentSlotString();
93 
94 };
95 
96 
98 
99 public:
100 
102 
103  virtual Component* create(ComponentId_t id, Params& params) = 0;
104  virtual uint32_t getCategory() = 0;
105 
106  std::string toString();
107 };
108 
110 
111 public:
112 
113  virtual SubComponent* create(Component* comp, Params& params) = 0;
114  virtual const std::string getInterface() = 0;
115 
116  std::string toString();
117 };
118 
119 
121 
122 protected:
123 
124 public:
125  virtual Module* create(Component* UNUSED(comp), Params& UNUSED(params)) { /* Need to print error */ return NULL; }
126  virtual Module* create(Params& UNUSED(params)) { /* Need to print error */ return NULL; }
127  virtual const std::string getInterface() = 0;
128 
129  std::string toString();
130 };
131 
132 
134 public:
135  virtual Partition::SSTPartitioner* create(RankInfo total_ranks, RankInfo my_rank, int verbosity) = 0;
136 
137  std::string toString();
138 };
139 
141 public:
142  virtual SSTElementPythonModule* create() = 0;
143  const std::string getDescription() { return getLibrary() + " python module"; };
144  const std::string getName() { return getLibrary(); }
145 };
146 
147 
148 class LibraryInfo {
149 public:
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;
154  PythonModuleElementInfo* python_module;
155 
156  LibraryInfo() :
157  python_module(NULL) {}
158 
159 
160  BaseComponentElementInfo* getComponentOrSubComponent(const std::string &name) {
161  BaseComponentElementInfo *bcei = getComponent(name);
162  if ( !bcei )
163  bcei = getSubComponent(name);
164  return bcei;
165  }
166 
167  ComponentElementInfo* getComponent(const std::string &name) {
168  if ( components.count(name) == 0 ) return NULL;
169  return components[name];
170  }
171 
172  SubComponentElementInfo* getSubComponent(const std::string &name) {
173  if ( subcomponents.count(name) == 0 ) return NULL;
174  return subcomponents[name];
175  }
176 
177  ModuleElementInfo* getModule(const std::string &name) {
178  if ( modules.count(name) == 0 ) return NULL;
179  return modules[name];
180  }
181 
182  PartitionerElementInfo* getPartitioner(const std::string &name) {
183  if ( partitioners.count(name) == 0 ) return NULL;
184  return partitioners[name];
185  }
186 
187  PythonModuleElementInfo* getPythonModule() {
188  return python_module;
189  }
190 
191  std::string toString();
192 };
193 
194 
196 private:
197  // Database
198  static std::map<std::string,LibraryInfo*> libraries;
199 
200  static LibraryInfo* getLibrary(const std::string &library) {
201  if ( libraries.count(library) == 0 ) {
202  libraries[library] = new LibraryInfo;
203  }
204  return libraries[library];
205  }
206 
207 public:
208  static bool addComponent(ComponentElementInfo* comp) {
209  LibraryInfo* library = getLibrary(comp->getLibrary());
210  library->components[comp->getName()] = comp;
211  return true;
212  }
213 
214  static bool addSubComponent(SubComponentElementInfo* comp) {
215  LibraryInfo* library = getLibrary(comp->getLibrary());
216  library->subcomponents[comp->getName()] = comp;
217  return true;
218  }
219 
220  static bool addModule(ModuleElementInfo* comp) {
221  LibraryInfo* library = getLibrary(comp->getLibrary());
222  library->modules[comp->getName()] = comp;
223  return true;
224  }
225 
226  static bool addPartitioner(PartitionerElementInfo* part) {
227  LibraryInfo* library = getLibrary(part->getLibrary());
228  library->partitioners[part->getName()] = part;
229  return true;
230  }
231 
232  static bool addPythonModule(PythonModuleElementInfo* pymod) {
233  LibraryInfo* library = getLibrary(pymod->getLibrary());
234  if ( library->python_module == NULL ) {
235  library->python_module = pymod;
236  }
237  else {
238  // need to fatal
239  }
240  return true;
241  }
242 
243  static std::string toString();
244 
245  static LibraryInfo* getLibraryInfo(const std::string &library) {
246  if ( libraries.count(library) == 0 ) return NULL;
247  return libraries[library];
248  }
249 };
250 
251 
252 
253 /**************************************************************************
254  Templated classes that are used to actually implement the element info
255  documenation in the database.
256 **************************************************************************/
257 
258 
259 /**************************************************************************
260  Class to check for an ELI_getParams Function
261 **************************************************************************/
262 template <class T>
264 {
265  template <typename F, F> struct check;
266 
267  typedef char Match;
268  typedef long NotMatch;
269 
270  typedef const std::vector<ElementInfoParam>& (*functionsig)();
271 
272  template <typename F> static Match HasFunction(check<functionsig, &F::ELI_getParams >*);
273  template <typename F> static NotMatch HasFunction(...);
274 
275 public:
276  static bool const value = (sizeof(HasFunction<T>(0)) == sizeof(Match) );
277 };
278 
279 
280 template<class T>
281 typename std::enable_if<checkForELI_getParamsFunction<T>::value, const std::vector<ElementInfoParam>& >::type
282 ELI_templatedGetParams() {
283  return T::ELI_getParams();
284 }
285 
286 template<class T>
287 typename std::enable_if<not checkForELI_getParamsFunction<T>::value, std::vector<ElementInfoParam>& >::type
288 ELI_templatedGetParams() {
289  static std::vector<ElementInfoParam> var;
290  return var;
291 }
292 
293 
294 /**************************************************************************
295  Class to check for an ELI_getStatistics Function
296 **************************************************************************/
297 template <class T>
299 {
300  template <typename F, F> struct check;
301 
302  typedef char Match;
303  typedef long NotMatch;
304 
305  typedef const std::vector<ElementInfoStatistic>& (*functionsig)();
306 
307  template <typename F> static Match HasFunction(check<functionsig, &F::ELI_getStatistics>*);
308  template <typename F> static NotMatch HasFunction(...);
309 
310 public:
311  static bool const value = (sizeof(HasFunction<T>(0)) == sizeof(Match) );
312 };
313 
314 template<class T>
315 typename std::enable_if<checkForELI_getStatisticsFunction<T>::value, const std::vector<ElementInfoStatistic>& >::type
316 ELI_templatedGetStatistics() {
317  return T::ELI_getStatistics();
318 }
319 
320 template<class T>
321 typename std::enable_if<not checkForELI_getStatisticsFunction<T>::value, const std::vector<ElementInfoStatistic>& >::type
322 ELI_templatedGetStatistics() {
323  static std::vector<ElementInfoStatistic> var;
324  return var;
325 }
326 
327 
328 /**************************************************************************
329  Class to check for an ELI_getPorts Function
330 **************************************************************************/
331 template <class T>
333 {
334  template <typename F, F> struct check;
335 
336  typedef char Match;
337  typedef long NotMatch;
338 
339  typedef const std::vector<ElementInfoPort2>& (*functionsig)();
340 
341  template <typename F> static Match HasFunction(check<functionsig, &F::ELI_getPorts>*);
342  template <typename F> static NotMatch HasFunction(...);
343 
344 public:
345  static bool const value = (sizeof(HasFunction<T>(0)) == sizeof(Match) );
346 };
347 
348 template<class T>
349 typename std::enable_if<checkForELI_getPortsFunction<T>::value, const std::vector<ElementInfoPort2>& >::type
350 ELI_templatedGetPorts() {
351  return T::ELI_getPorts();
352 }
353 
354 template<class T>
355 typename std::enable_if<not checkForELI_getPortsFunction<T>::value, const std::vector<ElementInfoPort2>& >::type
356 ELI_templatedGetPorts() {
357  static std::vector<ElementInfoPort2> var;
358  return var;
359 }
360 
361 
362 /**************************************************************************
363  Class to check for an ELI_getSubComponentSlots Function
364 **************************************************************************/
365 template <class T>
367 {
368  template <typename F, F> struct check;
369 
370  typedef char Match;
371  typedef long NotMatch;
372 
373  typedef const std::vector<ElementInfoSubComponentSlot>& (*functionsig)();
374 
375  template <typename F> static Match HasFunction(check<functionsig, &F::ELI_getSubComponentSlots>*);
376  template <typename F> static NotMatch HasFunction(...);
377 
378 public:
379  static bool const value = (sizeof(HasFunction<T>(0)) == sizeof(Match) );
380 };
381 
382 template<class T>
383 typename std::enable_if<checkForELI_getSubComponentSlotsFunction<T>::value, const std::vector<ElementInfoSubComponentSlot>& >::type
384 ELI_templatedGetSubComponentSlots() {
385  return T::ELI_getSubComponentSlots();
386 }
387 
388 template<class T>
389 typename std::enable_if<not checkForELI_getSubComponentSlotsFunction<T>::value, const std::vector<ElementInfoSubComponentSlot>& >::type
390 ELI_templatedGetSubComponentSlots() {
391  static std::vector<ElementInfoSubComponentSlot> var;
392  return var;
393 }
394 
395 
396 /**************************************************************************
397  Class to check for an ELI_CustomCreate Function for Components
398 **************************************************************************/
399 template <class T>
401 {
402  template <typename F, F> struct check;
403 
404  typedef char Match;
405  typedef long NotMatch;
406 
407  typedef Component* (*functionsig)(ComponentId_t, Params&);
408 
409  template <typename F> static Match HasFunction(check<functionsig, &F::ELI_CustomCreate>*);
410  template <typename F> static NotMatch HasFunction(...);
411 
412 public:
413  static bool const value = (sizeof(HasFunction<T>(0)) == sizeof(Match) );
414 };
415 
416 template<class T>
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);
420 }
421 
422 template<class T>
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);
426 }
427 
428 /**************************************************************************
429  Class to check for an ELI_CustomCreate Function for SubComponents
430 **************************************************************************/
431 template <class T>
433 {
434  template <typename F, F> struct check;
435 
436  typedef char Match;
437  typedef long NotMatch;
438 
439  struct FunctionSignature
440  {
441  typedef SubComponent* (*function)(Component*, Params&);
442  };
443 
444  template <typename F> static Match HasFunction(check< typename FunctionSignature::function, &F::ELI_CustomCreate>*);
445  template <typename F> static NotMatch HasFunction(...);
446 
447 public:
448  static bool const value = (sizeof(HasFunction<T>(0)) == sizeof(Match) );
449 };
450 
451 template<class T>
452 typename std::enable_if<checkForELI_CustomCreateFunctionforSubComponent<T>::value, SubComponent* >::type
453 ELI_templatedCreateforSubComponent(Component* comp, Params& params) {
454  return T::ELI_CustomCreate(comp, params);
455 }
456 
457 template<class T>
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);
461 }
462 
463 
464 #if 0
465 
466 // This has code for looking for non-static class functions
467 template <class T>
468 class checkForCustomCreateComponent
469 {
470  template <typename F, F> struct check;
471 
472  typedef char Match;
473  typedef long NotMatch;
474 
475  // Used for non-static
476  // template <typename F>
477  // struct FunctionSignature
478  // {
479  // typedef Component* (F::*function)(ComponentId_t,Params&);
480  // };
481 
482  struct FunctionSignature
483  {
484  typedef Component* (*function)(ComponentId_t,Params&);
485  };
486 
487  // Used for non-static functions
488  // template <typename F> static Match HasCustomCreate(check< typename FunctionSignature<F>::function, &F::ELI_Custom_Create >*);
489  template <typename F> static Match HasCustomCreate(check< typename FunctionSignature::function, &F::ELI_Custom_Create >*);
490  template <typename F> static NotMatch HasCustomCreate(...);
491 
492 public:
493  static bool const value = (sizeof(HasCustomCreate<T>(0)) == sizeof(Match) );
494 };
495 
496 #endif
497 
498 
499 /**************************************************************************
500  Classes to support Components
501 **************************************************************************/
502 
503 
504 template <class T, unsigned V1, unsigned V2, unsigned V3>
506 private:
507  static const bool loaded;
508 
509 public:
510 
512  initialize_allowedKeys();
513  initialize_portnames();
514  initialize_statnames();
515  }
516 
517  Component* create(ComponentId_t id, Params& params) {
518  // return new T(id, params);
519  return ELI_templatedCreateforComponent<T>(id,params);
520  }
521 
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(); }
535 
536 };
537 
538 
539 // template<class T, int A> const bool SST::ComponentDoc<T, A>::loaded = SST::ElementLibraryDatabase::addComponent(new SST::ComponentDoc<T,T::ELI_getMajorVersion()>());
540 template<class T, unsigned V1, unsigned V2, unsigned V3> const bool SST::ComponentDoc<T,V1,V2,V3>::loaded = SST::ElementLibraryDatabase::addComponent(new SST::ComponentDoc<T,V1,V2,V3>());
541 
542 
543 /**************************************************************************
544  Classes to support SubComponents
545 **************************************************************************/
546 
547 template <class T, unsigned V1, unsigned V2, unsigned V3>
549 private:
550  static const bool loaded;
551 
552 public:
553 
555  initialize_allowedKeys();
556  initialize_portnames();
557  initialize_statnames();
558  }
559 
560  SubComponent* create(Component* comp, Params& params) {
561  // return new T(comp,params);
562  return ELI_templatedCreateforSubComponent<T>(comp,params);
563  }
564 
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(); }
578 };
579 
580 template<class T, unsigned V1, unsigned V2, unsigned V3> const bool SubComponentDoc<T,V1,V2,V3>::loaded = ElementLibraryDatabase::addSubComponent(new SubComponentDoc<T,V1,V2,V3>());
581 
582 
583 /**************************************************************************
584  Classes to support Modules
585  There's some template metaprogramming to check for the two different
586  versions of constructors that can exist.
587 **************************************************************************/
588 
589 template <class T, unsigned V1, unsigned V2, unsigned V3>
590 class ModuleDoc : public ModuleElementInfo {
591 private:
592  static const bool loaded;
593 
594 public:
595 
597  initialize_allowedKeys();
598  }
599 
600  Module* create(Component* comp, Params& params) {
601  return new T(comp,params);
602  }
603 
604  Module* create(Params& params) {
605  return new T(params);
606  }
607 
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(); }
618 };
619 
620 template <class T, unsigned V1, unsigned V2, unsigned V3>
622 private:
623  static const bool loaded;
624 
625 public:
626 
628  initialize_allowedKeys();
629  }
630 
631  Module* create(Component* comp, Params& params) {
632  return new T(comp,params);
633  }
634 
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(); }
645 };
646 
647 template <class T, unsigned V1, unsigned V2, unsigned V3>
649 private:
650  static const bool loaded;
651 
652 public:
653 
655  initialize_allowedKeys();
656  }
657 
658  Module* create(Params& params) {
659  return new T(params);
660  }
661 
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(); }
672 };
673 
674 
675 // These static functions choose between the custom and not custom
676 // create versions by looking for ELI_Custom_Create
677 template<class T, unsigned V1, unsigned V2, unsigned V3>
678 typename std::enable_if<std::is_constructible<T,Component*,Params&>::value &&
679  std::is_constructible<T,Params&>::value, ModuleElementInfo*>::type
680 createModuleDoc() {
681  return new ModuleDoc<T,V1,V2,V3>();
682 }
683 
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
687 createModuleDoc() {
689 }
690 
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
694 createModuleDoc() {
696 }
697 
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>());
699 // template<class T> const bool ModuleDoc<T>::loaded = ElementLibraryDatabase::addModule(new ModuleDoc<T>());
700 
701 
702 /**************************************************************************
703  Classes to support partitioners
704 **************************************************************************/
705 
706 template <class T, unsigned V1, unsigned V2, unsigned V3>
708 private:
709  static const bool loaded;
710 
711 public:
712 
713  virtual Partition::SSTPartitioner* create(RankInfo total_ranks, RankInfo my_rank, int verbosity) override {
714  return new T(total_ranks,my_rank,verbosity);
715  }
716 
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(); }
725 };
726 
727 template<class T, unsigned V1, unsigned V2, unsigned V3> const bool PartitionerDoc<T,V1,V2,V3>::loaded = ElementLibraryDatabase::addPartitioner(new PartitionerDoc<T,V1,V2,V3>());
728 
729 
730 /**************************************************************************
731  Classes to support element python modules
732 **************************************************************************/
733 template <class T, unsigned V1, unsigned V2, unsigned V3>
735 private:
736  static const bool loaded;
737  // Only need to create one of these
738  static T* instance;
739 
740 public:
741 
742  SSTElementPythonModule* create() {
743  // return new T(getLibrary());
744  if( instance == NULL ) instance = new T(getLibrary());
745  return instance;
746  }
747 
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(); }
754 };
755 
756 template<class T, unsigned V1, unsigned V2, unsigned V3> T* PythonModuleDoc<T,V1,V2,V3>::instance = NULL;
757 template<class T, unsigned V1, unsigned V2, unsigned V3> const bool PythonModuleDoc<T,V1,V2,V3>::loaded = ElementLibraryDatabase::addPythonModule(new PythonModuleDoc<T,V1,V2,V3>());
758 
759 
760 
761 /**************************************************************************
762  Class and constexpr functions to extract integers from version number.
763 **************************************************************************/
764 
766  const unsigned major;
767  const unsigned minor;
768  const unsigned tertiary;
769 
770  constexpr unsigned getMajor() { return major; }
771  constexpr unsigned getMinor() { return minor; }
772  constexpr unsigned getTertiary() { return tertiary; }
773 };
774 
775 constexpr unsigned SST_ELI_getMajorNumberFromVersion(SST_ELI_element_version_extraction ver) {
776  return ver.getMajor();
777 }
778 
779 constexpr unsigned SST_ELI_getMinorNumberFromVersion(SST_ELI_element_version_extraction ver) {
780  return ver.getMinor();
781 }
782 
783 constexpr unsigned SST_ELI_getTertiaryNumberFromVersion(SST_ELI_element_version_extraction ver) {
784  return ver.getTertiary();
785 }
786 
787 
788 /**************************************************************************
789  Macros used by elements to add element documentation
790 **************************************************************************/
791 
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; \
797  return date_time; \
798  } \
799  static const std::string ELI_getCompileFile() { \
800  return __FILE__; \
801  } \
802  static const std::vector<int>& ELI_getELICompiledVersion() { \
803  static const std::vector<int> var(SST::SST_ELI_VERSION); \
804  return var; \
805  }
806 
807 
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(); \
811  } \
812  static const std::string ELI_getLibrary() { \
813  return lib; \
814  } \
815  static const std::string ELI_getName() { \
816  return name; \
817  } \
818  static const std::string ELI_getDescription() { \
819  return desc; \
820  } \
821  static const uint32_t ELI_getCategory() { \
822  return cat; \
823  } \
824  SST_ELI_INSERT_COMPILE_INFO()
825 
826 #define SST_ELI_ELEMENT_VERSION(...) {__VA_ARGS__}
827 
828 
829 #define SST_ELI_DOCUMENT_PARAMS(...) \
830  static const std::vector<SST::ElementInfoParam>& ELI_getParams() { \
831  static std::vector<SST::ElementInfoParam> var = { __VA_ARGS__ } ; \
832  return var; \
833  }
834 
835 
836 #define SST_ELI_DOCUMENT_STATISTICS(...) \
837  static const std::vector<SST::ElementInfoStatistic>& ELI_getStatistics() { \
838  static std::vector<SST::ElementInfoStatistic> var = { __VA_ARGS__ } ; \
839  return var; \
840  }
841 
842 
843 #define SST_ELI_DOCUMENT_PORTS(...) \
844  static const std::vector<SST::ElementInfoPort2>& ELI_getPorts() { \
845  static std::vector<SST::ElementInfoPort2> var = { __VA_ARGS__ } ; \
846  return var; \
847  }
848 
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__ } ; \
852  return var; \
853  }
854 
855 
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(); \
859  } \
860  static const std::string ELI_getLibrary() { \
861  return lib; \
862  } \
863  static const std::string ELI_getName() { \
864  return name; \
865  } \
866  static const std::string ELI_getDescription() { \
867  return desc; \
868  } \
869  static const std::string ELI_getInterface() { \
870  return interface; \
871  } \
872  static const std::vector<int>& ELI_getVersion() { \
873  static std::vector<int> var = version ; \
874  return var; \
875  } \
876  SST_ELI_INSERT_COMPILE_INFO()
877 
878 
879 
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(); \
883  } \
884  static const std::string ELI_getLibrary() { \
885  return lib; \
886  } \
887  static const std::string ELI_getName() { \
888  return name; \
889  } \
890  static const std::string ELI_getDescription() { \
891  return desc; \
892  } \
893  static const std::string ELI_getInterface() { \
894  return interface; \
895  } \
896  static const std::vector<int>& ELI_getVersion() { \
897  static std::vector<int> var = version ; \
898  return var; \
899  } \
900  SST_ELI_INSERT_COMPILE_INFO()
901 
902 
903 
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(); \
907  } \
908  static const std::string ELI_getLibrary() { \
909  return lib; \
910  } \
911  static const std::string ELI_getName() { \
912  return name; \
913  } \
914  static const std::string ELI_getDescription() { \
915  return desc; \
916  } \
917  static const std::vector<int>& ELI_getVersion() { \
918  static std::vector<int> var = version ; \
919  return var; \
920  } \
921  SST_ELI_INSERT_COMPILE_INFO()
922 
923 
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(); \
927  } \
928  static const std::string ELI_getLibrary() { \
929  return lib; \
930  } \
931  static const std::vector<int>& ELI_getVersion() { \
932  static std::vector<int> var = version ; \
933  return var; \
934  } \
935  SST_ELI_INSERT_COMPILE_INFO()
936 
937 
938 } //namespace SST
939 
940 #endif // SST_CORE_ELEMENTINFO_H
Definition: elementinfo.h:148
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: action.cc:17
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:133
Definition: elementinfo.h:332
Definition: elementinfo.h:548
Definition: rankInfo.h:21
Definition: elementinfo.h:765
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