SST 16.0.0
Structural Simulation Toolkit
configStatistic.h
1// -*- c++ -*-
2
3// Copyright 2009-2026 NTESS. Under the terms
4// of Contract DE-NA0003525 with NTESS, the U.S.
5// Government retains certain rights in this software.
6//
7// Copyright (c) 2009-2026, NTESS
8// All rights reserved.
9//
10// This file is part of the SST software package. For license
11// information, see the LICENSE file in the top level directory of the
12// distribution.
13
14#ifndef SST_CORE_CONFIGCSTATISTIC_H
15#define SST_CORE_CONFIGCSTATISTIC_H
16
17#include "sst/core/params.h"
18#include "sst/core/serialization/serializable.h"
19#include "sst/core/sst_types.h"
20#include "sst/core/statapi/statbase.h"
21#include "sst/core/statapi/statoutput.h"
22
23#include <climits>
24#include <cstddef>
25#include <cstdint>
26#include <map>
27#include <memory>
28#include <ostream>
29#include <string>
30#include <utility>
31#include <vector>
32
33using namespace SST::Statistics;
34
35namespace SST {
36
37class ConfigGraph;
38class ConfigLink;
39
40class ConfigStatistic : public SST::Core::Serialization::serializable
41{
42public:
43 StatisticId_t id; /*!< Unique ID of this statistic */
44 Params params;
45 bool shared = false;
46 std::string name;
47
48 ConfigStatistic(StatisticId_t _id, bool _shared = false, std::string _name = "") :
49 id(_id),
50 shared(_shared),
51 name(_name)
52 {}
53
55 id(stat_null_id)
56 {}
57
58 ConfigStatistic(const ConfigStatistic&) = default;
60 ConfigStatistic& operator=(const ConfigStatistic&) = default;
61 ConfigStatistic& operator=(ConfigStatistic&&) = default;
62 ~ConfigStatistic() override = default;
63
64 inline const StatisticId_t& getId() const { return id; }
65
66 void addParameter(const std::string& key, const std::string& value, bool overwrite);
67
68 void serialize_order(SST::Core::Serialization::serializer& ser) override
69 {
70 SST_SER(id);
71 SST_SER(shared);
72 SST_SER(name);
73 SST_SER(params);
74 }
75
76 ImplementSerializable(ConfigStatistic)
77
78 static constexpr StatisticId_t stat_null_id = std::numeric_limits<StatisticId_t>::max();
79};
80
81class ConfigStatGroup : public SST::Core::Serialization::serializable
82{
83public:
84 std::string name;
85 std::map<std::string, Params> statMap;
86 std::vector<ComponentId_t> components;
87 size_t outputID;
88 UnitAlgebra outputFrequency;
89
90 explicit ConfigStatGroup(const std::string& name) :
91 name(name),
92 outputID(0)
93 {}
94 ConfigStatGroup() {} /* Do not use */
95
96 bool addComponent(ComponentId_t id);
97 bool addStatistic(const std::string& name, Params& p);
98 bool setOutput(size_t id);
99 bool setFrequency(const std::string& freq);
100
101 /**
102 * Checks to make sure that all components in the group support all
103 * of the statistics as configured in the group.
104 * @return pair of: bool for OK, string for error message (if any)
105 */
106 std::pair<bool, std::string> verifyStatsAndComponents(const ConfigGraph* graph);
107
108 void serialize_order(SST::Core::Serialization::serializer& ser) override
109 {
110 SST_SER(name);
111 SST_SER(statMap);
112 SST_SER(components);
113 SST_SER(outputID);
114 SST_SER(outputFrequency);
115 }
116
117 ImplementSerializable(SST::ConfigStatGroup)
118};
119
120class ConfigStatOutput : public SST::Core::Serialization::serializable
121{
122public:
123 std::string type;
124 Params params;
125
126 explicit ConfigStatOutput(const std::string& type) :
127 type(type)
128 {}
129 ConfigStatOutput() {}
130
131 void addParameter(const std::string& key, const std::string& val) { params.insert(key, val); }
132
133 void serialize_order(SST::Core::Serialization::serializer& ser) override
134 {
135 SST_SER(type);
136 SST_SER(params);
137 }
138
139 ImplementSerializable(SST::ConfigStatOutput)
140};
141
143{
144 std::map<std::string, ConfigStatGroup> groups;
145 std::vector<ConfigStatOutput> outputs; // [0] is default group
146 uint8_t load_level;
147
148 void serialize_order(SST::Core::Serialization::serializer& ser)
149 {
150 SST_SER(groups);
151 SST_SER(outputs);
152 SST_SER(load_level);
153 }
154};
155
156} // namespace SST
157
158#endif // SST_CORE_CONFIGCOMPONENT_H
A Configuration Graph A graph representing Components and Links.
Definition configGraph.h:76
Definition configStatistic.h:82
std::pair< bool, std::string > verifyStatsAndComponents(const ConfigGraph *graph)
Checks to make sure that all components in the group support all of the statistics as configured in t...
Definition configStatistic.cc:81
Definition configStatistic.h:121
Definition configStatistic.h:41
StatisticId_t id
Definition configStatistic.h:43
Definition serializable.h:25
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition serializer.h:43
Parameter store.
Definition params.h:65
Performs Unit math in full precision.
Definition unitAlgebra.h:107
Definition configStatistic.h:143