Deleted Added
sdiff udiff text old ( 11435:0f1b46dde3fa ) new ( 11439:d0368996f1e0 )
full compact
1/*
2 * Copyright (c) 2014 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software
9 * licensed hereunder. You may use the software subject to the license
10 * terms below provided that you ensure that this notice is replicated

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

58 }
59}
60
61Tick
62QueuedPrefetcher::notify(const PacketPtr &pkt)
63{
64 // Verify this access type is observed by prefetcher
65 if (observeAccess(pkt)) {
66 Addr blk_addr = pkt->getAddr() & ~(Addr)(blkSize - 1);
67 bool is_secure = pkt->isSecure();
68
69 // Squash queued prefetches if demand miss to same line
70 if (queueSquash) {
71 auto itr = pfq.begin();
72 while (itr != pfq.end()) {
73 if (itr->pkt->getAddr() == blk_addr &&
74 itr->pkt->isSecure() == is_secure) {
75 delete itr->pkt->req;
76 delete itr->pkt;
77 itr = pfq.erase(itr);
78 } else {
79 ++itr;
80 }
81 }
82 }
83
84 // Calculate prefetches given this access
85 std::vector addresses;
86 calculatePrefetch(pkt, addresses);
87
88 // Queue up generated prefetches
89 for (Addr pf_addr : addresses) {
90
91 // Block align prefetch address
92 pf_addr = pf_addr & ~(Addr)(blkSize - 1);
93
94 pfIdentified++;
95 DPRINTF(HWPrefetch, "Found a pf candidate addr: %#x, "
96 "inserting into prefetch queue.\n", pf_addr);
97
98 if (queueFilter && inPrefetch(pf_addr, is_secure)) {
99 pfBufferHit++;
100 DPRINTF(HWPrefetch, "Prefetch addr already in "
101 "prefetch queue\n");
102 continue;
103 }
104
105 if (cacheSnoop && (inCache(pf_addr, is_secure) ||
106 inMissQueue(pf_addr, is_secure))) {
107 pfInCache++;
108 DPRINTF(HWPrefetch, "Dropping redundant in "
109 "cache/MSHR prefetch addr:%#x\n", pf_addr);
110 continue;
111 }
112
113 // Create a prefetch memory request
114 Request *pf_req =
115 new Request(pf_addr, blkSize, 0, masterId);
116
117 if (is_secure) {
118 pf_req->setFlags(Request::SECURE);
119 }
120 pf_req->taskId(ContextSwitchTaskId::Prefetcher);
121 PacketPtr pf_pkt = new Packet(pf_req, MemCmd::HardPFReq);
122 pf_pkt->allocate();
123
124 if (pkt->req->hasContextId()) {
125 pf_req->setContext(pkt->req->contextId());
126 }
127
128 if (tagPrefetch && pkt->req->hasPC()) {
129 // Tag prefetch packet with accessing pc
130 pf_pkt->req->setPC(pkt->req->getPC());
131 }
132
133 // Verify prefetch buffer space for request
134 if (pfq.size() == queueSize) {
135 pfRemovedFull++;
136 PacketPtr old_pkt = pfq.begin()->pkt;
137 DPRINTF(HWPrefetch, "Prefetch queue full, removing "
138 "oldest packet addr: %#x", old_pkt->getAddr());
139 delete old_pkt->req;
140 delete old_pkt;
141 pfq.pop_front();
142 }
143
144 Tick pf_time = curTick() + clockPeriod() * latency;
145 DPRINTF(HWPrefetch, "Prefetch queued. "
146 "addr:%#x tick:%lld.\n", pf_addr, pf_time);
147
148 pfq.emplace_back(pf_time, pf_pkt);
149 }
150 }
151
152 return pfq.empty() ? MaxTick : pfq.front().tick;
153}
154
155PacketPtr
156QueuedPrefetcher::getPacket()

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

166 pfq.pop_front();
167
168 pfIssued++;
169 assert(pkt != NULL);
170 DPRINTF(HWPrefetch, "Generating prefetch for %#x.\n", pkt->getAddr());
171 return pkt;
172}
173
174bool
175QueuedPrefetcher::inPrefetch(Addr address, bool is_secure) const
176{
177 for (const DeferredPacket &dp : pfq) {
178 if (dp.pkt->getAddr() == address &&
179 dp.pkt->isSecure() == is_secure) return true;
180 }
181
182 return false;
183}
184
185void
186QueuedPrefetcher::regStats()
187{
188 BasePrefetcher::regStats();
189
190 pfIdentified
191 .name(name() + ".pfIdentified")
192 .desc("number of prefetch candidates identified");

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

202 pfRemovedFull
203 .name(name() + ".pfRemovedFull")
204 .desc("number of prefetches dropped due to prefetch queue size");
205
206 pfSpanPage
207 .name(name() + ".pfSpanPage")
208 .desc("number of prefetches not generated due to page crossing");
209}