gem5  v21.1.0.2
CheckTable.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
3  * Copyright (c) 2009 Advanced Micro Devices, Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met: redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer;
10  * redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution;
13  * neither the name of the copyright holders nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 
31 
32 #include "base/intmath.hh"
33 #include "base/random.hh"
34 #include "base/trace.hh"
36 #include "debug/RubyTest.hh"
37 
38 namespace gem5
39 {
40 
41 CheckTable::CheckTable(int _num_writers, int _num_readers, RubyTester* _tester)
42  : m_num_writers(_num_writers), m_num_readers(_num_readers),
43  m_tester_ptr(_tester)
44 {
45  Addr physical = 0;
46 
47  const int size1 = 32;
48  const int size2 = 100;
49 
50  DPRINTF(RubyTest, "Adding false sharing checks\n");
51  // The first set is to get some false sharing
52  physical = 1000;
53  for (int i = 0; i < size1; i++) {
54  // Setup linear addresses
55  addCheck(physical);
56  physical += CHECK_SIZE;
57  }
58 
59  DPRINTF(RubyTest, "Adding cache conflict checks\n");
60  // The next two sets are to get some limited false sharing and
61  // cache conflicts
62  physical = 1000;
63  for (int i = 0; i < size2; i++) {
64  // Setup linear addresses
65  addCheck(physical);
66  physical += 256;
67  }
68 
69  DPRINTF(RubyTest, "Adding cache conflict checks2\n");
70  physical = 1000 + CHECK_SIZE;
71  for (int i = 0; i < size2; i++) {
72  // Setup linear addresses
73  addCheck(physical);
74  physical += 256;
75  }
76 }
77 
79 {
80  int size = m_check_vector.size();
81  for (int i = 0; i < size; i++)
82  delete m_check_vector[i];
83 }
84 
85 void
87 {
88  if (floorLog2(CHECK_SIZE) != 0) {
89  if (ruby::bitSelect(address, 0, CHECK_SIZE_BITS - 1) != 0) {
90  panic("Check not aligned");
91  }
92  }
93 
94  for (int i = 0; i < CHECK_SIZE; i++) {
95  if (m_lookup_map.count(address+i)) {
96  // A mapping for this byte already existed, discard the
97  // entire check
98  return;
99  }
100  }
101 
102  DPRINTF(RubyTest, "Adding check for address: %s\n", address);
103 
104  Check* check_ptr = new Check(address, 100 + m_check_vector.size(),
106  for (int i = 0; i < CHECK_SIZE; i++) {
107  // Insert it once per byte
108  m_lookup_map[address + i] = check_ptr;
109  }
110  m_check_vector.push_back(check_ptr);
111 }
112 
113 Check*
115 {
116  assert(m_check_vector.size() > 0);
117  return m_check_vector[random_mt.random<unsigned>(0, m_check_vector.size() - 1)];
118 }
119 
120 Check*
122 {
123  DPRINTF(RubyTest, "Looking for check by address: %s\n", address);
124 
125  auto i = m_lookup_map.find(address);
126 
127  if (i == m_lookup_map.end())
128  return NULL;
129 
130  Check* check = i->second;
131  assert(check != NULL);
132  return check;
133 }
134 
135 void
136 CheckTable::print(std::ostream& out) const
137 {
138 }
139 
140 } // namespace gem5
gem5::CheckTable::CheckTable
CheckTable(int _num_writers, int _num_readers, RubyTester *_tester)
Definition: CheckTable.cc:41
gem5::CheckTable::addCheck
void addCheck(Addr address)
Definition: CheckTable.cc:86
gem5::CheckTable::~CheckTable
~CheckTable()
Definition: CheckTable.cc:78
gem5::CheckTable::getRandomCheck
Check * getRandomCheck()
Definition: CheckTable.cc:114
gem5::CheckTable::m_tester_ptr
RubyTester * m_tester_ptr
Definition: CheckTable.hh:73
random.hh
gem5::Check
Definition: Check.hh:51
gem5::ruby::bitSelect
Addr bitSelect(Addr addr, unsigned int small, unsigned int big)
Definition: Address.cc:41
gem5::RubyTester
Definition: RubyTester.hh:60
gem5::ArmISA::i
Bitfield< 7 > i
Definition: misc_types.hh:66
CheckTable.hh
Check.hh
gem5::CheckTable::m_num_readers
int m_num_readers
Definition: CheckTable.hh:72
gem5::CheckTable::m_num_writers
int m_num_writers
Definition: CheckTable.hh:71
gem5::Random::random
std::enable_if_t< std::is_integral< T >::value, T > random()
Use the SFINAE idiom to choose an implementation based on whether the type is integral or floating po...
Definition: random.hh:90
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:186
gem5::CheckTable::print
void print(std::ostream &out) const
Definition: CheckTable.cc:136
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::CheckTable::m_lookup_map
std::unordered_map< Addr, Check * > m_lookup_map
Definition: CheckTable.hh:69
gem5::floorLog2
static constexpr std::enable_if_t< std::is_integral< T >::value, int > floorLog2(T x)
Definition: intmath.hh:59
gem5::CheckTable::m_check_vector
std::vector< Check * > m_check_vector
Definition: CheckTable.hh:68
gem5::CHECK_SIZE
const int CHECK_SIZE
Definition: Check.hh:49
trace.hh
intmath.hh
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40
gem5::random_mt
Random random_mt
Definition: random.cc:99
gem5::CheckTable::getCheck
Check * getCheck(Addr address)
Definition: CheckTable.cc:121
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:177
gem5::CHECK_SIZE_BITS
const int CHECK_SIZE_BITS
Definition: Check.hh:48

Generated on Tue Sep 21 2021 12:25:09 for gem5 by doxygen 1.8.17