gem5  v20.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
inst_queue.hh
Go to the documentation of this file.
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
11  * terms below provided that you ensure that this notice is replicated
12  * unmodified and in its entirety in all distributions of the software,
13  * modified or unmodified, in source code or in binary form.
14  *
15  * Copyright (c) 2004-2006 The Regents of The University of Michigan
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms, with or without
19  * modification, are permitted provided that the following conditions are
20  * met: redistributions of source code must retain the above copyright
21  * notice, this list of conditions and the following disclaimer;
22  * redistributions in binary form must reproduce the above copyright
23  * notice, this list of conditions and the following disclaimer in the
24  * documentation and/or other materials provided with the distribution;
25  * neither the name of the copyright holders nor the names of its
26  * contributors may be used to endorse or promote products derived from
27  * this software without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  */
41 
42 #ifndef __CPU_O3_INST_QUEUE_HH__
43 #define __CPU_O3_INST_QUEUE_HH__
44 
45 #include <list>
46 #include <map>
47 #include <queue>
48 #include <vector>
49 
50 #include "base/statistics.hh"
51 #include "base/types.hh"
52 #include "cpu/o3/dep_graph.hh"
53 #include "cpu/inst_seq.hh"
54 #include "cpu/op_class.hh"
55 #include "cpu/timebuf.hh"
56 #include "enums/SMTQueuePolicy.hh"
57 #include "sim/eventq.hh"
58 
59 struct DerivO3CPUParams;
60 class FUPool;
61 class MemInterface;
62 
80 template <class Impl>
82 {
83  public:
84  //Typedefs from the Impl.
85  typedef typename Impl::O3CPU O3CPU;
86  typedef typename Impl::DynInstPtr DynInstPtr;
87 
88  typedef typename Impl::CPUPol::IEW IEW;
89  typedef typename Impl::CPUPol::MemDepUnit MemDepUnit;
90  typedef typename Impl::CPUPol::IssueStruct IssueStruct;
91  typedef typename Impl::CPUPol::TimeStruct TimeStruct;
92 
93  // Typedef of iterator through the list of instructions.
95 
97  class FUCompletion : public Event {
98  private:
100  DynInstPtr inst;
101 
103  int fuIdx;
104 
107 
111  bool freeFU;
112 
113  public:
115  FUCompletion(const DynInstPtr &_inst, int fu_idx,
116  InstructionQueue<Impl> *iq_ptr);
117 
118  virtual void process();
119  virtual const char *description() const;
120  void setFreeFU() { freeFU = true; }
121  };
122 
124  InstructionQueue(O3CPU *cpu_ptr, IEW *iew_ptr, DerivO3CPUParams *params);
125 
128 
130  std::string name() const;
131 
133  void regStats();
134 
136  void resetState();
137 
140 
143 
146 
148  bool isDrained() const;
149 
151  void drainSanityCheck() const;
152 
154  void takeOverFrom();
155 
157  int entryAmount(ThreadID num_threads);
158 
160  void resetEntries();
161 
163  unsigned numFreeEntries();
164 
166  unsigned numFreeEntries(ThreadID tid);
167 
169  bool isFull();
170 
172  bool isFull(ThreadID tid);
173 
175  bool hasReadyInsts();
176 
178  void insert(const DynInstPtr &new_inst);
179 
181  void insertNonSpec(const DynInstPtr &new_inst);
182 
186  void insertBarrier(const DynInstPtr &barr_inst);
187 
191  DynInstPtr getInstToExecute();
192 
196  DynInstPtr getDeferredMemInstToExecute();
197 
201  DynInstPtr getBlockedMemInstToExecute();
202 
207  void recordProducer(const DynInstPtr &inst)
208  { addToProducers(inst); }
209 
211  void processFUCompletion(const DynInstPtr &inst, int fu_idx);
212 
217  void scheduleReadyInsts();
218 
220  void scheduleNonSpec(const InstSeqNum &inst);
221 
226  void commit(const InstSeqNum &inst, ThreadID tid = 0);
227 
229  int wakeDependents(const DynInstPtr &completed_inst);
230 
232  void addReadyMemInst(const DynInstPtr &ready_inst);
233 
238  void rescheduleMemInst(const DynInstPtr &resched_inst);
239 
241  void replayMemInst(const DynInstPtr &replay_inst);
242 
244  void completeMemInst(const DynInstPtr &completed_inst);
245 
250  void deferMemInst(const DynInstPtr &deferred_inst);
251 
253  void blockMemInst(const DynInstPtr &blocked_inst);
254 
256  void cacheUnblocked();
257 
259  void violation(const DynInstPtr &store, const DynInstPtr &faulting_load);
260 
265  void squash(ThreadID tid);
266 
268  unsigned getCount(ThreadID tid) { return count[tid]; };
269 
271  void printInsts();
272 
273  private:
275  void doSquash(ThreadID tid);
276 
278  // Various pointers
280 
282  O3CPU *cpu;
283 
285  MemInterface *dcacheInterface;
286 
288  IEW *iewStage;
289 
293  MemDepUnit memDepUnit[Impl::MaxThreads];
294 
299 
302 
305 
308 
310  // Instruction lists, ready queues, and ordering
312 
314  std::list<DynInstPtr> instList[Impl::MaxThreads];
315 
318 
323 
326 
331 
339  struct pqCompare {
340  bool operator() (const DynInstPtr &lhs, const DynInstPtr &rhs) const
341  {
342  return lhs->seqNum > rhs->seqNum;
343  }
344  };
345 
346  typedef std::priority_queue<DynInstPtr, std::vector<DynInstPtr>, pqCompare>
348 
353 
361  std::map<InstSeqNum, DynInstPtr> nonSpecInsts;
362 
363  typedef typename std::map<InstSeqNum, DynInstPtr>::iterator NonSpecMapIt;
364 
366  struct ListOrderEntry {
367  OpClass queueType;
369  };
370 
379 
381 
384 
388  ListOrderIt readyIt[Num_OpClasses];
389 
391  void addToOrderList(OpClass op_class);
392 
397  void moveToYoungerInst(ListOrderIt age_order_it);
398 
400 
402  // Various parameters
404 
406  SMTQueuePolicy iqPolicy;
407 
410 
413 
415  unsigned count[Impl::MaxThreads];
416 
418  unsigned maxEntries[Impl::MaxThreads];
419 
421  unsigned freeEntries;
422 
424  unsigned numEntries;
425 
427  unsigned totalWidth;
428 
430  unsigned numPhysRegs;
431 
434 
439 
441  InstSeqNum squashedSeqNum[Impl::MaxThreads];
442 
450 
452  bool addToDependents(const DynInstPtr &new_inst);
453 
455  void addToProducers(const DynInstPtr &new_inst);
456 
458  void addIfReady(const DynInstPtr &inst);
459 
464  int countInsts();
465 
470  void dumpLists();
471 
475  void dumpInsts();
476 
481 
504  // Also include number of instructions rescheduled and replayed.
505 
509 // Stats::VectorDistribution queueResDist;
515 // Stats::VectorDistribution issueDelayDist;
516 
521 // Stats::Vector dist_unissued;
524 
527 
532  public:
542 
546 };
547 
548 #endif //__CPU_O3_INST_QUEUE_HH__
Stats::Scalar iqMiscInstsIssued
Stat for number of miscellaneous instructions issued.
Definition: inst_queue.hh:492
int wbOutstanding
Number of instructions currently in flight to FUs.
Definition: inst_queue.hh:433
void regStats()
Registers statistics.
std::list< ThreadID > * activeThreads
Pointer to list of active threads.
Definition: inst_queue.hh:412
Stats::Scalar iqFloatInstsIssued
Stat for number of floating point instructions issued.
Definition: inst_queue.hh:486
unsigned getCount(ThreadID tid)
Returns the number of used entries for a thread.
Definition: inst_queue.hh:268
void replayMemInst(const DynInstPtr &replay_inst)
Replays a memory instruction.
Stats::Scalar vecInstQueueReads
Definition: inst_queue.hh:539
Struct for comparing entries to be added to the priority queue.
Definition: inst_queue.hh:339
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:81
void insertNonSpec(const DynInstPtr &new_inst)
Inserts a new, non-speculative instruction into the IQ.
Stats::Scalar fpAluAccesses
Definition: inst_queue.hh:544
void doSquash(ThreadID tid)
Does the actual squashing.
void scheduleReadyInsts()
Schedules ready instructions, adding the ready ones (oldest first) to the queue to execute...
Stats::Scalar intAluAccesses
Definition: inst_queue.hh:543
void recordProducer(const DynInstPtr &inst)
Records the instruction as the producer of a register without adding it to the rest of the IQ...
Definition: inst_queue.hh:207
Impl::CPUPol::IEW IEW
Definition: inst_queue.hh:88
Stats::Scalar iqInstsAdded
Stat for number of instructions added.
Definition: inst_queue.hh:478
InstructionQueue(O3CPU *cpu_ptr, IEW *iew_ptr, DerivO3CPUParams *params)
Constructs an IQ.
bool queueOnList[Num_OpClasses]
Tracks if each ready queue is on the age order list.
Definition: inst_queue.hh:383
Stats::Scalar fpInstQueueWakeupAccesses
Definition: inst_queue.hh:538
std::list< DynInstPtr > instsToExecute
List of instructions that are ready to be executed.
Definition: inst_queue.hh:317
void squash()
Squash the current event.
Definition: eventq.hh:466
void dumpInsts()
Debugging function to dump out all instructions that are in the IQ.
InstSeqNum squashedSeqNum[Impl::MaxThreads]
The sequence number of the squashed instruction.
Definition: inst_queue.hh:441
Impl::DynInstPtr DynInstPtr
Definition: inst_queue.hh:86
void violation(const DynInstPtr &store, const DynInstPtr &faulting_load)
Indicates an ordering violation between a store and a load.
void scheduleNonSpec(const InstSeqNum &inst)
Schedules a single specific non-speculative instruction.
DynInstPtr getInstToExecute()
Returns the oldest scheduled instruction, and removes it from the list of instructions waiting to exe...
Stats::Scalar iqInstsIssued
Definition: inst_queue.hh:482
MemInterface * dcacheInterface
Cache interface.
Definition: inst_queue.hh:285
FU completion event class.
Definition: inst_queue.hh:97
Stats::Scalar iqMemInstsIssued
Stat for number of memory instructions issued.
Definition: inst_queue.hh:490
A vector of scalar stats.
Definition: statistics.hh:2547
void addToOrderList(OpClass op_class)
Add an op class to the age order list.
void setActiveThreads(std::list< ThreadID > *at_ptr)
Sets active threads list.
void insertBarrier(const DynInstPtr &barr_inst)
Inserts a memory or write barrier into the IQ to make sure loads and stores are ordered properly...
unsigned numEntries
The number of entries in the instruction queue.
Definition: inst_queue.hh:424
std::list< DynInstPtr > instList[Impl::MaxThreads]
List of all the instructions in the IQ (some of which may be issued).
Definition: inst_queue.hh:314
bool addToDependents(const DynInstPtr &new_inst)
Adds an instruction to the dependency graph, as a consumer.
Declaration of Statistics objects.
DynInstPtr inst
Executing instruction.
Definition: inst_queue.hh:100
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2505
void rescheduleMemInst(const DynInstPtr &resched_inst)
Reschedules a memory instruction.
void setTimeBuffer(TimeBuffer< TimeStruct > *tb_ptr)
Sets the global time buffer.
std::vector< bool > regScoreboard
A cache of the recently woken registers.
Definition: inst_queue.hh:449
Stats::Scalar fpInstQueueWrites
Definition: inst_queue.hh:537
Impl::O3CPU O3CPU
Definition: inst_queue.hh:85
Impl::CPUPol::IssueStruct IssueStruct
Definition: inst_queue.hh:90
std::list< DynInstPtr > blockedMemInsts
List of instructions that have been cache blocked.
Definition: inst_queue.hh:325
bool isFull()
Returns whether or not the IQ is full.
unsigned numFreeEntries()
Returns total number of free entries.
int fuIdx
Index of the FU used for executing.
Definition: inst_queue.hh:103
bool hasReadyInsts()
Returns if there are any ready instructions in the IQ.
Stats::Scalar intInstQueueWakeupAccesses
Definition: inst_queue.hh:535
virtual const std::string name() const
Definition: eventq.cc:82
Stats::Scalar iqSquashedNonSpecRemoved
Stat for number of non-speculative instructions removed due to a squash.
Definition: inst_queue.hh:503
Pool of FU&#39;s, specific to the new CPU model.
Definition: fu_pool.hh:69
Array of linked list that maintains the dependencies between producing instructions and consuming ins...
Definition: dep_graph.hh:71
A simple distribution stat.
Definition: statistics.hh:2589
TimeBuffer< IssueStruct > * issueToExecuteQueue
The queue to the execute stage.
Definition: inst_queue.hh:298
int wakeDependents(const DynInstPtr &completed_inst)
Wakes all dependents of a completed instruction.
IEW * iewStage
Pointer to IEW stage.
Definition: inst_queue.hh:288
Stats::Scalar intInstQueueWrites
Definition: inst_queue.hh:534
void addReadyMemInst(const DynInstPtr &ready_inst)
Adds a ready memory instruction to the ready list.
ReadyInstQueue readyInsts[Num_OpClasses]
List of ready instructions, per op class.
Definition: inst_queue.hh:352
void commit(const InstSeqNum &inst, ThreadID tid=0)
Commits all instructions up to and including the given sequence number, for a specific thread...
uint64_t InstSeqNum
Definition: inst_seq.hh:37
std::map< InstSeqNum, DynInstPtr > nonSpecInsts
List of non-speculative instructions that will be scheduled once the IQ gets a signal from commit...
Definition: inst_queue.hh:361
std::list< ListOrderEntry > listOrder
List that contains the age order of the oldest instruction of each ready queue.
Definition: inst_queue.hh:378
void addIfReady(const DynInstPtr &inst)
Moves an instruction to the ready queue if it is ready.
Stats::Scalar iqBranchInstsIssued
Stat for number of branch instructions issued.
Definition: inst_queue.hh:488
STL list class.
Definition: stl.hh:51
virtual const char * description() const
Return a C string describing the event.
unsigned count[Impl::MaxThreads]
Per Thread IQ count.
Definition: inst_queue.hh:415
void takeOverFrom()
Takes over execution from another CPU&#39;s thread.
TimeBuffer< TimeStruct > * timeBuffer
The backwards time buffer.
Definition: inst_queue.hh:301
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
Cycles commitToIEWDelay
Delay between commit stage and the IQ.
Definition: inst_queue.hh:438
Stats::Scalar iqSquashedInstsIssued
Stat for number of squashed instructions that were ready to issue.
Definition: inst_queue.hh:494
Stats::Formula fuBusyRate
Number of times the FU was busy per instruction issued.
Definition: inst_queue.hh:531
std::list< ListOrderEntry >::iterator ListOrderIt
Definition: inst_queue.hh:380
Stats::Scalar vecAluAccesses
Definition: inst_queue.hh:545
std::list< DynInstPtr > retryMemInsts
List of instructions that were cache blocked, but a retry has been seen since, so they can now be ret...
Definition: inst_queue.hh:330
TimeBuffer< TimeStruct >::wire fromCommit
Wire to read information from timebuffer.
Definition: inst_queue.hh:304
A formula for statistics that is calculated when printed.
Definition: statistics.hh:3009
void deferMemInst(const DynInstPtr &deferred_inst)
Defers a memory instruction when its DTB translation incurs a hw page table walk. ...
DynInstPtr getBlockedMemInstToExecute()
Gets a memory instruction that was blocked on the cache.
void resetState()
Resets all instruction queue state.
~InstructionQueue()
Destructs the IQ.
DynInstPtr getDeferredMemInstToExecute()
Gets a memory instruction that was referred due to a delayed DTB translation if it is now ready to ex...
void drainSanityCheck() const
Perform sanity checks after a drain.
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:225
Stats::Vector2d statIssuedInstType
Stat for total number issued for each instruction type.
Definition: inst_queue.hh:523
SMTQueuePolicy iqPolicy
IQ sharing policy for SMT.
Definition: inst_queue.hh:406
DependencyGraph< DynInstPtr > dependGraph
Definition: inst_queue.hh:399
int countInsts()
Debugging function to count how many entries are in the IQ.
bool freeFU
Should the FU be added to the list to be freed upon completing this event.
Definition: inst_queue.hh:111
Stats::Scalar iqSquashedOperandsExamined
Stat for number of squashed instruction operands examined when squashing.
Definition: inst_queue.hh:500
void blockMemInst(const DynInstPtr &blocked_inst)
Defers a memory instruction when it is cache blocked.
void resetEntries()
Resets max entries for all threads.
Stats::Scalar fpInstQueueReads
Definition: inst_queue.hh:536
Stats::Scalar vecInstQueueWrites
Definition: inst_queue.hh:540
static const OpClass Num_OpClasses
Definition: op_class.hh:105
std::priority_queue< DynInstPtr, std::vector< DynInstPtr >, pqCompare > ReadyInstQueue
Definition: inst_queue.hh:347
Definition: eventq.hh:245
void completeMemInst(const DynInstPtr &completed_inst)
Completes a memory operation.
std::map< InstSeqNum, DynInstPtr >::iterator NonSpecMapIt
Definition: inst_queue.hh:363
int entryAmount(ThreadID num_threads)
Number of entries needed for given amount of threads.
Stats::Scalar iqSquashedInstsExamined
Stat for number of squashed instructions examined when squashing.
Definition: inst_queue.hh:496
O3CPU * cpu
Pointer to the CPU.
Definition: inst_queue.hh:282
ListOrderIt readyIt[Num_OpClasses]
Iterators of each ready queue.
Definition: inst_queue.hh:388
void processFUCompletion(const DynInstPtr &inst, int fu_idx)
Process FU completion event.
Stats::Scalar iqIntInstsIssued
Stat for number of integer instructions issued.
Definition: inst_queue.hh:484
Stats::Vector fuBusy
Number of times the FU was busy.
Definition: inst_queue.hh:529
Entry for the list age ordering by op class.
Definition: inst_queue.hh:366
std::list< DynInstPtr >::iterator ListIt
Definition: inst_queue.hh:94
unsigned maxEntries[Impl::MaxThreads]
Max IQ Entries Per Thread.
Definition: inst_queue.hh:418
Stats::Scalar vecInstQueueWakeupAccesses
Definition: inst_queue.hh:541
void setIssueToExecuteQueue(TimeBuffer< IssueStruct > *i2eQueue)
Sets the timer buffer between issue and execute.
void cacheUnblocked()
Notify instruction queue that a previous blockage has resolved.
void moveToYoungerInst(ListOrderIt age_order_it)
Called when the oldest instruction has been removed from a ready queue; this places that ready queue ...
Stats::Scalar iqNonSpecInstsAdded
Stat for number of non-speculative instructions added.
Definition: inst_queue.hh:480
void printInsts()
Debug function to print all instructions.
Stats::Formula issueRate
Number of instructions issued per cycle.
Definition: inst_queue.hh:526
unsigned numPhysRegs
The number of physical registers in the CPU.
Definition: inst_queue.hh:430
A 2-Dimensional vecto of scalar stats.
Definition: statistics.hh:2575
Stats::Scalar intInstQueueReads
Definition: inst_queue.hh:533
MemDepUnit memDepUnit[Impl::MaxThreads]
The memory dependence unit, which tracks/predicts memory dependences between instructions.
Definition: inst_queue.hh:293
void addToProducers(const DynInstPtr &new_inst)
Adds an instruction to the dependency graph, as a producer.
FUPool * fuPool
Function unit pool.
Definition: inst_queue.hh:307
std::list< DynInstPtr > deferredMemInsts
List of instructions waiting for their DTB translation to complete (hw page table walk in progress)...
Definition: inst_queue.hh:322
bool isDrained() const
Determine if we are drained.
FUCompletion(const DynInstPtr &_inst, int fu_idx, InstructionQueue< Impl > *iq_ptr)
Construct a FU completion event.
InstructionQueue< Impl > * iqPtr
Pointer back to the instruction queue.
Definition: inst_queue.hh:106
A standard instruction queue class.
Definition: inst_queue.hh:81
unsigned totalWidth
The total number of instructions that can be issued in one cycle.
Definition: inst_queue.hh:427
void dumpLists()
Debugging function to dump all the list sizes, as well as print out the list of nonspeculative instru...
Stats::Distribution numIssuedDist
Distribution of number of instructions in the queue.
Definition: inst_queue.hh:511
unsigned freeEntries
Number of free IQ entries left.
Definition: inst_queue.hh:421
Stats::Vector statFuBusy
Distribution of the cycles it takes to issue an instruction.
Definition: inst_queue.hh:520
Impl::CPUPol::MemDepUnit MemDepUnit
Definition: inst_queue.hh:89
Impl::CPUPol::TimeStruct TimeStruct
Definition: inst_queue.hh:91
ThreadID numThreads
Number of Total Threads.
Definition: inst_queue.hh:409
void insert(const DynInstPtr &new_inst)
Inserts a new instruction into the IQ.

Generated on Thu May 28 2020 16:21:31 for gem5 by doxygen 1.8.13