gem5  v19.0.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 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  * Authors: Kevin Lim
41  * Korey Sewell
42  */
43 
44 #ifndef __CPU_O3_COMMIT_HH__
45 #define __CPU_O3_COMMIT_HH__
46 
47 #include <queue>
48 
49 #include "base/statistics.hh"
50 #include "cpu/exetrace.hh"
51 #include "cpu/inst_seq.hh"
52 #include "cpu/timebuf.hh"
53 #include "enums/CommitPolicy.hh"
54 #include "sim/probe/probe.hh"
55 
56 struct DerivO3CPUParams;
57 
58 template <class>
60 
83 template<class Impl>
85 {
86  public:
87  // Typedefs from the Impl.
88  typedef typename Impl::O3CPU O3CPU;
89  typedef typename Impl::DynInstPtr DynInstPtr;
90  typedef typename Impl::CPUPol CPUPol;
91 
92  typedef typename CPUPol::RenameMap RenameMap;
93  typedef typename CPUPol::ROB ROB;
94 
95  typedef typename CPUPol::TimeStruct TimeStruct;
96  typedef typename CPUPol::FetchStruct FetchStruct;
97  typedef typename CPUPol::IEWStruct IEWStruct;
98  typedef typename CPUPol::RenameStruct RenameStruct;
99 
100  typedef typename CPUPol::Fetch Fetch;
101  typedef typename CPUPol::IEW IEW;
102 
104 
111  };
112 
120  SquashAfterPending, //< Committing instructions before a squash.
121  };
122 
123  private:
129  ThreadStatus commitStatus[Impl::MaxThreads];
131  CommitPolicy commitPolicy;
132 
138 
140  void processTrapEvent(ThreadID tid);
141 
142  public:
144  DefaultCommit(O3CPU *_cpu, DerivO3CPUParams *params);
145 
147  std::string name() const;
148 
150  void regStats();
151 
153  void regProbePoints();
154 
156  void setThreads(std::vector<Thread *> &threads);
157 
160 
162 
165 
167  void setIEWQueue(TimeBuffer<IEWStruct> *iq_ptr);
168 
170  void setIEWStage(IEW *iew_stage);
171 
176  IEW *iewStage;
177 
180 
182  void setRenameMap(RenameMap rm_ptr[Impl::MaxThreads]);
183 
185  void setROB(ROB *rob_ptr);
186 
188  void startupStage();
189 
191  void clearStates(ThreadID tid);
192 
194  void drain();
195 
197  void drainResume();
198 
200  void drainSanityCheck() const;
201 
203  bool isDrained() const;
204 
206  void takeOverFrom();
207 
209  void deactivateThread(ThreadID tid);
210 
212  void tick();
213 
217  void commit();
218 
220  size_t numROBFreeEntries(ThreadID tid);
221 
223  void generateTrapEvent(ThreadID tid, Fault inst_fault);
224 
228  void generateTCEvent(ThreadID tid);
229 
230  private:
234  void updateStatus();
235 
240  bool changedROBEntries();
241 
243  void squashAll(ThreadID tid);
244 
246  void squashFromTrap(ThreadID tid);
247 
249  void squashFromTC(ThreadID tid);
250 
253 
282  void squashAfter(ThreadID tid, const DynInstPtr &head_inst);
283 
285  void handleInterrupt();
286 
288  void propagateInterrupt();
289 
291  void commitInsts();
292 
296  bool commitHead(const DynInstPtr &head_inst, unsigned inst_num);
297 
299  void getInsts();
300 
302  void markCompletedInsts();
303 
306 
309 
312 
313  public:
315  TheISA::PCState pcState(ThreadID tid) { return pc[tid]; }
316 
319  { pc[tid] = val; }
320 
322  Addr instAddr(ThreadID tid) { return pc[tid].instAddr(); }
323 
325  Addr nextInstAddr(ThreadID tid) { return pc[tid].nextInstAddr(); }
326 
328  Addr microPC(ThreadID tid) { return pc[tid].microPC(); }
329 
330  private:
333 
336 
339 
341 
343 
346 
349 
352 
355 
356  public:
358  ROB *rob;
359 
360  private:
362  O3CPU *cpu;
363 
366 
371 
375  bool changedROBNumEntries[Impl::MaxThreads];
376 
378  bool trapSquash[Impl::MaxThreads];
379 
381  bool tcSquash[Impl::MaxThreads];
382 
390  DynInstPtr squashAfterInst[Impl::MaxThreads];
391 
394 
397 
400 
403 
405 
409  const unsigned renameWidth;
410 
412  const unsigned commitWidth;
413 
415  unsigned numRobs;
416 
419 
424 
431 
436 
439 
443  TheISA::PCState pc[Impl::MaxThreads];
444 
446  InstSeqNum youngestSeqNum[Impl::MaxThreads];
447 
449  InstSeqNum lastCommitedSeqNum[Impl::MaxThreads];
450 
452  bool trapInFlight[Impl::MaxThreads];
453 
455  bool committedStores[Impl::MaxThreads];
456 
459  bool checkEmptyROB[Impl::MaxThreads];
460 
463 
465  RenameMap *renameMap[Impl::MaxThreads];
466 
469 
475 
477  void updateComInstStats(const DynInstPtr &inst);
478 
490 
517 
520 };
521 
522 #endif // __CPU_O3_COMMIT_HH__
ROB * rob
ROB interface.
Definition: commit.hh:358
const unsigned commitWidth
Commit width, in instructions.
Definition: commit.hh:412
void handleInterrupt()
Handles processing an interrupt.
Definition: commit_impl.hh:736
void regProbePoints()
Registers probes.
Definition: commit_impl.hh:141
const Cycles fetchToCommitDelay
Definition: commit.hh:404
void processTrapEvent(ThreadID tid)
Mark the thread as processing a trap.
Definition: commit_impl.hh:76
Cycles is a wrapper class for representing cycle counts, i.e.
Definition: types.hh:83
void setRenameMap(RenameMap rm_ptr[Impl::MaxThreads])
Sets pointer to the commited state rename map.
Definition: commit_impl.hh:340
Stats::Scalar commitEligibleSamples
Number of cycles where the commit bandwidth limit is reached.
Definition: commit.hh:519
bool trapInFlight[Impl::MaxThreads]
Records if there is a trap currently in flight.
Definition: commit.hh:452
Class that has various thread state, such as the status, the current instruction being processed...
Definition: commit.hh:59
TimeBuffer< TimeStruct >::wire toIEW
Wire to write information heading to previous stages.
Definition: commit.hh:335
TheISA::PCState pc[Impl::MaxThreads]
The commit PC state of each thread.
Definition: commit.hh:443
bool drainImminent
Is a drain imminent? Commit has found an instruction boundary while no interrupts were present or in ...
Definition: commit.hh:430
TimeBuffer< FetchStruct >::wire fromFetch
Definition: commit.hh:342
void squashFromTC(ThreadID tid)
Handles squashing due to an TC write.
Definition: commit_impl.hh:610
Addr instAddr(ThreadID tid)
Returns the PC of a specific thread.
Definition: commit.hh:322
const Cycles renameToROBDelay
Rename to ROB delay.
Definition: commit.hh:402
Stats::Vector statComBranches
Total number of committed branches.
Definition: commit.hh:506
Stats::Vector statComSwp
Total number of software prefetches committed.
Definition: commit.hh:496
bool commitHead(const DynInstPtr &head_inst, unsigned inst_num)
Tries to commit the head ROB instruction passed in.
CPUPol::RenameMap RenameMap
Definition: commit.hh:92
TimeBuffer< FetchStruct > * fetchQueue
Definition: commit.hh:340
const Cycles commitToIEWDelay
Commit to IEW delay.
Definition: commit.hh:399
Stats::Vector statComRefs
Stat for the total number of committed memory references.
Definition: commit.hh:498
CommitStatus
Overall commit status.
Definition: commit.hh:108
void squashFromSquashAfter(ThreadID tid)
Handles a squash from a squashAfter() request.
Definition: commit_impl.hh:627
TimeBuffer< TimeStruct >::wire robInfoFromIEW
Wire to read information from IEW (for ROB).
Definition: commit.hh:338
void setActiveThreads(std::list< ThreadID > *at_ptr)
Sets pointer to list of active threads.
Definition: commit_impl.hh:333
void setTimeBuffer(TimeBuffer< TimeStruct > *tb_ptr)
Sets the main time buffer pointer, used for backwards communication.
Definition: commit_impl.hh:283
IEW * iewStage
The pointer to the IEW stage.
Definition: commit.hh:176
A vector of scalar stats.
Definition: statistics.hh:2550
bool tcSquash[Impl::MaxThreads]
Records if a thread has to squash this cycle due to an XC write.
Definition: commit.hh:381
void updateStatus()
Updates the overall status of commit with the nextStatus, and tell the CPU if commit is active/inacti...
Definition: commit_impl.hh:472
Stats::Vector2d statCommittedInstType
Committed instructions by instruction type (OpClass)
Definition: commit.hh:516
void getInsts()
Gets instructions from rename and inserts them into the ROB.
CPUPol::RenameStruct RenameStruct
Definition: commit.hh:98
void setRenameQueue(TimeBuffer< RenameStruct > *rq_ptr)
Sets the pointer to the queue coming from rename.
Definition: commit_impl.hh:306
bool avoidQuiesceLiveLock
Have we had an interrupt pending and then seen it de-asserted because of a masking change...
Definition: commit.hh:474
DefaultCommit(O3CPU *_cpu, DerivO3CPUParams *params)
Construct a DefaultCommit with the given parameters.
Definition: commit_impl.hh:84
Stats::Vector statComLoads
Stat for the total number of committed loads.
Definition: commit.hh:500
Declaration of Statistics objects.
void tick()
Ticks the commit stage, which tries to commit instructions.
Definition: commit_impl.hh:657
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2508
STL vector class.
Definition: stl.hh:40
std::list< ThreadID > * activeThreads
Pointer to the list of active threads.
Definition: commit.hh:462
RenameMap * renameMap[Impl::MaxThreads]
Rename map interface.
Definition: commit.hh:465
Bitfield< 63 > val
Definition: misc.hh:771
ThreadID roundRobin()
Returns the thread ID to use based on a round robin policy.
void commitInsts()
Commits as many instructions as possible.
Definition: commit_impl.hh:978
TimeBuffer< RenameStruct > * renameQueue
Rename instruction queue interface, for ROB.
Definition: commit.hh:351
CPUPol::FetchStruct FetchStruct
Definition: commit.hh:96
bool isDrained() const
Has the stage drained?
Definition: commit_impl.hh:415
DefaultCommit handles single threaded and SMT commit.
Definition: commit.hh:84
void setIEWStage(IEW *iew_stage)
Sets the pointer to the IEW stage.
Definition: commit_impl.hh:326
CPUPol::IEW IEW
Definition: commit.hh:101
void drainResume()
Resumes execution after draining.
Definition: commit_impl.hh:399
void propagateInterrupt()
Get fetch redirecting so we can handle an interrupt.
Definition: commit_impl.hh:790
Stats::Vector opsCommitted
Total number of ops (including micro ops) committed.
Definition: commit.hh:494
void generateTrapEvent(ThreadID tid, Fault inst_fault)
Generates an event to schedule a squash due to a trap.
Definition: commit_impl.hh:528
Stats::Vector statComFloating
Total number of floating point instructions.
Definition: commit.hh:510
const Cycles trapLatency
The latency to handle a trap.
Definition: commit.hh:435
Addr microPC(ThreadID tid)
Reads the micro PC of a specific thread.
Definition: commit.hh:328
void setFetchQueue(TimeBuffer< FetchStruct > *fq_ptr)
Definition: commit_impl.hh:296
void squashFromTrap(ThreadID tid)
Handles squashing due to a trap.
Definition: commit_impl.hh:592
const unsigned renameWidth
Rename width, in instructions.
Definition: commit.hh:409
TheISA::PCState pcState(ThreadID tid)
Reads the PC of a specific thread.
Definition: commit.hh:315
Stats::Vector statComAmos
Stat for the total number of committed atomics.
Definition: commit.hh:502
Stats::Scalar branchMispredicts
Stat for the total number of branch mispredicts that caused a squash.
Definition: commit.hh:487
ThreadID oldestReady()
Returns the thread ID to use based on an oldest instruction policy.
Impl::O3CPU O3CPU
Definition: commit.hh:88
unsigned numRobs
Number of Reorder Buffers.
Definition: commit.hh:415
Stats::Vector statComMembars
Total number of committed memory barriers.
Definition: commit.hh:504
Impl::CPUPol CPUPol
Definition: commit.hh:90
TimeBuffer< IEWStruct >::wire fromIEW
Wire to read information from IEW queue.
Definition: commit.hh:348
A simple distribution stat.
Definition: statistics.hh:2592
ThreadStatus commitStatus[Impl::MaxThreads]
Per-thread status.
Definition: commit.hh:129
Stats::Distribution numCommittedDist
Distribution of the number of committed instructions each cycle.
Definition: commit.hh:489
O3ThreadState< Impl > Thread
Definition: commit.hh:103
CPUPol::IEWStruct IEWStruct
Definition: commit.hh:97
void squashAll(ThreadID tid)
Squashes all in flight instructions.
Definition: commit_impl.hh:556
void generateTCEvent(ThreadID tid)
Records that commit needs to initiate a squash due to an external state update through the TC...
Definition: commit_impl.hh:546
O3CPU * cpu
Pointer to O3CPU.
Definition: commit.hh:362
uint64_t InstSeqNum
Definition: inst_seq.hh:40
void regStats()
Registers statistics.
Definition: commit_impl.hh:150
ProbePointArg< DynInstPtr > * ppCommit
Probe Points.
Definition: commit.hh:134
void deactivateThread(ThreadID tid)
Deschedules a thread from scheduling.
Definition: commit_impl.hh:459
void setROB(ROB *rob_ptr)
Sets pointer to the ROB.
Definition: commit_impl.hh:348
bool checkEmptyROB[Impl::MaxThreads]
Records if commit should check if the ROB is truly empty (see commit_impl.hh).
Definition: commit.hh:459
Fault interrupt
The interrupt fault.
Definition: commit.hh:438
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
void takeOverFrom()
Takes over from another CPU&#39;s thread.
Definition: commit_impl.hh:443
void updateComInstStats(const DynInstPtr &inst)
Updates commit stats based on this instruction.
ProbePointArg< DynInstPtr > * ppSquash
To probe when an instruction is squashed.
Definition: commit.hh:137
ThreadStatus
Individual thread status.
Definition: commit.hh:114
const Cycles iewToCommitDelay
IEW to Commit delay.
Definition: commit.hh:396
bool changedROBEntries()
Returns if any of the threads have the number of ROB entries changed on this cycle.
Definition: commit_impl.hh:503
bool drainPending
Is a drain pending? Commit is looking for an instruction boundary while there are no pending interrup...
Definition: commit.hh:423
CommitPolicy commitPolicy
Commit policy used in SMT mode.
Definition: commit.hh:131
CPUPol::TimeStruct TimeStruct
Definition: commit.hh:95
TimeBuffer< TimeStruct > * timeBuffer
Time buffer interface.
Definition: commit.hh:332
void drain()
Initializes the draining of commit.
Definition: commit_impl.hh:392
size_t numROBFreeEntries(ThreadID tid)
Returns the number of free ROB entries for a specific thread.
Definition: commit_impl.hh:521
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:227
InstSeqNum lastCommitedSeqNum[Impl::MaxThreads]
The sequence number of the last commited instruction.
Definition: commit.hh:449
void drainSanityCheck() const
Perform sanity checks after a drain.
Definition: commit_impl.hh:407
void pcState(const TheISA::PCState &val, ThreadID tid)
Sets the PC of a specific thread.
Definition: commit.hh:318
std::list< ThreadID > priority_list
Priority List used for Commit Policy.
Definition: commit.hh:393
Stats::Vector statComVector
Total number of vector instructions.
Definition: commit.hh:508
bool trapSquash[Impl::MaxThreads]
Records if a thread has to squash this cycle due to a trap.
Definition: commit.hh:378
void commit()
Handles any squashes that are sent from IEW, and adds instructions to the ROB and tries to commit ins...
Definition: commit_impl.hh:815
InstSeqNum youngestSeqNum[Impl::MaxThreads]
The sequence number of the youngest valid instruction in the ROB.
Definition: commit.hh:446
GenericISA::SimplePCState< MachInst > PCState
Definition: types.hh:43
Stats::Scalar commitNonSpecStalls
Stat for the total number of times commit has had to stall due to a non- speculative instruction reac...
Definition: commit.hh:485
const ThreadID numThreads
Number of Active Threads.
Definition: commit.hh:418
ThreadID getCommittingThread()
Gets the thread to commit, based on the SMT policy.
void squashAfter(ThreadID tid, const DynInstPtr &head_inst)
Handle squashing from instruction with SquashAfter set.
Definition: commit_impl.hh:645
CPUPol::ROB ROB
Definition: commit.hh:93
void setIEWQueue(TimeBuffer< IEWStruct > *iq_ptr)
Sets the pointer to the queue coming from IEW.
Definition: commit_impl.hh:316
Stats::Vector instsCommitted
Total number of instructions committed.
Definition: commit.hh:492
TimeBuffer< RenameStruct >::wire fromRename
Wire to read information from rename queue.
Definition: commit.hh:354
bool committedStores[Impl::MaxThreads]
Records if there were any stores committed this cycle.
Definition: commit.hh:455
Stats::Scalar commitSquashedInsts
Stat for the total number of squashed instructions discarded by commit.
Definition: commit.hh:481
TimeBuffer< IEWStruct > * iewQueue
IEW instruction queue interface.
Definition: commit.hh:345
A 2-Dimensional vecto of scalar stats.
Definition: statistics.hh:2578
DynInstPtr squashAfterInst[Impl::MaxThreads]
Instruction passed to squashAfter().
Definition: commit.hh:390
CommitStatus _nextStatus
Next commit status, to be set at the end of the cycle.
Definition: commit.hh:127
bool wroteToTimeBuffer
Records that commit has written to the time buffer this cycle.
Definition: commit.hh:370
Addr nextInstAddr(ThreadID tid)
Returns the next PC of a specific thread.
Definition: commit.hh:325
Impl::DynInstPtr DynInstPtr
Definition: commit.hh:89
Stats::Vector statComFunctionCalls
Total number of function calls.
Definition: commit.hh:514
std::shared_ptr< FaultBase > Fault
Definition: types.hh:240
std::string name() const
Returns the name of the DefaultCommit.
Definition: commit_impl.hh:134
Stats::Vector statComInteger
Total number of integer instructions.
Definition: commit.hh:512
void clearStates(ThreadID tid)
Clear all thread-specific states.
Definition: commit_impl.hh:376
CommitStatus _status
Overall commit status.
Definition: commit.hh:125
bool canHandleInterrupts
True if last committed microop can be followed by an interrupt.
Definition: commit.hh:468
void startupStage()
Initializes stage by sending back the number of free entries.
Definition: commit_impl.hh:355
void setThreads(std::vector< Thread *> &threads)
Sets the list of threads.
Definition: commit_impl.hh:276
bool changedROBNumEntries[Impl::MaxThreads]
Records if the number of ROB entries has changed this cycle.
Definition: commit.hh:375
ProbePointArg< DynInstPtr > * ppCommitStall
Definition: commit.hh:135
std::vector< Thread * > thread
Vector of all of the threads.
Definition: commit.hh:365
CPUPol::Fetch Fetch
Definition: commit.hh:100
void markCompletedInsts()
Marks completed instructions using information sent from IEW.

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