Deleted Added
sdiff udiff text old ( 9545:508784fad4e5 ) new ( 9546:ac0c18d738ce )
full compact
1/*
2 * Copyright (c) 2005 The Regents of The University of Michigan
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

--- 124 unchanged lines hidden (view full) ---

134{
135 DPRINTF(HWPrefetch, "Requesting a hw_pf to issue\n");
136
137 if (pf.empty()) {
138 DPRINTF(HWPrefetch, "No HW_PF found\n");
139 return NULL;
140 }
141
142 PacketPtr pkt = *pf.begin();
143 while (!pf.empty()) {
144 pkt = *pf.begin();
145 pf.pop_front();
146
147 Addr blk_addr = pkt->getAddr() & ~(Addr)(blkSize-1);
148
149 if (!inCache(blk_addr) && !inMissQueue(blk_addr))
150 // we found a prefetch, return it
151 break;
152

--- 10 unchanged lines hidden (view full) ---

163 pfIssued++;
164 assert(pkt != NULL);
165 DPRINTF(HWPrefetch, "returning 0x%x\n", pkt->getAddr());
166 return pkt;
167}
168
169
170Tick
171BasePrefetcher::notify(PacketPtr &pkt, Tick time)
172{
173 if (!pkt->req->isUncacheable() && !(pkt->req->isInstFetch() && onlyData)) {
174 // Calculate the blk address
175 Addr blk_addr = pkt->getAddr() & ~(Addr)(blkSize-1);
176
177 // Check if miss is in pfq, if so remove it
178 std::list<PacketPtr>::iterator iter = inPrefetch(blk_addr);
179 if (iter != pf.end()) {
180 DPRINTF(HWPrefetch, "Saw a miss to a queued prefetch addr: "
181 "0x%x, removing it\n", blk_addr);
182 pfRemovedMSHR++;
183 delete (*iter)->req;
184 delete (*iter);
185 iter = pf.erase(iter);
186 if (pf.empty())
187 cache->deassertMemSideBusRequest(BaseCache::Request_PF);
188 }
189
190 // Remove anything in queue with delay older than time
191 // since everything is inserted in time order, start from end
192 // and work until pf.empty() or time is earlier
193 // This is done to emulate Aborting the previous work on a new miss
194 // Needed for serial calculators like GHB
195 if (serialSquash) {
196 iter = pf.end();
197 if (iter != pf.begin())
198 iter--;
199 while (!pf.empty() && ((*iter)->time >= time)) {
200 pfSquashed++;
201 DPRINTF(HWPrefetch, "Squashing old prefetch addr: 0x%x\n",
202 (*iter)->getAddr());
203 delete (*iter)->req;
204 delete (*iter);
205 iter = pf.erase(iter);
206 if (iter != pf.begin())
207 iter--;
208 }
209 if (pf.empty())
210 cache->deassertMemSideBusRequest(BaseCache::Request_PF);
211 }
212

--- 23 unchanged lines hidden (view full) ---

236 // create a prefetch memreq
237 Request *prefetchReq = new Request(*addrIter, blkSize, 0, masterId);
238 PacketPtr prefetch =
239 new Packet(prefetchReq, MemCmd::HardPFReq);
240 prefetch->allocate();
241 prefetch->req->setThreadContext(pkt->req->contextId(),
242 pkt->req->threadId());
243
244 prefetch->time = time + clockPeriod() * *delayIter;
245
246 // We just remove the head if we are full
247 if (pf.size() == size) {
248 pfRemovedFull++;
249 PacketPtr old_pkt = *pf.begin();
250 DPRINTF(HWPrefetch, "Prefetch queue full, "
251 "removing oldest 0x%x\n", old_pkt->getAddr());
252 delete old_pkt->req;
253 delete old_pkt;
254 pf.pop_front();
255 }
256
257 pf.push_back(prefetch);
258 }
259 }
260
261 return pf.empty() ? 0 : pf.front()->time;
262}
263
264std::list<PacketPtr>::iterator
265BasePrefetcher::inPrefetch(Addr address)
266{
267 // Guaranteed to only be one match, we always check before inserting
268 std::list<PacketPtr>::iterator iter;
269 for (iter = pf.begin(); iter != pf.end(); iter++) {
270 if (((*iter)->getAddr() & ~(Addr)(blkSize-1)) == address) {
271 return iter;
272 }
273 }
274 return pf.end();
275}
276
277bool
278BasePrefetcher::samePage(Addr a, Addr b)
279{
280 return roundDown(a, TheISA::VMPageSize) == roundDown(b, TheISA::VMPageSize);
281}
282
283