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

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