gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
stat_tester.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 The Regents of the University of California
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
30
31#include <set>
32
33#include "base/stats/group.hh"
34
35namespace gem5
36{
37
38void
40{
41 stats.scalar = params.value;
42}
43
45 statistics::Group *parent,
46 const ScalarStatTesterParams &params
47) : statistics::Group(parent),
48 scalar(this,
49 params.name.c_str(),
50 statistics::units::Count::get(),
51 params.description.c_str()
52 )
53{
54}
55
56void
58{
59 for (int i = 0; i < params.values.size(); i++)
60 {
61 stats.vector[i] = (params.values[i]);
62 }
63}
64
66 statistics::Group *parent,
67 const VectorStatTesterParams &params
68) : statistics::Group(parent),
69 vector(this,
70 params.name.c_str(),
71 statistics::units::Count::get(),
72 params.description.c_str()
73 )
74{
75 vector.init(params.values.size());
76 for (int i = 0; i < params.values.size(); i++)
77 {
78 if (params.subnames.size() > i) {
79 vector.subname(i, params.subnames[i]);
80 } else {
81 vector.subname(i, std::to_string(i));
82 }
83 if (params.subdescs.size() > i) {
84 vector.subdesc(i, params.subdescs[i]);
85 }
86 }
87}
88
89void
91{
92 for (int i = 0; i < params.x_size; i++)
93 {
94 for (int j = 0; j < params.y_size; j++)
95 {
96 stats.vector2d[i][j] = (params.values[j + i * params.y_size]);
97 }
98 }
99}
100
102 statistics::Group *parent,
103 const Vector2dStatTesterParams &params
104) : statistics::Group(parent),
105 vector2d(this,
106 params.name.c_str(),
107 statistics::units::Count::get(),
108 params.description.c_str()
109 )
110{
111 vector2d.init(params.x_size, params.y_size);
112
113 assert(params.x_size * params.y_size == params.values.size());
114
115 for (int i = 0; i < params.x_size; i++)
116 {
117 if (params.subnames.size() > i) {
118 vector2d.subname(i, params.subnames[i]);
119 } else {
120 vector2d.subname(i, std::to_string(i));
121 }
122 if (params.subdescs.size() > i) {
123 vector2d.subdesc(i, params.subdescs[i]);
124 }
125 }
126 for (int j = 0; j < params.y_size; j++)
127 {
128 if (params.ysubnames.size() > j) {
129 vector2d.ysubname(j, params.ysubnames[j]);
130 } else {
131 vector2d.ysubname(j, std::to_string(j));
132 }
133
134 }
135
136}
137
138void
140{
141 for (auto sample : params.samples) {
142 stats.sparse_histogram.sample(sample);
143 }
144}
145
147 statistics::Group *parent,
148 const SparseHistStatTesterParams &params
149) : statistics::Group(parent),
151 this,
152 params.name.c_str(),
153 statistics::units::Count::get(),
154 params.description.c_str()
155 )
156{
157 sparse_histogram.init(
158 (std::set(params.samples.begin(), params.samples.end())).size()
159 );
160}
161
162} // namespace gem5
virtual std::string name() const
Definition named.hh:60
gem5::ScalarStatTester::ScalarStatTesterStats stats
ScalarStatTesterParams params
void setStats() override
gem5::SparseHistStatTester::SparseHistStatTesterStats stats
SparseHistStatTesterParams params
Vector2dStatTesterParams params
gem5::Vector2dStatTester::Vector2dStatTesterStats stats
void setStats() override
VectorStatTesterParams params
void setStats() override
gem5::VectorStatTester::VectorStatTesterStats stats
Statistics container.
Definition group.hh:93
Bitfield< 7 > i
Definition misc_types.hh:67
Units for Stats.
Definition units.hh:113
Copyright (c) 2024 Arm Limited All rights reserved.
Definition binary32.hh:36
ScalarStatTesterStats(statistics::Group *parent, const ScalarStatTesterParams &params)
SparseHistStatTesterStats(statistics::Group *parent, const SparseHistStatTesterParams &params)
Vector2dStatTesterStats(statistics::Group *parent, const Vector2dStatTesterParams &params)
VectorStatTesterStats(statistics::Group *parent, const VectorStatTesterParams &params)

Generated on Mon May 26 2025 09:19:15 for gem5 by doxygen 1.13.2