gem5  v22.1.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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"
50 #include "cpu/o3/dyn_inst_ptr.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 
59 namespace gem5
60 {
61 
62 struct BaseO3CPUParams;
63 
64 namespace o3
65 {
66 
67 class ThreadState;
68 
91 class Commit
92 {
93  public:
98  {
100  Inactive
101  };
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 
144  void setThreads(std::vector<ThreadState *> &threads);
145 
148 
150 
153 
155  void setIEWQueue(TimeBuffer<IEWStruct> *iq_ptr);
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 
200  bool executingHtmTransaction(ThreadID) const;
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 
465  {
481 
506 
509  } stats;
510 };
511 
512 } // namespace o3
513 } // namespace gem5
514 
515 #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:1499
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:600
void squashAll(ThreadID tid)
Squashes all in flight instructions.
Definition: commit.cc:532
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:313
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:475
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:425
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:283
size_t numROBFreeEntries(ThreadID tid)
Returns the number of free ROB entries for a specific thread.
Definition: commit.cc:492
void setFetchQueue(TimeBuffer< FetchStruct > *fq_ptr)
Definition: commit.cc:265
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:274
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:498
void deactivateThread(ThreadID tid)
Deschedules a thread from scheduling.
Definition: commit.cc:414
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:584
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:706
const Cycles fetchToCommitDelay
Definition: commit.hh:388
void propagateInterrupt()
Get fetch redirecting so we can handle an interrupt.
Definition: commit.cc:759
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:310
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:628
void setIEWStage(IEW *iew_stage)
Sets the pointer to the IEW stage.
Definition: commit.cc:292
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:253
void setActiveThreads(std::list< ThreadID > *at_ptr)
Sets pointer to list of active threads.
Definition: commit.cc:298
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
void updateStatus()
Updates the overall status of commit with the nextStatus, and tell the CPU if commit is active/inacti...
Definition: commit.cc:445
void squashAfter(ThreadID tid, const DynInstPtr &head_inst)
Handle squashing from instruction with SquashAfter set.
Definition: commit.cc:617
bool commitHead(const DynInstPtr &head_inst, unsigned inst_num)
Tries to commit the head ROB instruction passed in.
Definition: commit.cc:1143
void resetHtmStartsStops(ThreadID)
Definition: commit.cc:434
void getInsts()
Gets instructions from rename and inserts them into the ROB.
Definition: commit.cc:1329
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:357
void takeOverFrom()
Takes over from another CPU's thread.
Definition: commit.cc:399
void clearStates(ThreadID tid)
Clear all thread-specific states.
Definition: commit.cc:333
void drainResume()
Resumes execution after draining.
Definition: commit.cc:350
CommitStatus
Overall commit status.
Definition: commit.hh:98
const PCStateBase & pcState(ThreadID tid)
Reads the PC of a specific thread.
Definition: commit.hh:309
TimeBuffer< RenameStruct > * renameQueue
Rename instruction queue interface, for ROB.
Definition: commit.hh:335
void drain()
Initializes the draining of commit.
Definition: commit.cc:347
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:944
void markCompletedInsts()
Marks completed instructions using information sent from IEW.
Definition: commit.cc:1362
void setRenameMap(UnifiedRenameMap rm_ptr[MaxThreads])
Sets pointer to the commited state rename map.
Definition: commit.cc:304
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:1472
void generateTCEvent(ThreadID tid)
Records that commit needs to initiate a squash due to an external state update through the TC.
Definition: commit.cc:523
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:247
void updateComInstStats(const DynInstPtr &inst)
Updates commit stats based on this instruction.
Definition: commit.cc:1382
ThreadID getCommittingThread()
Gets the thread to commit, based on the SMT policy.
Definition: commit.cc:1444
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:783
UnifiedRenameMap * renameMap[MaxThreads]
Rename map interface.
Definition: commit.hh:446
void squashFromTrap(ThreadID tid)
Handles squashing due to a trap.
Definition: commit.cc:567
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:372
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.
Definition: rename_map.hh:169
A simple distribution stat.
Definition: statistics.hh:2085
Statistics container.
Definition: group.hh:94
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:1931
A 2-Dimensional vecto of scalar stats.
Definition: statistics.hh:2059
A vector of scalar stats.
Definition: statistics.hh:2007
STL vector class.
Definition: stl.hh:37
Bitfield< 12, 11 > set
Definition: misc_types.hh:709
Bitfield< 63 > val
Definition: misc.hh:776
static constexpr int MaxThreads
Definition: limits.hh:38
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
std::shared_ptr< FaultBase > Fault
Definition: types.hh:248
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:491
statistics::Vector instsCommitted
Total number of instructions committed.
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:508
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:505
statistics::Vector integer
Total number of integer instructions.
Definition: commit.hh:501
statistics::Vector vectorInstructions
Total number of vector instructions.
Definition: commit.hh:497
statistics::Vector branches
Total number of committed branches.
Definition: commit.hh:495
statistics::Vector memRefs
Stat for the total number of committed memory references.
Definition: commit.hh:487
statistics::Vector floating
Total number of floating point instructions.
Definition: commit.hh:499
statistics::Vector loads
Stat for the total number of committed loads.
Definition: commit.hh:489
statistics::Vector functionCalls
Total number of function calls.
Definition: commit.hh:503
statistics::Vector opsCommitted
Total number of ops (including micro ops) committed.
Definition: commit.hh:485
statistics::Vector membars
Total number of committed memory barriers.
Definition: commit.hh:493

Generated on Wed Dec 21 2022 10:22:30 for gem5 by doxygen 1.9.1