gem5 v24.0.0.0
Loading...
Searching...
No Matches
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/inst_seq.hh"
53#include "cpu/o3/comm.hh"
54#include "cpu/o3/dep_graph.hh"
56#include "cpu/o3/limits.hh"
58#include "cpu/o3/store_set.hh"
59#include "cpu/op_class.hh"
60#include "cpu/timebuf.hh"
61#include "enums/SMTQueuePolicy.hh"
62#include "sim/eventq.hh"
63
64namespace gem5
65{
66
67struct BaseO3CPUParams;
68
69namespace memory
70{
71class MemInterface;
72} // namespace memory
73
74namespace o3
75{
76
77class FUPool;
78class CPU;
79class IEW;
80
99{
100 public:
101 // Typedef of iterator through the list of instructions.
103
105 class FUCompletion : public Event
106 {
107 private:
110
112 int fuIdx;
113
116
120 bool freeFU;
121
122 public:
124 FUCompletion(const DynInstPtr &_inst, int fu_idx,
125 InstructionQueue *iq_ptr);
126
127 virtual void process();
128 virtual const char *description() const;
129 void setFreeFU() { freeFU = true; }
130 };
131
133 InstructionQueue(CPU *cpu_ptr, IEW *iew_ptr,
134 const BaseO3CPUParams &params);
135
138
140 std::string name() const;
141
143 void resetState();
144
147
150
153
155 bool isDrained() const;
156
158 void drainSanityCheck() const;
159
161 void takeOverFrom();
162
164 int entryAmount(ThreadID num_threads);
165
167 void resetEntries();
168
170 unsigned numFreeEntries();
171
173 unsigned numFreeEntries(ThreadID tid);
174
176 bool isFull();
177
179 bool isFull(ThreadID tid);
180
182 bool hasReadyInsts();
183
185 void insert(const DynInstPtr &new_inst);
186
188 void insertNonSpec(const DynInstPtr &new_inst);
189
193 void insertBarrier(const DynInstPtr &barr_inst);
194
199
204
209
214 void
216 {
217 addToProducers(inst);
218 }
219
221 void processFUCompletion(const DynInstPtr &inst, int fu_idx);
222
227 void scheduleReadyInsts();
228
230 void scheduleNonSpec(const InstSeqNum &inst);
231
236 void commit(const InstSeqNum &inst, ThreadID tid = 0);
237
239 int wakeDependents(const DynInstPtr &completed_inst);
240
242 void addReadyMemInst(const DynInstPtr &ready_inst);
243
248 void rescheduleMemInst(const DynInstPtr &resched_inst);
249
251 void replayMemInst(const DynInstPtr &replay_inst);
252
257 void deferMemInst(const DynInstPtr &deferred_inst);
258
260 void blockMemInst(const DynInstPtr &blocked_inst);
261
263 void cacheUnblocked();
264
266 void violation(const DynInstPtr &store, const DynInstPtr &faulting_load);
267
272 void squash(ThreadID tid);
273
275 unsigned getCount(ThreadID tid) { return count[tid]; };
276
279
280 private:
282 void doSquash(ThreadID tid);
283
285 // Various pointers
287
290
293
296
301
306
309
312
315
317 // Instruction lists, ready queues, and ordering
319
322
325
330
333
338
347 {
348 bool operator()(const DynInstPtr &lhs, const DynInstPtr &rhs) const;
349 };
350
351 typedef std::priority_queue<
353
358
366 std::map<InstSeqNum, DynInstPtr> nonSpecInsts;
367
368 typedef std::map<InstSeqNum, DynInstPtr>::iterator NonSpecMapIt;
369
376
385
387
390
395
397 void addToOrderList(OpClass op_class);
398
403 void moveToYoungerInst(ListOrderIt age_order_it);
404
406
408 // Various parameters
410
412 SMTQueuePolicy iqPolicy;
413
416
419
421 unsigned count[MaxThreads];
422
425
427 unsigned freeEntries;
428
430 unsigned numEntries;
431
433 unsigned totalWidth;
434
436 unsigned numPhysRegs;
437
440
445
448
456
458 bool addToDependents(const DynInstPtr &new_inst);
459
461 void addToProducers(const DynInstPtr &new_inst);
462
464 void addIfReady(const DynInstPtr &inst);
465
470 int countInsts();
471
476 void dumpLists();
477
481 void dumpInsts();
482
545
546 public:
564};
565
566} // namespace o3
567} // namespace gem5
568
569#endif //__CPU_O3_INST_QUEUE_HH__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
Cycles is a wrapper class for representing cycle counts, i.e.
Definition types.hh:79
General interface to memory device Includes functions and parameters shared across media types.
O3CPU class, has each of the stages (fetch through commit) within it, as well as all of the time buff...
Definition cpu.hh:94
Array of linked list that maintains the dependencies between producing instructions and consuming ins...
Definition dep_graph.hh:78
Pool of FU's, specific to the new CPU model.
Definition fu_pool.hh:76
IEW handles both single threaded and SMT IEW (issue/execute/writeback).
Definition iew.hh:88
bool freeFU
Should the FU be added to the list to be freed upon completing this event.
FUCompletion(const DynInstPtr &_inst, int fu_idx, InstructionQueue *iq_ptr)
Construct a FU completion event.
Definition inst_queue.cc:66
DynInstPtr inst
Executing instruction.
int fuIdx
Index of the FU used for executing.
InstructionQueue * iqPtr
Pointer back to the instruction queue.
virtual const char * description() const
Return a C string describing the event.
Definition inst_queue.cc:82
A standard instruction queue class.
Definition inst_queue.hh:99
std::string name() const
Returns the name of the IQ.
void commit(const InstSeqNum &inst, ThreadID tid=0)
Commits all instructions up to and including the given sequence number, for a specific thread.
gem5::o3::InstructionQueue::IQStats iqStats
std::priority_queue< DynInstPtr, std::vector< DynInstPtr >, PqCompare > ReadyInstQueue
void processFUCompletion(const DynInstPtr &inst, int fu_idx)
Process FU completion event.
DynInstPtr getBlockedMemInstToExecute()
Gets a memory instruction that was blocked on the cache.
std::list< DynInstPtr > instList[MaxThreads]
List of all the instructions in the IQ (some of which may be issued).
memory::MemInterface * dcacheInterface
Cache interface.
std::list< DynInstPtr > retryMemInsts
List of instructions that were cache blocked, but a retry has been seen since, so they can now be ret...
void deferMemInst(const DynInstPtr &deferred_inst)
Defers a memory instruction when its DTB translation incurs a hw page table walk.
ReadyInstQueue readyInsts[Num_OpClasses]
List of ready instructions, per op class.
unsigned totalWidth
The total number of instructions that can be issued in one cycle.
void addIfReady(const DynInstPtr &inst)
Moves an instruction to the ready queue if it is ready.
unsigned numEntries
The number of entries in the instruction queue.
void insertBarrier(const DynInstPtr &barr_inst)
Inserts a memory or write barrier into the IQ to make sure loads and stores are ordered properly.
bool queueOnList[Num_OpClasses]
Tracks if each ready queue is on the age order list.
FUPool * fuPool
Function unit pool.
int wakeDependents(const DynInstPtr &completed_inst)
Wakes all dependents of a completed instruction.
std::list< DynInstPtr > deferredMemInsts
List of instructions waiting for their DTB translation to complete (hw page table walk in progress).
TimeBuffer< IssueStruct > * issueToExecuteQueue
The queue to the execute stage.
std::list< DynInstPtr > instsToExecute
List of instructions that are ready to be executed.
void setTimeBuffer(TimeBuffer< TimeStruct > *tb_ptr)
Sets the global time buffer.
unsigned numFreeEntries()
Returns total number of free entries.
std::list< DynInstPtr > blockedMemInsts
List of instructions that have been cache blocked.
void rescheduleMemInst(const DynInstPtr &resched_inst)
Reschedules a memory instruction.
TimeBuffer< TimeStruct >::wire fromCommit
Wire to read information from timebuffer.
void insertNonSpec(const DynInstPtr &new_inst)
Inserts a new, non-speculative instruction into the IQ.
void addReadyMemInst(const DynInstPtr &ready_inst)
Adds a ready memory instruction to the ready list.
unsigned getCount(ThreadID tid)
Returns the number of used entries for a thread.
void replayMemInst(const DynInstPtr &replay_inst)
Replays a memory instruction.
void resetState()
Resets all instruction queue state.
void recordProducer(const DynInstPtr &inst)
Records the instruction as the producer of a register without adding it to the rest of the IQ.
bool isDrained() const
Determine if we are drained.
unsigned count[MaxThreads]
Per Thread IQ count.
void cacheUnblocked()
Notify instruction queue that a previous blockage has resolved.
std::map< InstSeqNum, DynInstPtr > nonSpecInsts
List of non-speculative instructions that will be scheduled once the IQ gets a signal from commit.
unsigned freeEntries
Number of free IQ entries left.
MemDepUnit memDepUnit[MaxThreads]
The memory dependence unit, which tracks/predicts memory dependences between instructions.
void dumpLists()
Debugging function to dump all the list sizes, as well as print out the list of nonspeculative instru...
void blockMemInst(const DynInstPtr &blocked_inst)
Defers a memory instruction when it is cache blocked.
void drainSanityCheck() const
Perform sanity checks after a drain.
unsigned numPhysRegs
The number of physical registers in the CPU.
DynInstPtr getDeferredMemInstToExecute()
Gets a memory instruction that was referred due to a delayed DTB translation if it is now ready to ex...
void dumpInsts()
Debugging function to dump out all instructions that are in the IQ.
void takeOverFrom()
Takes over execution from another CPU's thread.
SMTQueuePolicy iqPolicy
IQ sharing policy for SMT.
gem5::o3::InstructionQueue::IQIOStats iqIOStats
void moveToYoungerInst(ListOrderIt age_order_it)
Called when the oldest instruction has been removed from a ready queue; this places that ready queue ...
InstructionQueue(CPU *cpu_ptr, IEW *iew_ptr, const BaseO3CPUParams &params)
Constructs an IQ.
Definition inst_queue.cc:87
InstSeqNum squashedSeqNum[MaxThreads]
The sequence number of the squashed instruction.
void violation(const DynInstPtr &store, const DynInstPtr &faulting_load)
Indicates an ordering violation between a store and a load.
std::list< DynInstPtr >::iterator ListIt
bool hasReadyInsts()
Returns if there are any ready instructions in the IQ.
Cycles commitToIEWDelay
Delay between commit stage and the IQ.
void resetEntries()
Resets max entries for all threads.
int countInsts()
Debugging function to count how many entries are in the IQ.
std::list< ThreadID > * activeThreads
Pointer to list of active threads.
std::list< ListOrderEntry >::iterator ListOrderIt
void setActiveThreads(std::list< ThreadID > *at_ptr)
Sets active threads list.
void addToOrderList(OpClass op_class)
Add an op class to the age order list.
ThreadID numThreads
Number of Total Threads.
TimeBuffer< TimeStruct > * timeBuffer
The backwards time buffer.
void scheduleNonSpec(const InstSeqNum &inst)
Schedules a single specific non-speculative instruction.
std::vector< bool > regScoreboard
A cache of the recently woken registers.
void scheduleReadyInsts()
Schedules ready instructions, adding the ready ones (oldest first) to the queue to execute.
bool isFull()
Returns whether or not the IQ is full.
void printInsts()
Debug function to print all instructions.
void squash(ThreadID tid)
Squashes instructions for a thread.
IEW * iewStage
Pointer to IEW stage.
std::list< ListOrderEntry > listOrder
List that contains the age order of the oldest instruction of each ready queue.
~InstructionQueue()
Destructs the IQ.
void doSquash(ThreadID tid)
Does the actual squashing.
void setIssueToExecuteQueue(TimeBuffer< IssueStruct > *i2eQueue)
Sets the timer buffer between issue and execute.
int wbOutstanding
Number of instructions currently in flight to FUs.
void insert(const DynInstPtr &new_inst)
Inserts a new instruction into the IQ.
unsigned maxEntries[MaxThreads]
Max IQ Entries Per Thread.
CPU * cpu
Pointer to the CPU.
bool addToDependents(const DynInstPtr &new_inst)
Adds an instruction to the dependency graph, as a consumer.
int entryAmount(ThreadID num_threads)
Number of entries needed for given amount of threads.
DynInstPtr getInstToExecute()
Returns the oldest scheduled instruction, and removes it from the list of instructions waiting to exe...
DependencyGraph< DynInstPtr > dependGraph
ListOrderIt readyIt[Num_OpClasses]
Iterators of each ready queue.
void addToProducers(const DynInstPtr &new_inst)
Adds an instruction to the dependency graph, as a producer.
std::map< InstSeqNum, DynInstPtr >::iterator NonSpecMapIt
Memory dependency unit class.
A simple distribution stat.
A formula for statistics that is calculated when printed.
Statistics container.
Definition group.hh:93
This is a simple scalar statistic, like a counter.
A 2-Dimensional vecto of scalar stats.
A vector of scalar stats.
STL list class.
Definition stl.hh:51
STL vector class.
Definition stl.hh:37
static constexpr int MaxThreads
Definition limits.hh:38
RefCountingPtr< DynInst > DynInstPtr
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
int16_t ThreadID
Thread index/ID type.
Definition types.hh:235
static const OpClass Num_OpClasses
Definition op_class.hh:135
uint64_t InstSeqNum
Definition inst_seq.hh:40
Declaration of Statistics objects.
statistics::Scalar vecInstQueueWakeupAccesses
statistics::Scalar intInstQueueWakeupAccesses
IQIOStats(statistics::Group *parent)
statistics::Scalar fpInstQueueWakeupAccesses
statistics::Vector2d statIssuedInstType
Stat for total number issued for each instruction type.
statistics::Scalar floatInstsIssued
Stat for number of floating point instructions issued.
statistics::Vector fuBusy
Number of times the FU was busy.
statistics::Scalar instsAdded
Stat for number of instructions added.
statistics::Distribution numIssuedDist
Distribution of number of instructions in the queue.
statistics::Scalar nonSpecInstsAdded
Stat for number of non-speculative instructions added.
statistics::Scalar squashedInstsExamined
Stat for number of squashed instructions examined when squashing.
statistics::Scalar miscInstsIssued
Stat for number of miscellaneous instructions issued.
statistics::Scalar branchInstsIssued
Stat for number of branch instructions issued.
statistics::Formula fuBusyRate
Number of times the FU was busy per instruction issued.
statistics::Scalar memInstsIssued
Stat for number of memory instructions issued.
statistics::Scalar intInstsIssued
Stat for number of integer instructions issued.
statistics::Formula issueRate
Number of instructions issued per cycle.
IQStats(CPU *cpu, const unsigned &total_width)
statistics::Scalar squashedOperandsExamined
Stat for number of squashed instruction operands examined when squashing.
statistics::Scalar squashedInstsIssued
Stat for number of squashed instructions that were ready to issue.
statistics::Vector statFuBusy
Distribution of the cycles it takes to issue an instruction.
statistics::Scalar squashedNonSpecRemoved
Stat for number of non-speculative instructions removed due to a squash.
Entry for the list age ordering by op class.
Struct for comparing entries to be added to the priority queue.
bool operator()(const DynInstPtr &lhs, const DynInstPtr &rhs) const
Definition mem.h:38

Generated on Tue Jun 18 2024 16:24:01 for gem5 by doxygen 1.11.0