gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 "sim/probe/probe.hh"
54 
55 struct DerivO3CPUParams;
56 
57 template <class>
59 
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  typedef typename Impl::CPUPol CPUPol;
90 
91  typedef typename CPUPol::RenameMap RenameMap;
92  typedef typename CPUPol::ROB ROB;
93 
94  typedef typename CPUPol::TimeStruct TimeStruct;
95  typedef typename CPUPol::FetchStruct FetchStruct;
96  typedef typename CPUPol::IEWStruct IEWStruct;
97  typedef typename CPUPol::RenameStruct RenameStruct;
98 
99  typedef typename CPUPol::Fetch Fetch;
100  typedef typename CPUPol::IEW IEW;
101 
103 
107  class TrapEvent : public Event {
108  private:
111 
112  public:
113  TrapEvent(DefaultCommit<Impl> *_commit, ThreadID _tid);
114 
115  void process();
116  const char *description() const;
117  };
118 
125  };
126 
134  SquashAfterPending, //< Committing instructions before a squash.
135  };
136 
142  };
143 
144  private:
150  ThreadStatus commitStatus[Impl::MaxThreads];
153 
159 
160  public:
162  DefaultCommit(O3CPU *_cpu, DerivO3CPUParams *params);
163 
165  std::string name() const;
166 
168  void regStats();
169 
171  void regProbePoints();
172 
174  void setThreads(std::vector<Thread *> &threads);
175 
178 
180 
183 
185  void setIEWQueue(TimeBuffer<IEWStruct> *iq_ptr);
186 
188  void setIEWStage(IEW *iew_stage);
189 
195 
198 
200  void setRenameMap(RenameMap rm_ptr[Impl::MaxThreads]);
201 
203  void setROB(ROB *rob_ptr);
204 
206  void startupStage();
207 
209  void drain();
210 
212  void drainResume();
213 
215  void drainSanityCheck() const;
216 
218  bool isDrained() const;
219 
221  void takeOverFrom();
222 
224  void deactivateThread(ThreadID tid);
225 
227  void tick();
228 
232  void commit();
233 
235  size_t numROBFreeEntries(ThreadID tid);
236 
238  void generateTrapEvent(ThreadID tid, Fault inst_fault);
239 
243  void generateTCEvent(ThreadID tid);
244 
245  private:
249  void updateStatus();
250 
255  bool changedROBEntries();
256 
258  void squashAll(ThreadID tid);
259 
261  void squashFromTrap(ThreadID tid);
262 
264  void squashFromTC(ThreadID tid);
265 
268 
297  void squashAfter(ThreadID tid, DynInstPtr &head_inst);
298 
300  void handleInterrupt();
301 
303  void propagateInterrupt();
304 
306  void commitInsts();
307 
311  bool commitHead(DynInstPtr &head_inst, unsigned inst_num);
312 
314  void getInsts();
315 
317  void markCompletedInsts();
318 
321 
324 
327 
328  public:
330  TheISA::PCState pcState(ThreadID tid) { return pc[tid]; }
331 
334  { pc[tid] = val; }
335 
337  Addr instAddr(ThreadID tid) { return pc[tid].instAddr(); }
338 
340  Addr nextInstAddr(ThreadID tid) { return pc[tid].nextInstAddr(); }
341 
343  Addr microPC(ThreadID tid) { return pc[tid].microPC(); }
344 
345  private:
348 
351 
354 
356 
358 
361 
364 
367 
370 
371  public:
374 
375  private:
378 
381 
386 
390  bool changedROBNumEntries[Impl::MaxThreads];
391 
393  bool trapSquash[Impl::MaxThreads];
394 
396  bool tcSquash[Impl::MaxThreads];
397 
405  DynInstPtr squashAfterInst[Impl::MaxThreads];
406 
409 
412 
415 
418 
420 
424  const unsigned renameWidth;
425 
427  const unsigned commitWidth;
428 
430  unsigned numRobs;
431 
434 
439 
446 
451 
454 
458  TheISA::PCState pc[Impl::MaxThreads];
459 
461  InstSeqNum youngestSeqNum[Impl::MaxThreads];
462 
464  InstSeqNum lastCommitedSeqNum[Impl::MaxThreads];
465 
467  bool trapInFlight[Impl::MaxThreads];
468 
470  bool committedStores[Impl::MaxThreads];
471 
474  bool checkEmptyROB[Impl::MaxThreads];
475 
478 
480  RenameMap *renameMap[Impl::MaxThreads];
481 
484 
490 
492  void updateComInstStats(DynInstPtr &inst);
493 
505 
528 
531 };
532 
533 #endif // __CPU_O3_COMMIT_HH__
ROB * rob
ROB interface.
Definition: commit.hh:373
const unsigned commitWidth
Commit width, in instructions.
Definition: commit.hh:427
void handleInterrupt()
Handles processing an interrupt.
Definition: commit_impl.hh:735
void regProbePoints()
Registers probes.
Definition: commit_impl.hh:172
const Cycles fetchToCommitDelay
Definition: commit.hh:419
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:357
Stats::Scalar commitEligibleSamples
Number of cycles where the commit bandwidth limit is reached.
Definition: commit.hh:530
bool trapInFlight[Impl::MaxThreads]
Records if there is a trap currently in flight.
Definition: commit.hh:467
Class that has various thread state, such as the status, the current instruction being processed...
Definition: commit.hh:58
TimeBuffer< TimeStruct >::wire toIEW
Wire to write information heading to previous stages.
Definition: commit.hh:350
TheISA::PCState pc[Impl::MaxThreads]
The commit PC state of each thread.
Definition: commit.hh:458
bool drainImminent
Is a drain imminent? Commit has found an instruction boundary while no interrupts were present or in ...
Definition: commit.hh:445
TimeBuffer< FetchStruct >::wire fromFetch
Definition: commit.hh:357
void squashFromTC(ThreadID tid)
Handles squashing due to an TC write.
Definition: commit_impl.hh:609
Addr instAddr(ThreadID tid)
Returns the PC of a specific thread.
Definition: commit.hh:337
const Cycles renameToROBDelay
Rename to ROB delay.
Definition: commit.hh:417
Stats::Vector statComBranches
Total number of committed branches.
Definition: commit.hh:519
Stats::Vector statComSwp
Total number of software prefetches committed.
Definition: commit.hh:511
CPUPol::RenameMap RenameMap
Definition: commit.hh:91
TimeBuffer< FetchStruct > * fetchQueue
Definition: commit.hh:355
const Cycles commitToIEWDelay
Commit to IEW delay.
Definition: commit.hh:414
Stats::Vector statComRefs
Stat for the total number of committed memory references.
Definition: commit.hh:513
CommitStatus
Overall commit status.
Definition: commit.hh:122
void squashFromSquashAfter(ThreadID tid)
Handles a squash from a squashAfter() request.
Definition: commit_impl.hh:626
TimeBuffer< TimeStruct >::wire robInfoFromIEW
Wire to read information from IEW (for ROB).
Definition: commit.hh:353
void setActiveThreads(std::list< ThreadID > *at_ptr)
Sets pointer to list of active threads.
Definition: commit_impl.hh:350
void setTimeBuffer(TimeBuffer< TimeStruct > *tb_ptr)
Sets the main time buffer pointer, used for backwards communication.
Definition: commit_impl.hh:300
IEW * iewStage
The pointer to the IEW stage.
Definition: commit.hh:194
A vector of scalar stats.
Definition: statistics.hh:2499
bool tcSquash[Impl::MaxThreads]
Records if a thread has to squash this cycle due to an XC write.
Definition: commit.hh:396
void updateStatus()
Updates the overall status of commit with the nextStatus, and tell the CPU if commit is active/inacti...
Definition: commit_impl.hh:473
Stats::Vector2d statCommittedInstType
Committed instructions by instruction type (OpClass)
Definition: commit.hh:527
bool isDrained() const
Has the stage drained?
Definition: commit_impl.hh:416
void getInsts()
Gets instructions from rename and inserts them into the ROB.
CPUPol::RenameStruct RenameStruct
Definition: commit.hh:97
void setRenameQueue(TimeBuffer< RenameStruct > *rq_ptr)
Sets the pointer to the queue coming from rename.
Definition: commit_impl.hh:323
std::string name() const
Returns the name of the DefaultCommit.
Definition: commit_impl.hh:165
bool avoidQuiesceLiveLock
Have we had an interrupt pending and then seen it de-asserted because of a masking change...
Definition: commit.hh:489
DefaultCommit(O3CPU *_cpu, DerivO3CPUParams *params)
Construct a DefaultCommit with the given parameters.
Definition: commit_impl.hh:97
Stats::Vector statComLoads
Stat for the total number of committed loads.
Definition: commit.hh:515
Declaration of Statistics objects.
void tick()
Ticks the commit stage, which tries to commit instructions.
Definition: commit_impl.hh:656
This is a simple scalar statistic, like a counter.
Definition: statistics.hh:2475
STL vector class.
Definition: stl.hh:40
std::list< ThreadID > * activeThreads
Pointer to the list of active threads.
Definition: commit.hh:477
RenameMap * renameMap[Impl::MaxThreads]
Rename map interface.
Definition: commit.hh:480
Bitfield< 63 > val
Definition: misc.hh:770
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:969
TimeBuffer< RenameStruct > * renameQueue
Rename instruction queue interface, for ROB.
Definition: commit.hh:366
CPUPol::FetchStruct FetchStruct
Definition: commit.hh:95
DefaultCommit handles single threaded and SMT commit.
Definition: commit.hh:83
void setIEWStage(IEW *iew_stage)
Sets the pointer to the IEW stage.
Definition: commit_impl.hh:343
CPUPol::IEW IEW
Definition: commit.hh:100
void drainResume()
Resumes execution after draining.
Definition: commit_impl.hh:400
void propagateInterrupt()
Get fetch redirecting so we can handle an interrupt.
Definition: commit_impl.hh:789
Stats::Vector opsCommitted
Total number of ops (including micro ops) committed.
Definition: commit.hh:509
void generateTrapEvent(ThreadID tid, Fault inst_fault)
Generates an event to schedule a squash due to a trap.
Definition: commit_impl.hh:529
Stats::Vector statComFloating
Total number of floating point instructions.
Definition: commit.hh:521
const Cycles trapLatency
The latency to handle a trap.
Definition: commit.hh:450
Addr microPC(ThreadID tid)
Reads the micro PC of a specific thread.
Definition: commit.hh:343
void setFetchQueue(TimeBuffer< FetchStruct > *fq_ptr)
Definition: commit_impl.hh:313
void squashFromTrap(ThreadID tid)
Handles squashing due to a trap.
Definition: commit_impl.hh:591
const unsigned renameWidth
Rename width, in instructions.
Definition: commit.hh:424
TheISA::PCState pcState(ThreadID tid)
Reads the PC of a specific thread.
Definition: commit.hh:330
Stats::Scalar branchMispredicts
Stat for the total number of branch mispredicts that caused a squash.
Definition: commit.hh:502
ThreadID oldestReady()
Returns the thread ID to use based on an oldest instruction policy.
Impl::O3CPU O3CPU
Definition: commit.hh:87
void setThreads(std::vector< Thread * > &threads)
Sets the list of threads.
Definition: commit_impl.hh:293
unsigned numRobs
Number of Reorder Buffers.
Definition: commit.hh:430
Stats::Vector statComMembars
Total number of committed memory barriers.
Definition: commit.hh:517
Impl::CPUPol CPUPol
Definition: commit.hh:89
TimeBuffer< IEWStruct >::wire fromIEW
Wire to read information from IEW queue.
Definition: commit.hh:363
A simple distribution stat.
Definition: statistics.hh:2523
ThreadStatus commitStatus[Impl::MaxThreads]
Per-thread status.
Definition: commit.hh:150
Stats::Distribution numCommittedDist
Distribution of the number of committed instructions each cycle.
Definition: commit.hh:504
O3ThreadState< Impl > Thread
Definition: commit.hh:102
CPUPol::IEWStruct IEWStruct
Definition: commit.hh:96
void squashAll(ThreadID tid)
Squashes all in flight instructions.
Definition: commit_impl.hh:555
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:545
O3CPU * cpu
Pointer to O3CPU.
Definition: commit.hh:377
uint64_t InstSeqNum
Definition: inst_seq.hh:40
void squashAfter(ThreadID tid, DynInstPtr &head_inst)
Handle squashing from instruction with SquashAfter set.
Definition: commit_impl.hh:644
void regStats()
Registers statistics.
Definition: commit_impl.hh:181
ProbePointArg< DynInstPtr > * ppCommit
Probe Points.
Definition: commit.hh:155
void deactivateThread(ThreadID tid)
Deschedules a thread from scheduling.
Definition: commit_impl.hh:460
void setROB(ROB *rob_ptr)
Sets pointer to the ROB.
Definition: commit_impl.hh:365
bool checkEmptyROB[Impl::MaxThreads]
Records if commit should check if the ROB is truly empty (see commit_impl.hh).
Definition: commit.hh:474
Fault interrupt
The interrupt fault.
Definition: commit.hh:453
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's thread.
Definition: commit_impl.hh:444
ProbePointArg< DynInstPtr > * ppSquash
To probe when an instruction is squashed.
Definition: commit.hh:158
ThreadStatus
Individual thread status.
Definition: commit.hh:128
const Cycles iewToCommitDelay
IEW to Commit delay.
Definition: commit.hh:411
bool changedROBEntries()
Returns if any of the threads have the number of ROB entries changed on this cycle.
Definition: commit_impl.hh:504
bool drainPending
Is a drain pending? Commit is looking for an instruction boundary while there are no pending interrup...
Definition: commit.hh:438
CommitPolicy
Commit policy for SMT mode.
Definition: commit.hh:138
CommitPolicy commitPolicy
Commit policy used in SMT mode.
Definition: commit.hh:152
CPUPol::TimeStruct TimeStruct
Definition: commit.hh:94
TimeBuffer< TimeStruct > * timeBuffer
Time buffer interface.
Definition: commit.hh:347
void drain()
Initializes the draining of commit.
Definition: commit_impl.hh:393
size_t numROBFreeEntries(ThreadID tid)
Returns the number of free ROB entries for a specific thread.
Definition: commit_impl.hh:522
int16_t ThreadID
Thread index/ID type.
Definition: types.hh:171
InstSeqNum lastCommitedSeqNum[Impl::MaxThreads]
The sequence number of the last commited instruction.
Definition: commit.hh:464
void pcState(const TheISA::PCState &val, ThreadID tid)
Sets the PC of a specific thread.
Definition: commit.hh:333
void drainSanityCheck() const
Perform sanity checks after a drain.
Definition: commit_impl.hh:408
std::list< ThreadID > priority_list
Priority List used for Commit Policy.
Definition: commit.hh:408
bool trapSquash[Impl::MaxThreads]
Records if a thread has to squash this cycle due to a trap.
Definition: commit.hh:393
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:814
Definition: eventq.hh:185
InstSeqNum youngestSeqNum[Impl::MaxThreads]
The sequence number of the youngest valid instruction in the ROB.
Definition: commit.hh:461
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:500
const ThreadID numThreads
Number of Active Threads.
Definition: commit.hh:433
void updateComInstStats(DynInstPtr &inst)
Updates commit stats based on this instruction.
ThreadID getCommittingThread()
Gets the thread to commit, based on the SMT policy.
CPUPol::ROB ROB
Definition: commit.hh:92
void setIEWQueue(TimeBuffer< IEWStruct > *iq_ptr)
Sets the pointer to the queue coming from IEW.
Definition: commit_impl.hh:333
Stats::Vector instsCommitted
Total number of instructions committed.
Definition: commit.hh:507
TimeBuffer< RenameStruct >::wire fromRename
Wire to read information from rename queue.
Definition: commit.hh:369
bool committedStores[Impl::MaxThreads]
Records if there were any stores committed this cycle.
Definition: commit.hh:470
Stats::Scalar commitSquashedInsts
Stat for the total number of squashed instructions discarded by commit.
Definition: commit.hh:496
TrapEvent(DefaultCommit< Impl > *_commit, ThreadID _tid)
Definition: commit_impl.hh:74
TimeBuffer< IEWStruct > * iewQueue
IEW instruction queue interface.
Definition: commit.hh:360
A 2-Dimensional vecto of scalar stats.
Definition: statistics.hh:2515
DynInstPtr squashAfterInst[Impl::MaxThreads]
Instruction passed to squashAfter().
Definition: commit.hh:405
const char * description() const
Return a C string describing the event.
Definition: commit_impl.hh:91
Event class used to schedule a squash due to a trap (fault or interrupt) to happen on a specific cycl...
Definition: commit.hh:107
CommitStatus _nextStatus
Next commit status, to be set at the end of the cycle.
Definition: commit.hh:148
bool wroteToTimeBuffer
Records that commit has written to the time buffer this cycle.
Definition: commit.hh:385
ROB class.
Definition: rob.hh:61
Addr nextInstAddr(ThreadID tid)
Returns the next PC of a specific thread.
Definition: commit.hh:340
Impl::DynInstPtr DynInstPtr
Definition: commit.hh:88
Stats::Vector statComFunctionCalls
Total number of function calls.
Definition: commit.hh:525
DefaultCommit< Impl > * commit
Definition: commit.hh:109
std::shared_ptr< FaultBase > Fault
Definition: types.hh:184
Stats::Vector statComInteger
Total number of integer instructions.
Definition: commit.hh:523
bool commitHead(DynInstPtr &head_inst, unsigned inst_num)
Tries to commit the head ROB instruction passed in.
CommitStatus _status
Overall commit status.
Definition: commit.hh:146
bool canHandleInterrupts
True if last committed microop can be followed by an interrupt.
Definition: commit.hh:483
void startupStage()
Initializes stage by sending back the number of free entries.
Definition: commit_impl.hh:372
bool changedROBNumEntries[Impl::MaxThreads]
Records if the number of ROB entries has changed this cycle.
Definition: commit.hh:390
ProbePointArg< DynInstPtr > * ppCommitStall
Definition: commit.hh:156
std::vector< Thread * > thread
Vector of all of the threads.
Definition: commit.hh:380
CPUPol::Fetch Fetch
Definition: commit.hh:99
void markCompletedInsts()
Marks completed instructions using information sent from IEW.

Generated on Fri Jun 9 2017 13:03:43 for gem5 by doxygen 1.8.6