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

Generated on Tue Mar 23 2021 19:41:28 for gem5 by doxygen 1.8.17