gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
31namespace gem5
32{
33
34namespace ruby
35{
36
40
44
45void
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
72void
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
97bool
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
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
130AccessType
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
145void
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
162bool
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
171int
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
183int
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
195void
196PersistentTable::print(std::ostream& out) const
197{
198}
199
200} // namespace ruby
201} // namespace gem5
void add(MachineID newElement)
Definition NetDest.cc:45
void remove(MachineID oldElement)
Definition NetDest.cc:70
bool isElement(MachineID element) const
Definition NetDest.cc:247
bool isSubset(const NetDest &test) const
Definition NetDest.hh:82
int count() const
Definition NetDest.cc:128
MachineID smallestElement() const
Definition NetDest.cc:144
bool isEmpty() const
Definition NetDest.cc:186
void persistentRequestLock(Addr address, MachineID locker, AccessType type)
void persistentRequestUnlock(Addr address, MachineID unlocker)
int countReadStarvingForAddress(Addr addr) const
AccessType typeOfSmallest(Addr address) const
MachineID findSmallest(Addr address) const
bool isLocked(Addr addr) const
bool okToIssueStarving(Addr address, MachineID machID) const
void print(std::ostream &out) const
int countStarvingForAddress(Addr addr) const
STL pair class.
Definition stl.hh:58
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 7 > present
Definition misc.hh:1027
Addr makeLineAddress(Addr addr)
Definition Address.cc:60
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147

Generated on Tue Jun 18 2024 16:24:05 for gem5 by doxygen 1.11.0