gem5  v20.1.0.0
PersistentTable.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 using namespace std;
32 
33 
35 {
36 }
37 
39 {
40 }
41 
42 void
44  MachineID locker,
45  AccessType type)
46 {
47  assert(address == makeLineAddress(address));
48 
49  static const PersistentTableEntry dflt;
51  m_map.insert(AddressMap::value_type(address, dflt));
52  bool present = !r.second;
53  AddressMap::iterator i = r.first;
54  PersistentTableEntry &entry = i->second;
55 
56  if (present) {
57  // Make sure we're not already in the locked set
58  assert(!(entry.m_starving.isElement(locker)));
59  }
60 
61  entry.m_starving.add(locker);
62  if (type == AccessType_Write)
63  entry.m_request_to_write.add(locker);
64 
65  if (present)
66  assert(entry.m_marked.isSubset(entry.m_starving));
67 }
68 
69 void
71  MachineID unlocker)
72 {
73  assert(address == makeLineAddress(address));
74  assert(m_map.count(address));
75  PersistentTableEntry& entry = m_map[address];
76 
77  //
78  // Make sure we're in the locked set
79  //
80  assert(entry.m_starving.isElement(unlocker));
81  assert(entry.m_marked.isSubset(entry.m_starving));
82  entry.m_starving.remove(unlocker);
83  entry.m_marked.remove(unlocker);
84  entry.m_request_to_write.remove(unlocker);
85  assert(entry.m_marked.isSubset(entry.m_starving));
86 
87  // Deallocate if empty
88  if (entry.m_starving.isEmpty()) {
89  assert(entry.m_marked.isEmpty());
90  m_map.erase(address);
91  }
92 }
93 
94 bool
96  MachineID machId) const
97 {
98  assert(address == makeLineAddress(address));
99 
100  AddressMap::const_iterator i = m_map.find(address);
101  if (i == m_map.end()) {
102  // No entry present
103  return true;
104  }
105 
106  const PersistentTableEntry &entry = i->second;
107 
108  if (entry.m_starving.isElement(machId)) {
109  // We can't issue another lockdown until are previous unlock
110  // has occurred
111  return false;
112  }
113 
114  return entry.m_marked.isEmpty();
115 }
116 
117 MachineID
119 {
120  assert(address == makeLineAddress(address));
121  AddressMap::const_iterator i = m_map.find(address);
122  assert(i != m_map.end());
123  const PersistentTableEntry& entry = i->second;
124  return entry.m_starving.smallestElement();
125 }
126 
127 AccessType
129 {
130  assert(address == makeLineAddress(address));
131  AddressMap::const_iterator i = m_map.find(address);
132  assert(i != m_map.end());
133  const PersistentTableEntry& entry = i->second;
134  if (entry.m_request_to_write.
135  isElement(entry.m_starving.smallestElement())) {
136  return AccessType_Write;
137  } else {
138  return AccessType_Read;
139  }
140 }
141 
142 void
144 {
145  assert(address == makeLineAddress(address));
146  AddressMap::iterator i = m_map.find(address);
147  if (i == m_map.end())
148  return;
149 
150  PersistentTableEntry& entry = i->second;
151 
152  // None should be marked
153  assert(entry.m_marked.isEmpty());
154 
155  // Mark all the nodes currently in the table
156  entry.m_marked = entry.m_starving;
157 }
158 
159 bool
161 {
162  assert(address == makeLineAddress(address));
163 
164  // If an entry is present, it must be locked
165  return m_map.count(address) > 0;
166 }
167 
168 int
170 {
171  assert(address == makeLineAddress(address));
172  AddressMap::const_iterator i = m_map.find(address);
173  if (i == m_map.end())
174  return 0;
175 
176  const PersistentTableEntry& entry = i->second;
177  return entry.m_starving.count();
178 }
179 
180 int
182 {
183  assert(address == makeLineAddress(address));
184  AddressMap::const_iterator i = m_map.find(address);
185  if (i == m_map.end())
186  return 0;
187 
188  const PersistentTableEntry& entry = i->second;
189  return entry.m_starving.count() - entry.m_request_to_write.count();
190 }
191 
192 void
193 PersistentTable::print(ostream& out) const
194 {
195 }
196 
PersistentTable::typeOfSmallest
AccessType typeOfSmallest(Addr address) const
Definition: PersistentTable.cc:128
NetDest::add
void add(MachineID newElement)
Definition: NetDest.cc:39
PersistentTable::~PersistentTable
~PersistentTable()
Definition: PersistentTable.cc:38
PersistentTable::print
void print(std::ostream &out) const
Definition: PersistentTable.cc:193
NetDest::count
int count() const
Definition: NetDest.cc:122
makeLineAddress
Addr makeLineAddress(Addr addr)
Definition: Address.cc:54
ArmISA::i
Bitfield< 7 > i
Definition: miscregs_types.hh:63
PersistentTable::okToIssueStarving
bool okToIssueStarving(Addr address, MachineID machID) const
Definition: PersistentTable.cc:95
PersistentTableEntry::m_request_to_write
NetDest m_request_to_write
Definition: PersistentTable.hh:48
NetDest::remove
void remove(MachineID oldElement)
Definition: NetDest.cc:64
X86ISA::present
Bitfield< 7 > present
Definition: misc.hh:992
type
uint8_t type
Definition: inet.hh:421
NetDest::isSubset
bool isSubset(const NetDest &test) const
Definition: NetDest.hh:76
PersistentTable::PersistentTable
PersistentTable()
Definition: PersistentTable.cc:34
MachineID
Definition: MachineID.hh:38
NetDest::isElement
bool isElement(MachineID element) const
Definition: NetDest.cc:241
PersistentTable::countReadStarvingForAddress
int countReadStarvingForAddress(Addr addr) const
Definition: PersistentTable.cc:181
PersistentTable::markEntries
void markEntries(Addr address)
Definition: PersistentTable.cc:143
MipsISA::r
r
Definition: pra_constants.hh:95
PersistentTable::findSmallest
MachineID findSmallest(Addr address) const
Definition: PersistentTable.cc:118
PersistentTable::isLocked
bool isLocked(Addr addr) const
Definition: PersistentTable.cc:160
NetDest::smallestElement
MachineID smallestElement() const
Definition: NetDest.cc:138
std::pair
STL pair class.
Definition: stl.hh:58
PersistentTable.hh
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
PersistentTableEntry
Definition: PersistentTable.hh:40
std
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:587
PersistentTable::persistentRequestLock
void persistentRequestLock(Addr address, MachineID locker, AccessType type)
Definition: PersistentTable.cc:43
PersistentTable::persistentRequestUnlock
void persistentRequestUnlock(Addr address, MachineID unlocker)
Definition: PersistentTable.cc:70
PersistentTableEntry::m_marked
NetDest m_marked
Definition: PersistentTable.hh:47
NetDest::isEmpty
bool isEmpty() const
Definition: NetDest.cc:180
PersistentTable::countStarvingForAddress
int countStarvingForAddress(Addr addr) const
Definition: PersistentTable.cc:169
PersistentTableEntry::m_starving
NetDest m_starving
Definition: PersistentTable.hh:46

Generated on Wed Sep 30 2020 14:02:13 for gem5 by doxygen 1.8.17