gem5  v19.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  * Authors: Kevin Lim
42  */
43 
44 #ifndef __CPU_O3_INST_QUEUE_HH__
45 #define __CPU_O3_INST_QUEUE_HH__
46 
47 #include <list>
48 #include <map>
49 #include <queue>
50 #include <vector>
51 
52 #include "base/statistics.hh"
53 #include "base/types.hh"
54 #include "cpu/o3/dep_graph.hh"
55 #include "cpu/inst_seq.hh"
56 #include "cpu/op_class.hh"
57 #include "cpu/timebuf.hh"
58 #include "enums/SMTQueuePolicy.hh"
59 #include "sim/eventq.hh"
60 
61 struct DerivO3CPUParams;
62 class FUPool;
63 class MemInterface;
64 
82 template <class Impl>
84 {
85  public:
86  //Typedefs from the Impl.
87  typedef typename Impl::O3CPU O3CPU;
88  typedef typename Impl::DynInstPtr DynInstPtr;
89 
90  typedef typename Impl::CPUPol::IEW IEW;
91  typedef typename Impl::CPUPol::MemDepUnit MemDepUnit;
92  typedef typename Impl::CPUPol::IssueStruct IssueStruct;
93  typedef typename Impl::CPUPol::TimeStruct TimeStruct;
94 
95  // Typedef of iterator through the list of instructions.
97 
99  class FUCompletion : public Event {
100  private:
102  DynInstPtr inst;
103 
105  int fuIdx;
106 
109 
113  bool freeFU;
114 
115  public:
117  FUCompletion(const DynInstPtr &_inst, int fu_idx,
118  InstructionQueue<Impl> *iq_ptr);
119 
120  virtual void process();
121  virtual const char *description() const;
122  void setFreeFU() { freeFU = true; }
123  };
124 
126  InstructionQueue(O3CPU *cpu_ptr, IEW *iew_ptr, DerivO3CPUParams *params);
127 
130 
132  std::string name() const;
133 
135  void regStats();
136 
138  void resetState();
139 
142 
145 
148 
150  bool isDrained() const;
151 
153  void drainSanityCheck() const;
154 
156  void takeOverFrom();
157 
159  int entryAmount(ThreadID num_threads);
160 
162  void resetEntries();
163 
165  unsigned numFreeEntries();
166 
168  unsigned numFreeEntries(ThreadID tid);
169 
171  bool isFull();
172 
174  bool isFull(ThreadID tid);
175 
177  bool hasReadyInsts();
178 
180  void insert(const DynInstPtr &new_inst);
181 
183  void insertNonSpec(const DynInstPtr &new_inst);
184 
188  void insertBarrier(const DynInstPtr &barr_inst);
189 
193  DynInstPtr getInstToExecute();
194 
198  DynInstPtr getDeferredMemInstToExecute();
199 
203  DynInstPtr getBlockedMemInstToExecute();
204 
209  void recordProducer(const DynInstPtr &inst)
210  { addToProducers(inst); }
211 
213  void processFUCompletion(const DynInstPtr &inst, int fu_idx);
214 
219  void scheduleReadyInsts();
220 
222  void scheduleNonSpec(const InstSeqNum &inst);
223 
228  void commit(const InstSeqNum &inst, ThreadID tid = 0);
229 
231  int wakeDependents(const DynInstPtr &completed_inst);
232 
234  void addReadyMemInst(const DynInstPtr &ready_inst);
235 
240  void rescheduleMemInst(const DynInstPtr &resched_inst);
241 
243  void replayMemInst(const DynInstPtr &replay_inst);
244 
246  void completeMemInst(const DynInstPtr &completed_inst);
247 
252  void deferMemInst(const DynInstPtr &deferred_inst);
253 
255  void blockMemInst(const DynInstPtr &blocked_inst);
256 
258  void cacheUnblocked();
259 
261  void violation(const DynInstPtr &store, const DynInstPtr &faulting_load);
262 
267  void squash(ThreadID tid);
268 
270  unsigned getCount(ThreadID tid) { return count[tid]; };
271 
273  void printInsts();
274 
275  private:
277  void doSquash(ThreadID tid);
278 
280  // Various pointers
282 
284  O3CPU *cpu;
285 
287  MemInterface *dcacheInterface;
288 
290  IEW *iewStage;
291 
295  MemDepUnit memDepUnit[Impl::MaxThreads];
296 
301 
304 
307 
310 
312  // Instruction lists, ready queues, and ordering
314 
316  std::list<DynInstPtr> instList[Impl::MaxThreads];
317 
320 
325 
328 
333 
341  struct pqCompare {
342  bool operator() (const DynInstPtr &lhs, const DynInstPtr &rhs) const
343  {
344  return lhs->seqNum > rhs->seqNum;
345  }
346  };
347 
348  typedef std::priority_queue<DynInstPtr, std::vector<DynInstPtr>, pqCompare>
350 
355 
363  std::map<InstSeqNum, DynInstPtr> nonSpecInsts;
364 
365  typedef typename std::map<InstSeqNum, DynInstPtr>::iterator NonSpecMapIt;
366 
368  struct ListOrderEntry {
369  OpClass queueType;
371  };
372 
381 
383 
386 
390  ListOrderIt readyIt[Num_OpClasses];
391 
393  void addToOrderList(OpClass op_class);
394 
399  void moveToYoungerInst(ListOrderIt age_order_it);
400 
402 
404  // Various parameters
406 
408  SMTQueuePolicy iqPolicy;
409 
412 
415 
417  unsigned count[Impl::MaxThreads];
418 
420  unsigned maxEntries[Impl::MaxThreads];
421 
423  unsigned freeEntries;
424 
426  unsigned numEntries;
427 
429  unsigned totalWidth;
430 
432  unsigned numPhysRegs;
433 
436 
441 
443  InstSeqNum squashedSeqNum[Impl::MaxThreads];
444 
452 
454  bool addToDependents(const DynInstPtr &new_inst);
455 
457  void addToProducers(const DynInstPtr &new_inst);
458 
460  void addIfReady(const DynInstPtr &inst);
461 
466  int countInsts();
467 
472  void dumpLists();
473 
477  void dumpInsts();
478 
483 
506  // Also include number of instructions rescheduled and replayed.
507 
511 // Stats::VectorDistribution queueResDist;
517 // Stats::VectorDistribution issueDelayDist;
518 
523 // Stats::Vector dist_unissued;
526 
529 
534  public:
544 
548 };
549 
550 #endif //__CPU_O3_INST_QUEUE_HH__
Stats::Scalar iqMiscInstsIssued
Stat for number of miscellaneous instructions issued.
Definition: inst_queue.hh:494
int wbOutstanding
Number of instructions currently in flight to FUs.
Definition: inst_queue.hh:435
void regStats()
Registers statistics.
std::list< ThreadID > * activeThreads
Pointer to list of active threads.
Definition: inst_queue.hh:414
Stats::Scalar iqFloatInstsIssued
Stat for number of floating point instructions issued.
Definition: inst_queue.hh:488
unsigned getCount(ThreadID tid)
Returns the number of used entries for a thread.
Definition: inst_queue.hh:270
void replayMemInst(const DynInstPtr &replay_inst)
Replays a memory instruction.
Stats::Scalar vecInstQueueReads
Definition: inst_queue.hh:541
Struct for comparing entries to be added to the priority queue.
Definition: inst_queue.hh:341
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
void insertNonSpec(const DynInstPtr &new_inst)
Inserts a new, non-speculative instruction into the IQ.
Stats::Scalar fpAluAccesses
Definition: inst_queue.hh:546
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:545
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:209
Impl::CPUPol::IEW IEW
Definition: inst_queue.hh:90
Stats::Scalar iqInstsAdded
Stat for number of instructions added.
Definition: inst_queue.hh:480
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:385
Stats::Scalar fpInstQueueWakeupAccesses
Definition: inst_queue.hh:540
std::list< DynInstPtr > instsToExecute
List of instructions that are ready to be executed.
Definition: inst_queue.hh:319
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:443
Impl::DynInstPtr DynInstPtr
Definition: inst_queue.hh:88
void violation(const DynInstPtr &store, const DynInstPtr &faulting_load)
Indicates an ordering violation between a store and a load.
virtual const std::string name() const
Definition: eventq.cc:86
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:484
MemInterface * dcacheInterface
Cache interface.
Definition: inst_queue.hh:287
FU completion event class.
Definition: inst_queue.hh:99
Stats::Scalar iqMemInstsIssued
Stat for number of memory instructions issued.
Definition: inst_queue.hh:492
A vector of scalar stats.
Definition: statistics.hh:2550
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:426
std::list< DynInstPtr > instList[Impl::MaxThreads]
List of all the instructions in the IQ (some of which may be issued).
Definition: inst_queue.hh:316
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:102
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2508
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:451
Stats::Scalar fpInstQueueWrites
Definition: inst_queue.hh:539
Impl::O3CPU O3CPU
Definition: inst_queue.hh:87
Impl::CPUPol::IssueStruct IssueStruct
Definition: inst_queue.hh:92
std::list< DynInstPtr > blockedMemInsts
List of instructions that have been cache blocked.
Definition: inst_queue.hh:327
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:105
bool hasReadyInsts()
Returns if there are any ready instructions in the IQ.
Stats::Scalar intInstQueueWakeupAccesses
Definition: inst_queue.hh:537
Stats::Scalar iqSquashedNonSpecRemoved
Stat for number of non-speculative instructions removed due to a squash.
Definition: inst_queue.hh:505
Pool of FU&#39;s, specific to the new CPU model.
Definition: fu_pool.hh:71
Array of linked list that maintains the dependencies between producing instructions and consuming ins...
Definition: dep_graph.hh:73
A simple distribution stat.
Definition: statistics.hh:2592
TimeBuffer< IssueStruct > * issueToExecuteQueue
The queue to the execute stage.
Definition: inst_queue.hh:300
int wakeDependents(const DynInstPtr &completed_inst)
Wakes all dependents of a completed instruction.
IEW * iewStage
Pointer to IEW stage.
Definition: inst_queue.hh:290
Stats::Scalar intInstQueueWrites
Definition: inst_queue.hh:536
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:354
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:40
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:363
std::list< ListOrderEntry > listOrder
List that contains the age order of the oldest instruction of each ready queue.
Definition: inst_queue.hh:380
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:490
STL list class.
Definition: stl.hh:54
void squash()
Squash the current event.
Definition: eventq.hh:388
virtual const char * description() const
Return a C string describing the event.
unsigned count[Impl::MaxThreads]
Per Thread IQ count.
Definition: inst_queue.hh:417
void takeOverFrom()
Takes over execution from another CPU&#39;s thread.
TimeBuffer< TimeStruct > * timeBuffer
The backwards time buffer.
Definition: inst_queue.hh:303
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:440
Stats::Scalar iqSquashedInstsIssued
Stat for number of squashed instructions that were ready to issue.
Definition: inst_queue.hh:496
Stats::Formula fuBusyRate
Number of times the FU was busy per instruction issued.
Definition: inst_queue.hh:533
std::list< ListOrderEntry >::iterator ListOrderIt
Definition: inst_queue.hh:382
Stats::Scalar vecAluAccesses
Definition: inst_queue.hh:547
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:332
TimeBuffer< TimeStruct >::wire fromCommit
Wire to read information from timebuffer.
Definition: inst_queue.hh:306
A formula for statistics that is calculated when printed.
Definition: statistics.hh:3012
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:227
Stats::Vector2d statIssuedInstType
Stat for total number issued for each instruction type.
Definition: inst_queue.hh:525
SMTQueuePolicy iqPolicy
IQ sharing policy for SMT.
Definition: inst_queue.hh:408
DependencyGraph< DynInstPtr > dependGraph
Definition: inst_queue.hh:401
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:113
Stats::Scalar iqSquashedOperandsExamined
Stat for number of squashed instruction operands examined when squashing.
Definition: inst_queue.hh:502
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:538
Stats::Scalar vecInstQueueWrites
Definition: inst_queue.hh:542
static const OpClass Num_OpClasses
Definition: op_class.hh:107
std::priority_queue< DynInstPtr, std::vector< DynInstPtr >, pqCompare > ReadyInstQueue
Definition: inst_queue.hh:349
Definition: eventq.hh:189
void completeMemInst(const DynInstPtr &completed_inst)
Completes a memory operation.
std::map< InstSeqNum, DynInstPtr >::iterator NonSpecMapIt
Definition: inst_queue.hh:365
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:498
O3CPU * cpu
Pointer to the CPU.
Definition: inst_queue.hh:284
ListOrderIt readyIt[Num_OpClasses]
Iterators of each ready queue.
Definition: inst_queue.hh:390
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:486
Stats::Vector fuBusy
Number of times the FU was busy.
Definition: inst_queue.hh:531
Entry for the list age ordering by op class.
Definition: inst_queue.hh:368
std::list< DynInstPtr >::iterator ListIt
Definition: inst_queue.hh:96
unsigned maxEntries[Impl::MaxThreads]
Max IQ Entries Per Thread.
Definition: inst_queue.hh:420
Stats::Scalar vecInstQueueWakeupAccesses
Definition: inst_queue.hh:543
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:482
void printInsts()
Debug function to print all instructions.
Stats::Formula issueRate
Number of instructions issued per cycle.
Definition: inst_queue.hh:528
unsigned numPhysRegs
The number of physical registers in the CPU.
Definition: inst_queue.hh:432
A 2-Dimensional vecto of scalar stats.
Definition: statistics.hh:2578
Stats::Scalar intInstQueueReads
Definition: inst_queue.hh:535
MemDepUnit memDepUnit[Impl::MaxThreads]
The memory dependence unit, which tracks/predicts memory dependences between instructions.
Definition: inst_queue.hh:295
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:309
std::list< DynInstPtr > deferredMemInsts
List of instructions waiting for their DTB translation to complete (hw page table walk in progress)...
Definition: inst_queue.hh:324
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:108
A standard instruction queue class.
Definition: inst_queue.hh:83
unsigned totalWidth
The total number of instructions that can be issued in one cycle.
Definition: inst_queue.hh:429
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:513
unsigned freeEntries
Number of free IQ entries left.
Definition: inst_queue.hh:423
Stats::Vector statFuBusy
Distribution of the cycles it takes to issue an instruction.
Definition: inst_queue.hh:522
Impl::CPUPol::MemDepUnit MemDepUnit
Definition: inst_queue.hh:91
Impl::CPUPol::TimeStruct TimeStruct
Definition: inst_queue.hh:93
ThreadID numThreads
Number of Total Threads.
Definition: inst_queue.hh:411
void insert(const DynInstPtr &new_inst)
Inserts a new instruction into the IQ.

Generated on Fri Feb 28 2020 16:26:59 for gem5 by doxygen 1.8.13