gem5  v22.1.0.0
StoreTrace.cc
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 
30 
31 #include "sim/cur_tick.hh"
32 
33 namespace gem5
34 {
35 
36 namespace ruby
37 {
38 
39 bool StoreTrace::s_init = false; // Total number of store lifetimes of
40  // all lines
41 int64_t StoreTrace::s_total_samples = 0; // Total number of store
42  // lifetimes of all lines
43 Histogram* StoreTrace::s_store_count_ptr = NULL;
47 
49  : m_store_count(-1), m_store_first_to_stolen(-1),
50  m_store_last_to_stolen(-1), m_store_first_to_last(-1)
51 {
53  m_addr = addr;
54  m_total_samples = 0;
55 
56  // Really -1 isn't valid, so this will trigger the initilization code
57  m_last_writer = -1;
59 }
60 
62 {
63 }
64 
65 void
66 StoreTrace::print(std::ostream& out) const
67 {
68  out << m_addr
69  << " total_samples: " << m_total_samples << std::endl
70  << "store_count: " << m_store_count << std::endl
71  << "store_first_to_stolen: " << m_store_first_to_stolen << std::endl
72  << "store_last_to_stolen: " << m_store_last_to_stolen << std::endl
73  << "store_first_to_last: " << m_store_first_to_last << std::endl;
74 }
75 
76 void
78 {
79  if (!s_init) {
80  s_total_samples = 0;
81  s_store_count_ptr = new Histogram(-1);
85  }
86  s_init = true;
87 }
88 
89 void
90 StoreTrace::printSummary(std::ostream& out)
91 {
92  out << "total_samples: " << s_total_samples << std::endl;
93  out << "store_count: " << (*s_store_count_ptr) << std::endl;
94  out << "store_first_to_stolen: "
95  << (*s_store_first_to_stolen_ptr) << std::endl;
96  out << "store_last_to_stolen: "
97  << (*s_store_last_to_stolen_ptr) << std::endl;
98  out << "store_first_to_last: " << (*s_store_first_to_last_ptr)
99  << std::endl;
100 }
101 
102 void
104 {
106  s_total_samples = 0;
111 }
112 
113 void
115 {
116  Tick current = curTick();
117 
118  assert((m_last_writer == -1) || (m_last_writer == node));
119 
120  m_last_writer = node;
121  if (m_last_writer == -1) {
122  assert(m_stores_this_interval == 0);
123  }
124 
125  if (m_stores_this_interval == 0) {
126  // A new proessor just wrote the line, so reset the stats
127  m_first_store = current;
128  }
129 
130  m_last_store = current;
132 }
133 
134 void
136 {
137  if (node == m_last_writer) {
138  Tick current = curTick();
139  assert(m_stores_this_interval != 0);
140  assert(m_last_store != 0);
141  assert(m_first_store != 0);
142  assert(m_last_writer != -1);
143 
144  // Per line stats
149  m_total_samples++;
150 
151  // Global stats
152  assert(s_store_first_to_stolen_ptr != NULL);
157  s_total_samples++;
158 
159  // Initilize for next go round
161  m_last_store = 0;
162  m_first_store = 0;
163  m_last_writer = -1;
164  }
165 }
166 
167 } // namespace ruby
168 } // namespace gem5
void add(int64_t value)
Definition: Histogram.cc:93
void store(NodeID node)
Definition: StoreTrace.cc:114
static void printSummary(std::ostream &out)
Definition: StoreTrace.cc:90
static int64_t s_total_samples
Definition: StoreTrace.hh:62
static Histogram * s_store_first_to_stolen_ptr
Definition: StoreTrace.hh:65
void downgrade(NodeID node)
Definition: StoreTrace.cc:135
Histogram m_store_last_to_stolen
Definition: StoreTrace.hh:78
static Histogram * s_store_count_ptr
Definition: StoreTrace.hh:64
static void initSummary()
Definition: StoreTrace.cc:77
Histogram m_store_first_to_last
Definition: StoreTrace.hh:79
static Histogram * s_store_first_to_last_ptr
Definition: StoreTrace.hh:67
Histogram m_store_first_to_stolen
Definition: StoreTrace.hh:77
void print(std::ostream &out) const
Definition: StoreTrace.cc:66
static Histogram * s_store_last_to_stolen_ptr
Definition: StoreTrace.hh:66
static void clearSummary()
Definition: StoreTrace.cc:103
Bitfield< 3 > addr
Definition: types.hh:84
unsigned int NodeID
Definition: TypeDefines.hh:42
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Tick curTick()
The universal simulation clock.
Definition: cur_tick.hh:46
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
uint64_t Tick
Tick count type.
Definition: types.hh:58

Generated on Wed Dec 21 2022 10:22:38 for gem5 by doxygen 1.9.1