gem5 v24.0.0.0
Loading...
Searching...
No Matches
commit.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010-2012, 2014, 2019 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
11 * unmodified and in its entirety in all distributions of the software,
12 * modified or unmodified, in source code or in binary form.
13 *
14 * Copyright (c) 2004-2006 The Regents of The University of Michigan
15 * All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions are
19 * met: redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer;
21 * redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution;
24 * neither the name of the copyright holders nor the names of its
25 * contributors may be used to endorse or promote products derived from
26 * this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 */
40
41#ifndef __CPU_O3_COMMIT_HH__
42#define __CPU_O3_COMMIT_HH__
43
44#include <queue>
45
46#include "base/statistics.hh"
47#include "cpu/exetrace.hh"
48#include "cpu/inst_seq.hh"
49#include "cpu/o3/comm.hh"
51#include "cpu/o3/iew.hh"
52#include "cpu/o3/limits.hh"
53#include "cpu/o3/rename_map.hh"
54#include "cpu/o3/rob.hh"
55#include "cpu/timebuf.hh"
56#include "enums/CommitPolicy.hh"
57#include "sim/probe/probe.hh"
58
59namespace gem5
60{
61
62struct BaseO3CPUParams;
63
64namespace o3
65{
66
67class ThreadState;
68
91class Commit
92{
93 public:
102
105 {
111 SquashAfterPending, //< Committing instructions before a squash.
112 };
113
114 private:
122 CommitPolicy commitPolicy;
123
129
131 void processTrapEvent(ThreadID tid);
132
133 public:
135 Commit(CPU *_cpu, const BaseO3CPUParams &params);
136
138 std::string name() const;
139
141 void regProbePoints();
142
145
148
150
153
156
158 void setIEWStage(IEW *iew_stage);
159
165
168
171
173 void setROB(ROB *rob_ptr);
174
176 void startupStage();
177
179 void clearStates(ThreadID tid);
180
182 void drain();
183
185 void drainResume();
186
188 void drainSanityCheck() const;
189
191 bool isDrained() const;
192
194 void takeOverFrom();
195
197 void deactivateThread(ThreadID tid);
198
201
202 /* Reset HTM tracking, e.g. after an abort */
204
206 void tick();
207
211 void commit();
212
214 size_t numROBFreeEntries(ThreadID tid);
215
217 void generateTrapEvent(ThreadID tid, Fault inst_fault);
218
222 void generateTCEvent(ThreadID tid);
223
224 private:
228 void updateStatus();
229
234 bool changedROBEntries();
235
237 void squashAll(ThreadID tid);
238
240 void squashFromTrap(ThreadID tid);
241
243 void squashFromTC(ThreadID tid);
244
247
276 void squashAfter(ThreadID tid, const DynInstPtr &head_inst);
277
279 void handleInterrupt();
280
282 void propagateInterrupt();
283
285 void commitInsts();
286
290 bool commitHead(const DynInstPtr &head_inst, unsigned inst_num);
291
293 void getInsts();
294
296 void markCompletedInsts();
297
300
303
306
307 public:
309 const PCStateBase &pcState(ThreadID tid) { return *pc[tid]; }
310
312 void pcState(const PCStateBase &val, ThreadID tid) { set(pc[tid], val); }
313
314 private:
317
320
323
325
327
330
333
336
339
340 public:
343
344 private:
347
350
355
360
363
366
375
378
381
384
387
389
393 const unsigned renameWidth;
394
396 const unsigned commitWidth;
397
400
405
412
417
420
424 std::unique_ptr<PCStateBase> pc[MaxThreads];
425
428
431
434
437
441
444
447
450
456
458 void updateComInstStats(const DynInstPtr &inst);
459
460 // HTM
463
494};
495
496} // namespace o3
497} // namespace gem5
498
499#endif // __CPU_O3_COMMIT_HH__
Cycles is a wrapper class for representing cycle counts, i.e.
Definition types.hh:79
ProbePointArg generates a point for the class of Arg.
Definition probe.hh:264
O3CPU class, has each of the stages (fetch through commit) within it, as well as all of the time buff...
Definition cpu.hh:94
Commit handles single threaded and SMT commit.
Definition commit.hh:92
ThreadStatus commitStatus[MaxThreads]
Per-thread status.
Definition commit.hh:120
TimeBuffer< IEWStruct >::wire fromIEW
Wire to read information from IEW queue.
Definition commit.hh:332
std::vector< ThreadState * > thread
Vector of all of the threads.
Definition commit.hh:349
ThreadID oldestReady()
Returns the thread ID to use based on an oldest instruction policy.
Definition commit.cc:1476
ProbePointArg< DynInstPtr > * ppCommitStall
Definition commit.hh:126
int htmStops[MaxThreads]
Definition commit.hh:462
void squashFromSquashAfter(ThreadID tid)
Handles a squash from a squashAfter() request.
Definition commit.cc:553
void squashAll(ThreadID tid)
Squashes all in flight instructions.
Definition commit.cc:485
void pcState(const PCStateBase &val, ThreadID tid)
Sets the PC of a specific thread.
Definition commit.hh:312
void startupStage()
Initializes stage by sending back the number of free entries.
Definition commit.cc:266
bool changedROBNumEntries[MaxThreads]
Records if the number of ROB entries has changed this cycle.
Definition commit.hh:359
bool changedROBEntries()
Returns if any of the threads have the number of ROB entries changed on this cycle.
Definition commit.cc:428
DynInstPtr squashAfterInst[MaxThreads]
Instruction passed to squashAfter().
Definition commit.hh:374
bool executingHtmTransaction(ThreadID) const
Is the CPU currently processing a HTM transaction?
Definition commit.cc:378
CommitStatus _status
Overall commit status.
Definition commit.hh:116
gem5::o3::Commit::CommitStats stats
void setIEWQueue(TimeBuffer< IEWStruct > *iq_ptr)
Sets the pointer to the queue coming from IEW.
Definition commit.cc:236
size_t numROBFreeEntries(ThreadID tid)
Returns the number of free ROB entries for a specific thread.
Definition commit.cc:445
void setFetchQueue(TimeBuffer< FetchStruct > *fq_ptr)
Definition commit.cc:218
ROB * rob
ROB interface.
Definition commit.hh:342
void processTrapEvent(ThreadID tid)
Mark the thread as processing a trap.
Definition commit.cc:77
void setRenameQueue(TimeBuffer< RenameStruct > *rq_ptr)
Sets the pointer to the queue coming from rename.
Definition commit.cc:227
bool checkEmptyROB[MaxThreads]
Records if commit should check if the ROB is truly empty (see commit_impl.hh).
Definition commit.hh:440
void generateTrapEvent(ThreadID tid, Fault inst_fault)
Generates an event to schedule a squash due to a trap.
Definition commit.cc:451
void deactivateThread(ThreadID tid)
Deschedules a thread from scheduling.
Definition commit.cc:367
TimeBuffer< TimeStruct >::wire toIEW
Wire to write information heading to previous stages.
Definition commit.hh:319
CPU * cpu
Pointer to O3CPU.
Definition commit.hh:346
void squashFromTC(ThreadID tid)
Handles squashing due to an TC write.
Definition commit.cc:537
ThreadStatus
Individual thread status.
Definition commit.hh:105
const ThreadID numThreads
Number of Active Threads.
Definition commit.hh:399
ProbePointArg< DynInstPtr > * ppSquash
To probe when an instruction is squashed.
Definition commit.hh:128
Commit(CPU *_cpu, const BaseO3CPUParams &params)
Construct a Commit with the given parameters.
Definition commit.cc:84
bool trapInFlight[MaxThreads]
Records if there is a trap currently in flight.
Definition commit.hh:433
void handleInterrupt()
Handles processing an interrupt.
Definition commit.cc:659
const Cycles fetchToCommitDelay
Definition commit.hh:388
void propagateInterrupt()
Get fetch redirecting so we can handle an interrupt.
Definition commit.cc:712
std::string name() const
Returns the name of the Commit.
Definition commit.cc:135
TimeBuffer< FetchStruct > * fetchQueue
Definition commit.hh:324
void setROB(ROB *rob_ptr)
Sets pointer to the ROB.
Definition commit.cc:263
int htmStarts[MaxThreads]
Definition commit.hh:461
CommitPolicy commitPolicy
Commit policy used in SMT mode.
Definition commit.hh:122
TimeBuffer< TimeStruct >::wire robInfoFromIEW
Wire to read information from IEW (for ROB).
Definition commit.hh:322
void tick()
Ticks the commit stage, which tries to commit instructions.
Definition commit.cc:581
void setIEWStage(IEW *iew_stage)
Sets the pointer to the IEW stage.
Definition commit.cc:245
const unsigned renameWidth
Rename width, in instructions.
Definition commit.hh:393
bool drainPending
Is a drain pending? Commit is looking for an instruction boundary while there are no pending interrup...
Definition commit.hh:404
const Cycles trapLatency
The latency to handle a trap.
Definition commit.hh:416
ProbePointArg< DynInstPtr > * ppCommit
Probe Points.
Definition commit.hh:125
bool wroteToTimeBuffer
Records that commit has written to the time buffer this cycle.
Definition commit.hh:354
TimeBuffer< IEWStruct > * iewQueue
IEW instruction queue interface.
Definition commit.hh:329
void setTimeBuffer(TimeBuffer< TimeStruct > *tb_ptr)
Sets the main time buffer pointer, used for backwards communication.
Definition commit.cc:206
void setActiveThreads(std::list< ThreadID > *at_ptr)
Sets pointer to list of active threads.
Definition commit.cc:251
const Cycles renameToROBDelay
Rename to ROB delay.
Definition commit.hh:386
std::list< ThreadID > * activeThreads
Pointer to the list of active threads.
Definition commit.hh:443
const PCStateBase & pcState(ThreadID tid)
Reads the PC of a specific thread.
Definition commit.hh:309
void updateStatus()
Updates the overall status of commit with the nextStatus, and tell the CPU if commit is active/inacti...
Definition commit.cc:398
void squashAfter(ThreadID tid, const DynInstPtr &head_inst)
Handle squashing from instruction with SquashAfter set.
Definition commit.cc:570
bool commitHead(const DynInstPtr &head_inst, unsigned inst_num)
Tries to commit the head ROB instruction passed in.
Definition commit.cc:1098
void resetHtmStartsStops(ThreadID)
Definition commit.cc:387
void getInsts()
Gets instructions from rename and inserts them into the ROB.
Definition commit.cc:1284
bool tcSquash[MaxThreads]
Records if a thread has to squash this cycle due to an XC write.
Definition commit.hh:365
const Cycles commitToIEWDelay
Commit to IEW delay.
Definition commit.hh:383
void drainSanityCheck() const
Perform sanity checks after a drain.
Definition commit.cc:310
void takeOverFrom()
Takes over from another CPU's thread.
Definition commit.cc:352
void clearStates(ThreadID tid)
Clear all thread-specific states.
Definition commit.cc:286
void drainResume()
Resumes execution after draining.
Definition commit.cc:303
CommitStatus
Overall commit status.
Definition commit.hh:98
TimeBuffer< RenameStruct > * renameQueue
Rename instruction queue interface, for ROB.
Definition commit.hh:335
void drain()
Initializes the draining of commit.
Definition commit.cc:300
bool trapSquash[MaxThreads]
Records if a thread has to squash this cycle due to a trap.
Definition commit.hh:362
InstSeqNum youngestSeqNum[MaxThreads]
The sequence number of the youngest valid instruction in the ROB.
Definition commit.hh:427
InstSeqNum lastCommitedSeqNum[MaxThreads]
The sequence number of the last commited instruction.
Definition commit.hh:430
CommitStatus _nextStatus
Next commit status, to be set at the end of the cycle.
Definition commit.hh:118
bool drainImminent
Is a drain imminent? Commit has found an instruction boundary while no interrupts were present or in ...
Definition commit.hh:411
void commitInsts()
Commits as many instructions as possible.
Definition commit.cc:897
void markCompletedInsts()
Marks completed instructions using information sent from IEW.
Definition commit.cc:1317
bool canHandleInterrupts
True if last committed microop can be followed by an interrupt.
Definition commit.hh:449
TimeBuffer< TimeStruct > * timeBuffer
Time buffer interface.
Definition commit.hh:316
TimeBuffer< RenameStruct >::wire fromRename
Wire to read information from rename queue.
Definition commit.hh:338
ThreadID roundRobin()
Returns the thread ID to use based on a round robin policy.
Definition commit.cc:1449
void generateTCEvent(ThreadID tid)
Records that commit needs to initiate a squash due to an external state update through the TC.
Definition commit.cc:476
std::unique_ptr< PCStateBase > pc[MaxThreads]
The commit PC state of each thread.
Definition commit.hh:424
void regProbePoints()
Registers probes.
Definition commit.cc:138
IEW * iewStage
The pointer to the IEW stage.
Definition commit.hh:164
void setThreads(std::vector< ThreadState * > &threads)
Sets the list of threads.
Definition commit.cc:200
void updateComInstStats(const DynInstPtr &inst)
Updates commit stats based on this instruction.
Definition commit.cc:1337
ThreadID getCommittingThread()
Gets the thread to commit, based on the SMT policy.
Definition commit.cc:1403
const Cycles iewToCommitDelay
IEW to Commit delay.
Definition commit.hh:380
bool avoidQuiesceLiveLock
Have we had an interrupt pending and then seen it de-asserted because of a masking change?...
Definition commit.hh:455
std::list< ThreadID > priority_list
Priority List used for Commit Policy.
Definition commit.hh:377
void commit()
Handles any squashes that are sent from IEW, and adds instructions to the ROB and tries to commit ins...
Definition commit.cc:736
UnifiedRenameMap * renameMap[MaxThreads]
Rename map interface.
Definition commit.hh:446
void setRenameMap(UnifiedRenameMap::PerThreadUnifiedRenameMap &rm_ptr)
Sets pointer to the commited state rename map.
Definition commit.cc:257
void squashFromTrap(ThreadID tid)
Handles squashing due to a trap.
Definition commit.cc:520
bool committedStores[MaxThreads]
Records if there were any stores committed this cycle.
Definition commit.hh:436
const unsigned commitWidth
Commit width, in instructions.
Definition commit.hh:396
bool isDrained() const
Has the stage drained?
Definition commit.cc:325
Fault interrupt
The interrupt fault.
Definition commit.hh:419
TimeBuffer< FetchStruct >::wire fromFetch
Definition commit.hh:326
IEW handles both single threaded and SMT IEW (issue/execute/writeback).
Definition iew.hh:88
ROB class.
Definition rob.hh:72
Unified register rename map for all classes of registers.
std::array< UnifiedRenameMap, MaxThreads > PerThreadUnifiedRenameMap
A simple distribution stat.
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
Bitfield< 12, 11 > set
Bitfield< 63 > val
Definition misc.hh:804
static constexpr int MaxThreads
Definition limits.hh:38
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
std::shared_ptr< FaultBase > Fault
Definition types.hh:249
int16_t ThreadID
Thread index/ID type.
Definition types.hh:235
uint64_t InstSeqNum
Definition inst_seq.hh:40
Declaration of Statistics objects.
statistics::Vector amos
Stat for the total number of committed atomics.
Definition commit.hh:483
CommitStats(CPU *cpu, Commit *commit)
Definition commit.cc:148
statistics::Distribution numCommittedDist
Distribution of the number of committed instructions each cycle.
Definition commit.hh:480
statistics::Scalar commitNonSpecStalls
Stat for the total number of times commit has had to stall due to a non-speculative instruction reach...
Definition commit.hh:474
statistics::Scalar commitEligibleSamples
Number of cycles where the commit bandwidth limit is reached.
Definition commit.hh:492
statistics::Scalar commitSquashedInsts
Stat for the total number of squashed instructions discarded by commit.
Definition commit.hh:470
statistics::Scalar branchMispredicts
Stat for the total number of branch mispredicts that caused a squash.
Definition commit.hh:478
statistics::Vector2d committedInstType
Committed instructions by instruction type (OpClass)
Definition commit.hh:489
statistics::Vector functionCalls
Total number of function calls.
Definition commit.hh:487
statistics::Vector membars
Total number of committed memory barriers.
Definition commit.hh:485

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