SST  12.0.1
StructuralSimulationToolkit
coreTest_SharedObjectComponent.h
1 // Copyright 2009-2022 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-2022, 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 SST_CORE_CORETEST_SHAREDOBJECT_H
17 #define SST_CORE_CORETEST_SHAREDOBJECT_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 {
32  int key;
33  int value;
34 
35  setItem() : key(0), value(0) {}
36 
37  setItem(int key, int value) : key(key), value(value) {}
38 
39  bool operator<(const setItem& lhs) const { return key < lhs.key; }
40 
41  bool operator==(const setItem& lhs) const
42  {
43  if ( key != lhs.key ) return false;
44  if ( value != lhs.value ) return false;
45  return true;
46  }
47 
48  void serialize_order(SST::Core::Serialization::serializer& ser) override
49  {
50  ser& key;
51  ser& value;
52  }
53 
54  ImplementSerializable(SST::CoreTestSharedObjectsComponent::setItem);
55 };
56 
58 {
59 public:
60  // REGISTER THIS COMPONENT INTO THE ELEMENT LIBRARY
61  SST_ELI_REGISTER_COMPONENT(
63  "coreTestElement",
64  "coreTestSharedObjectsComponent",
65  SST_ELI_ELEMENT_VERSION(1,0,0),
66  "Test for SharedObjects",
67  COMPONENT_CATEGORY_UNCATEGORIZED
68  )
69 
70  SST_ELI_DOCUMENT_PARAMS(
71  { "object_type", "Type of object to test ( array | map | set )", "array"},
72  { "num_entities", "Number of entities in the sim", "12"},
73  { "myid", "ID Number (0 <= myid < num_entities)", nullptr},
74  { "full_initialization", "If true, id 0 will initialize whole array, otherwise each id will contribute", "true"},
75  { "multiple_initializers", "If doing full_initialization, this will cause ID N-1 to also initialize array", "false"},
76  { "conflicting_write", "Controls whether a conflicting write is done when full_initialization and multiple_initializers are turned on (otherwise it has no effect)", "false"},
77  { "verify_mode", "Sets verify mode for SharedArray ( FE | INIT | NONE )", "INIT" },
78  { "late_write", "Controls whether a late write is done", "false" },
79  { "publish", "Controls whether publish() is called or not", "true"},
80  { "double_initialize", "If true, initialize() will be called twice", "false" },
81  { "late_initialize", "If true, initialize() will be called during setup instead of in constructor", "false" }
82  )
83 
84  // Optional since there is nothing to document
85  SST_ELI_DOCUMENT_STATISTICS(
86  )
87 
88  // Optional since there is nothing to document
89  SST_ELI_DOCUMENT_PORTS(
90  )
91 
92  // Optional since there is nothing to document
93  SST_ELI_DOCUMENT_SUBCOMPONENT_SLOTS(
94  )
95 
96  coreTestSharedObjectsComponent(SST::ComponentId_t id, SST::Params& params);
98 
99  void init(unsigned int phase) override;
100  void setup() override;
101  void finish() override;
102  void complete(unsigned int phase) override;
103 
104  bool tick(SST::Cycle_t);
105 
106 private:
107  Output out;
108 
109  bool test_array;
110  bool test_map;
111  bool test_set;
112 
113  int myid;
114  int num_entities;
115 
116  int count;
117  bool check;
118  bool late_write;
119  bool pub;
120  bool late_initialize;
121 
125 };
126 
127 } // namespace CoreTestSharedObjectsComponent
128 } // namespace SST
129 
130 #endif // SST_CORE_CORETEST_SHAREDOBJECT_H
Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file...
Definition: output.h:51
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:34
SharedSet class.
Definition: sharedSet.h:28
Definition: coreTest_SharedObjectComponent.h:57
Main component object for the simulation.
Definition: component.h:30
Definition: serializable.h:118
void setup() override
Called after all components have been constructed and initialization has completed, but before simulation time has begun.
Definition: coreTest_SharedObjectComponent.cc:187
Parameter store.
Definition: params.h:55
Definition: coreTest_SharedObjectComponent.h:30
void finish() override
Called after complete phase, but before objects are destroyed.
Definition: coreTest_SharedObjectComponent.cc:224