SST  11.0.0
StructuralSimulationToolkit
coreTest_SharedObjectComponent.h
1 // Copyright 2009-2021 NTESS. Under the terms
2 // of Contract DE-NA0003525 with NTESS, the U.S.
3 // Government retains certain rights in this software.
4 //
5 // Copyright (c) 2009-2021, NTESS
6 // All rights reserved.
7 //
8 // Portions are copyright of other developers:
9 // See the file CONTRIBUTORS.TXT in the top level directory
10 // the distribution for more information.
11 //
12 // This file is part of the SST software package. For license
13 // information, see the LICENSE file in the top level directory of the
14 // distribution.
15 
16 #ifndef _CORETESTSHAREDOBJECT_H
17 #define _CORETESTSHAREDOBJECT_H
18 
19 #include <sst/core/component.h>
20 #include <sst/core/output.h>
21 #include <sst/core/shared/sharedArray.h>
22 #include <sst/core/shared/sharedMap.h>
23 #include <sst/core/shared/sharedSet.h>
24 
25 namespace SST {
26 namespace CoreTestSharedObjectsComponent {
27 
28 // Class so that we can check to see if the equivalence check works
29 // for sets
31  int key;
32  int value;
33 
34  setItem() :
35  key(0),
36  value(0)
37  {}
38 
39  setItem(int key, int value) :
40  key(key),
41  value(value)
42  {}
43 
44  bool operator<(const setItem& lhs) const {
45  return key < lhs.key;
46  }
47 
48  bool operator==(const setItem& lhs) const {
49  if ( key != lhs.key ) return false;
50  if ( value != lhs.value ) return false;
51  return true;
52  }
53 
54  void serialize_order(SST::Core::Serialization::serializer& ser) override {
55  ser & key;
56  ser & value;
57  }
58 
59  ImplementSerializable(SST::CoreTestSharedObjectsComponent::setItem);
60 
61 };
62 
64 {
65 public:
66 
67  // REGISTER THIS COMPONENT INTO THE ELEMENT LIBRARY
68  SST_ELI_REGISTER_COMPONENT(
70  "coreTestElement",
71  "coreTestSharedObjectsComponent",
72  SST_ELI_ELEMENT_VERSION(1,0,0),
73  "Test for SharedObjects",
74  COMPONENT_CATEGORY_UNCATEGORIZED
75  )
76 
77  SST_ELI_DOCUMENT_PARAMS(
78  { "object_type", "Type of object to test ( array | map | set )", "array"},
79  { "num_entities", "Number of entities in the sim", "12"},
80  { "myid", "ID Number (0 <= myid < num_entities)", nullptr},
81  { "full_initialization", "If true, id 0 will initialize whole array, otherwise each id will contribute", "true"},
82  { "multiple_initializers", "If doing full_initialization, this will cause ID N-1 to also initialize array", "false"},
83  { "conflicting_write", "Controls whether a conflicting write is done when full_initialization and multiple_initializers are turned on (otherwise it has no effect)", "false"},
84  { "verify_mode", "Sets verify mode for SharedArray ( FE | INIT | NONE )", "INIT" },
85  { "late_write", "Controls whether a late write is done", "false" },
86  { "publish", "Controls whether publish() is called or not", "true"},
87  { "double_initialize", "If true, initialize() will be called twice", "false" },
88  { "late_initialize", "If true, initialize() will be called during setup instead of in constructor", "false" }
89  )
90 
91  // Optional since there is nothing to document
92  SST_ELI_DOCUMENT_STATISTICS(
93  )
94 
95  // Optional since there is nothing to document
96  SST_ELI_DOCUMENT_PORTS(
97  )
98 
99  // Optional since there is nothing to document
100  SST_ELI_DOCUMENT_SUBCOMPONENT_SLOTS(
101  )
102 
103  coreTestSharedObjectsComponent(SST::ComponentId_t id, SST::Params& params);
105 
106  void init(unsigned int phase) override;
107  void setup() override;
108  void finish() override;
109  void complete(unsigned int phase) override;
110 
111  bool tick(SST::Cycle_t);
112 private:
113  Output out;
114 
115  bool test_array;
116  bool test_map;
117  bool test_set;
118 
119  int myid;
120  int num_entities;
121 
122  int count;
123  bool check;
124  bool late_write;
125  bool pub;
126  bool late_initialize;
127 
131 };
132 
133 }
134 }
135 
136 #endif
Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file...
Definition: output.h:54
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:35
SharedSet class.
Definition: sharedSet.h:28
Definition: coreTest_SharedObjectComponent.h:63
Main component object for the simulation.
Definition: component.h:31
Definition: serializable.h:109
void setup() override
Called after all components have been constructed and initialization has completed, but before simulation time has begun.
Definition: coreTest_SharedObjectComponent.cc:189
Parameter store.
Definition: params.h:44
Definition: coreTest_SharedObjectComponent.h:30
void finish() override
Called after simulation completes, but before objects are destroyed.
Definition: coreTest_SharedObjectComponent.cc:240