Deleted Added
sdiff udiff text old ( 13560:f8732494c155 ) new ( 13590:d7e018859709 )
full compact
1/*
2 * Copyright (c) 2011-2012, 2014 ARM Limited
3 * Copyright (c) 2013 Advanced Micro Devices, Inc.
4 * All rights reserved
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating
9 * to a hardware implementation of the functionality of the software
10 * licensed hereunder. You may use the software subject to the license

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

56#include "debug/Writeback.hh"
57#include "params/DerivO3CPU.hh"
58
59using namespace std;
60
61template <class Impl>
62LSQ<Impl>::LSQ(O3CPU *cpu_ptr, IEW *iew_ptr, DerivO3CPUParams *params)
63 : cpu(cpu_ptr), iewStage(iew_ptr),
64 lsqPolicy(params->smtLSQPolicy),
65 LQEntries(params->LQEntries),
66 SQEntries(params->SQEntries),
67 maxLQEntries(maxLSQAllocation(lsqPolicy, LQEntries, params->numThreads,
68 params->smtLSQThreshold)),
69 maxSQEntries(maxLSQAllocation(lsqPolicy, SQEntries, params->numThreads,
70 params->smtLSQThreshold)),
71 numThreads(params->numThreads)
72{
73 assert(numThreads > 0 && numThreads <= Impl::MaxThreads);
74
75 //**********************************************/
76 //************ Handle SMT Parameters ***********/
77 //**********************************************/
78
79 //Figure out fetch policy
80 if (lsqPolicy == SMTQueuePolicy::Dynamic) {
81 DPRINTF(LSQ, "LSQ sharing policy set to Dynamic\n");
82 } else if (lsqPolicy == SMTQueuePolicy::Partitioned) {
83 DPRINTF(Fetch, "LSQ sharing policy set to Partitioned: "
84 "%i entries per LQ | %i entries per SQ\n",
85 maxLQEntries,maxSQEntries);
86 } else if (lsqPolicy == SMTQueuePolicy::Threshold) {
87
88 assert(params->smtLSQThreshold > LQEntries);
89 assert(params->smtLSQThreshold > SQEntries);
90
91 DPRINTF(LSQ, "LSQ sharing policy set to Threshold: "
92 "%i entries per LQ | %i entries per SQ\n",
93 maxLQEntries,maxSQEntries);
94 } else {
95 panic("Invalid LSQ sharing policy. Options are: Dynamic, "
96 "Partitioned, Threshold");
97 }

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

158
159 return drained;
160}
161
162template <class Impl>
163void
164LSQ<Impl>::takeOverFrom()
165{
166 for (ThreadID tid = 0; tid < numThreads; tid++) {
167 thread[tid].takeOverFrom();
168 }
169}
170
171template <class Impl>
172int
173LSQ<Impl>::entryAmount(ThreadID num_threads)
174{
175 if (lsqPolicy == SMTQueuePolicy::Partitioned) {
176 return LQEntries / num_threads;
177 } else {
178 return 0;
179 }
180}
181
182template <class Impl>
183void
184LSQ<Impl>::resetEntries()
185{
186 if (lsqPolicy != SMTQueuePolicy::Dynamic || numThreads > 1) {
187 int active_threads = activeThreads->size();
188
189 int maxEntries;
190
191 if (lsqPolicy == SMTQueuePolicy::Partitioned) {
192 maxEntries = LQEntries / active_threads;
193 } else if (lsqPolicy == SMTQueuePolicy::Threshold &&
194 active_threads == 1) {
195 maxEntries = LQEntries;
196 } else {
197 maxEntries = LQEntries;
198 }
199
200 list<ThreadID>::iterator threads = activeThreads->begin();
201 list<ThreadID>::iterator end = activeThreads->end();
202
203 while (threads != end) {
204 ThreadID tid = *threads++;
205
206 resizeEntries(maxEntries, tid);
207 }
208 }
209}
210
211template<class Impl>
212void
213LSQ<Impl>::removeEntries(ThreadID tid)
214{
215 thread[tid].clearLQ();
216 thread[tid].clearSQ();
217}
218
219template<class Impl>
220void
221LSQ<Impl>::resizeEntries(unsigned size, ThreadID tid)
222{
223 thread[tid].resizeLQ(size);
224 thread[tid].resizeSQ(size);
225}
226
227template<class Impl>
228void
229LSQ<Impl>::tick()
230{
231 list<ThreadID>::iterator threads = activeThreads->begin();
232 list<ThreadID>::iterator end = activeThreads->end();
233
234 while (threads != end) {
235 ThreadID tid = *threads++;
236
237 thread[tid].tick();
238 }
239}
240
241template<class Impl>
242void
243LSQ<Impl>::insertLoad(const DynInstPtr &load_inst)
244{
245 ThreadID tid = load_inst->threadNumber;
246

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

311 return false;
312}
313
314template <class Impl>
315void
316LSQ<Impl>::recvReqRetry()
317{
318 iewStage->cacheUnblocked();
319
320 for (ThreadID tid : *activeThreads) {
321 thread[tid].recvRetry();
322 }
323}
324
325template <class Impl>
326bool
327LSQ<Impl>::recvTimingResp(PacketPtr pkt)
328{
329 if (pkt->isError())
330 DPRINTF(LSQ, "Got error packet back for address: %#X\n",
331 pkt->getAddr());
332
333 thread[cpu->contextToThread(pkt->req->contextId())]
334 .completeDataAccess(pkt);
335
336 if (pkt->isInvalidate()) {
337 // This response also contains an invalidate; e.g. this can be the case
338 // if cmd is ReadRespWithInvalidate.
339 //
340 // The calling order between completeDataAccess and checkSnoop matters.
341 // By calling checkSnoop after completeDataAccess, we ensure that the
342 // fault set by checkSnoop is not lost. Calling writeback (more
343 // specifically inst->completeAcc) in completeDataAccess overwrites
344 // fault, and in case this instruction requires squashing (as
345 // determined by checkSnoop), the ReExec fault set by checkSnoop would
346 // be lost otherwise.
347
348 DPRINTF(LSQ, "received invalidation with response for addr:%#x\n",
349 pkt->getAddr());
350
351 for (ThreadID tid = 0; tid < numThreads; tid++) {
352 thread[tid].checkSnoop(pkt);
353 }
354 }
355
356 delete pkt;
357 return true;
358}
359
360template <class Impl>
361void
362LSQ<Impl>::recvTimingSnoopReq(PacketPtr pkt)
363{
364 DPRINTF(LSQ, "received pkt for addr:%#x %s\n", pkt->getAddr(),

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

676
677 while (threads != end) {
678 ThreadID tid = *threads++;
679
680 thread[tid].dumpInsts();
681 }
682}
683
684#endif//__CPU_O3_LSQ_IMPL_HH__