gem5 v24.0.0.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
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),
150 sparse_histogram(
151 this,
152 params.name.c_str(),
153 statistics::units::Count::get(),
154 params.description.c_str()
155 )
156{
158 (std::set(params.samples.begin(), params.samples.end())).size()
159 );
160}
161
162} // namespace gem5
virtual std::string name() const
Definition named.hh:47
gem5::ScalarStatTester::ScalarStatTesterStats stats
ScalarStatTesterParams params
void setStats() override
SparseHistStatTesterParams params
Vector2dStatTesterParams params
gem5::Vector2dStatTester::Vector2dStatTesterStats stats
void setStats() override
VectorStatTesterParams params
void setStats() override
gem5::VectorStatTester::VectorStatTesterStats stats
Derived & ysubname(off_type index, const std::string &subname)
Derived & subname(off_type index, const std::string &name)
Set the subfield name for the given index, and marks this stat to print at the end of simulation.
Derived & subdesc(off_type index, const std::string &desc)
Set the subfield description for the given index and marks this stat to print at the end of simulatio...
Statistics container.
Definition group.hh:93
Counter value() const
Return the current value of this stat as its base type.
SparseHistogram & init(size_type size)
Set the parameters of this histogram.
Derived & init(size_type _x, size_type _y)
Derived & init(size_type size)
Set this vector to have the given size.
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 15, 8 > vector
Definition intmessage.hh:48
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria 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)
const std::string & name()
Definition trace.cc:48

Generated on Tue Jun 18 2024 16:24:07 for gem5 by doxygen 1.11.0