gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Histogram.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
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 
29 #ifndef __MEM_RUBY_COMMON_HISTOGRAM_HH__
30 #define __MEM_RUBY_COMMON_HISTOGRAM_HH__
31 
32 #include <cstdint>
33 #include <iostream>
34 #include <vector>
35 
37 
38 namespace gem5
39 {
40 
41 namespace ruby
42 {
43 
44 class Histogram
45 {
46  public:
47  Histogram(int binsize = 1, uint32_t bins = 50);
48  ~Histogram();
49 
50  void add(int64_t value);
51  void add(Histogram& hist);
52  void doubleBinSize();
53 
54  void clear() { clear(m_data.size()); }
55  void clear(uint32_t bins);
56  void clear(int binsize, uint32_t bins);
57 
58  uint64_t size() const { return m_count; }
59  uint32_t getBins() const { return m_data.size(); }
60  int getBinSize() const { return m_binsize; }
61  int64_t getTotal() const { return m_sumSamples; }
62  uint64_t getSquaredTotal() const { return m_sumSquaredSamples; }
63  uint64_t getData(int index) const { return m_data[index]; }
64  int64_t getMax() const { return m_max; }
65 
66  void printWithMultiplier(std::ostream& out, double multiplier) const;
67  void printPercent(std::ostream& out) const;
68  void print(std::ostream& out) const;
69 
70 private:
72  int64_t m_max; // the maximum value seen so far
73  uint64_t m_count; // the number of elements added
74  int m_binsize; // the size of each bucket
75  uint32_t m_largest_bin; // the largest bin used
76 
77  int64_t m_sumSamples; // the sum of all samples
78  uint64_t m_sumSquaredSamples; // the sum of the square of all samples
79 
80  double getStandardDeviation() const;
81 };
82 
83 bool node_less_then_eq(const Histogram* n1, const Histogram* n2);
84 
85 inline std::ostream&
86 operator<<(std::ostream& out, const Histogram& obj)
87 {
88  obj.print(out);
89  out << std::flush;
90  return out;
91 }
92 
93 } // namespace ruby
94 } // namespace gem5
95 
96 #endif // __MEM_RUBY_COMMON_HISTOGRAM_HH__
gem5::ruby::Histogram::m_largest_bin
uint32_t m_largest_bin
Definition: Histogram.hh:75
gem5::ruby::Histogram::clear
void clear()
Definition: Histogram.hh:54
gem5::ruby::Histogram::getTotal
int64_t getTotal() const
Definition: Histogram.hh:61
gem5::ruby::Histogram::m_data
std::vector< uint64_t > m_data
Definition: Histogram.hh:71
gem5::ruby::Histogram::m_count
uint64_t m_count
Definition: Histogram.hh:73
gem5::MipsISA::index
Bitfield< 30, 0 > index
Definition: pra_constants.hh:47
gem5::ruby::operator<<
std::ostream & operator<<(std::ostream &os, const BoolVec &myvector)
Definition: BoolVec.cc:49
gem5::ruby::Histogram::add
void add(int64_t value)
Definition: Histogram.cc:93
gem5::ruby::Histogram::m_max
int64_t m_max
Definition: Histogram.hh:72
std::vector< uint64_t >
gem5::ruby::Histogram::getStandardDeviation
double getStandardDeviation() const
Definition: Histogram.cc:181
gem5::ruby::Histogram::m_sumSquaredSamples
uint64_t m_sumSquaredSamples
Definition: Histogram.hh:78
gem5::ruby::Histogram::getBinSize
int getBinSize() const
Definition: Histogram.hh:60
gem5::ruby::Histogram::printWithMultiplier
void printWithMultiplier(std::ostream &out, double multiplier) const
Definition: Histogram.cc:209
gem5::ruby::Histogram::m_binsize
int m_binsize
Definition: Histogram.hh:74
gem5::ruby::Histogram::getData
uint64_t getData(int index) const
Definition: Histogram.hh:63
gem5::ruby::Histogram::printPercent
void printPercent(std::ostream &out) const
Definition: Histogram.cc:199
gem5::ruby::Histogram::m_sumSamples
int64_t m_sumSamples
Definition: Histogram.hh:77
TypeDefines.hh
gem5::ruby::Histogram::getMax
int64_t getMax() const
Definition: Histogram.hh:64
gem5::ruby::Histogram::doubleBinSize
void doubleBinSize()
Definition: Histogram.cc:77
gem5::ruby::Histogram
Definition: Histogram.hh:44
gem5::ruby::Histogram::~Histogram
~Histogram()
Definition: Histogram.cc:49
gem5::ruby::Histogram::Histogram
Histogram(int binsize=1, uint32_t bins=50)
Definition: Histogram.cc:43
gem5::ruby::Histogram::getBins
uint32_t getBins() const
Definition: Histogram.hh:59
gem5::ruby::Histogram::size
uint64_t size() const
Definition: Histogram.hh:58
gem5::ruby::node_less_then_eq
bool node_less_then_eq(const Histogram *n1, const Histogram *n2)
Definition: Histogram.cc:239
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::ruby::Histogram::print
void print(std::ostream &out) const
Definition: Histogram.cc:193
gem5::ruby::Histogram::getSquaredTotal
uint64_t getSquaredTotal() const
Definition: Histogram.hh:62

Generated on Sun Jul 30 2023 01:56:58 for gem5 by doxygen 1.8.17