gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
commit.cc
Go to the documentation of this file.
1/*
2 * Copyright 2014 Google, Inc.
3 * Copyright (c) 2010-2014, 2017, 2020 ARM Limited
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-2005 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#include "cpu/o3/commit.hh"
43
44#include <algorithm>
45#include <set>
46#include <string>
47
48#include "base/compiler.hh"
49#include "base/loader/symtab.hh"
50#include "base/logging.hh"
51#include "cpu/base.hh"
52#include "cpu/checker/cpu.hh"
53#include "cpu/exetrace.hh"
54#include "cpu/o3/cpu.hh"
55#include "cpu/o3/dyn_inst.hh"
56#include "cpu/o3/limits.hh"
58#include "cpu/timebuf.hh"
59#include "debug/Activity.hh"
60#include "debug/Commit.hh"
61#include "debug/CommitRate.hh"
62#include "debug/Drain.hh"
63#include "debug/ExecFaulting.hh"
64#include "debug/HtmCpu.hh"
65#include "debug/O3PipeView.hh"
66#include "params/BaseO3CPU.hh"
67#include "sim/faults.hh"
68#include "sim/full_system.hh"
69
70namespace gem5
71{
72
73namespace o3
74{
75
76void
78{
79 // This will get reset by commit if it was switched out at the
80 // time of this event processing.
81 trapSquash[tid] = true;
82}
83
84Commit::Commit(CPU *_cpu, const BaseO3CPUParams &params)
85 : commitPolicy(params.smtCommitPolicy),
86 cpu(_cpu),
90 fetchToCommitDelay(params.commitToFetchDelay),
93 numThreads(params.numThreads),
94 drainPending(false),
95 drainImminent(false),
99 stats(_cpu, this)
100{
101 if (commitWidth > MaxWidth)
102 fatal("commitWidth (%d) is larger than compiled limit (%d),\n"
103 "\tincrease MaxWidth in src/cpu/o3/limits.hh\n",
104 commitWidth, static_cast<int>(MaxWidth));
105
106 _status = Active;
108
109 if (commitPolicy == CommitPolicy::RoundRobin) {
110 //Set-Up Priority List
111 for (ThreadID tid = 0; tid < numThreads; tid++) {
112 priority_list.push_back(tid);
113 }
114 }
115
116 for (ThreadID tid = 0; tid < MaxThreads; tid++) {
117 commitStatus[tid] = Idle;
118 changedROBNumEntries[tid] = false;
119 trapSquash[tid] = false;
120 tcSquash[tid] = false;
121 squashAfterInst[tid] = nullptr;
122 pc[tid].reset(params.isa[0]->newPCState());
123 youngestSeqNum[tid] = 0;
124 lastCommitedSeqNum[tid] = 0;
125 trapInFlight[tid] = false;
126 committedStores[tid] = false;
127 checkEmptyROB[tid] = false;
128 renameMap[tid] = nullptr;
129 htmStarts[tid] = 0;
130 htmStops[tid] = 0;
131 }
133}
134
135std::string Commit::name() const { return cpu->name() + ".commit"; }
136
137void
139{
141 cpu->getProbeManager(), "Commit");
143 cpu->getProbeManager(), "CommitStall");
145 cpu->getProbeManager(), "Squash");
146}
147
149 : statistics::Group(cpu, "commit"),
151 "The number of squashed insts skipped by commit"),
153 "The number of times commit has been forced to stall to "
154 "communicate backwards"),
156 "The number of times a branch was mispredicted"),
158 "Number of insts commited each cycle"),
159 ADD_STAT(amos, statistics::units::Count::get(),
160 "Number of atomic instructions committed"),
161 ADD_STAT(membars, statistics::units::Count::get(),
162 "Number of memory barriers committed"),
163 ADD_STAT(functionCalls, statistics::units::Count::get(),
164 "Number of function calls committed."),
166 "Class of committed instruction"),
168 "number cycles where commit BW limit reached")
169{
170 using namespace statistics;
171
175
177 .init(0,commit->commitWidth,1)
178 .flags(statistics::pdf);
179
180 amos
181 .init(cpu->numThreads)
182 .flags(total);
183
184 membars
185 .init(cpu->numThreads)
186 .flags(total);
187
189 .init(commit->numThreads)
190 .flags(total);
191
193 .init(commit->numThreads,enums::Num_OpClass)
194 .flags(total | pdf | dist);
195
196 committedInstType.ysubnames(enums::OpClassStrings);
197}
198
199void
201{
202 thread = threads;
203}
204
205void
207{
208 timeBuffer = tb_ptr;
209
210 // Setup wire to send information back to IEW.
211 toIEW = timeBuffer->getWire(0);
212
213 // Setup wire to read data from IEW (for the ROB).
215}
216
217void
219{
220 fetchQueue = fq_ptr;
221
222 // Setup wire to get instructions from rename (for the ROB).
224}
225
226void
228{
229 renameQueue = rq_ptr;
230
231 // Setup wire to get instructions from rename (for the ROB).
233}
234
235void
237{
238 iewQueue = iq_ptr;
239
240 // Setup wire to get instructions from IEW.
241 fromIEW = iewQueue->getWire(-iewToCommitDelay);
242}
243
244void
246{
247 iewStage = iew_stage;
248}
249
250void
255
256void
258{
259 for (ThreadID tid = 0; tid < numThreads; tid++)
260 renameMap[tid] = &rm_ptr[tid];
261}
262
263void Commit::setROB(ROB *rob_ptr) { rob = rob_ptr; }
264
265void
267{
268 rob->setActiveThreads(activeThreads);
269 rob->resetEntries();
270
271 // Broadcast the number of free entries.
272 for (ThreadID tid = 0; tid < numThreads; tid++) {
273 toIEW->commitInfo[tid].usedROB = true;
274 toIEW->commitInfo[tid].freeROBEntries = rob->numFreeEntries(tid);
275 toIEW->commitInfo[tid].emptyROB = true;
276 }
277
278 // Commit must broadcast the number of free entries it has at the
279 // start of the simulation, so it starts as active.
280 cpu->activateStage(CPU::CommitIdx);
281
282 cpu->activityThisCycle();
283}
284
285void
287{
288 commitStatus[tid] = Idle;
289 changedROBNumEntries[tid] = false;
290 checkEmptyROB[tid] = false;
291 trapInFlight[tid] = false;
292 committedStores[tid] = false;
293 trapSquash[tid] = false;
294 tcSquash[tid] = false;
295 pc[tid].reset(cpu->tcBase(tid)->getIsaPtr()->newPCState());
296 lastCommitedSeqNum[tid] = 0;
297 squashAfterInst[tid] = NULL;
298
299 // Clear out any of this thread's instructions being sent to prior stages.
300 for (int i = -cpu->timeBuffer.getPast();
301 i <= cpu->timeBuffer.getFuture(); ++i)
302 cpu->timeBuffer[i].commitInfo[i] = {};
303}
304
305void Commit::drain() { drainPending = true; }
306
307void
309{
310 drainPending = false;
311 drainImminent = false;
312}
313
314void
316{
317 assert(isDrained());
318 rob->drainSanityCheck();
319
320 // hardware transactional memory
321 // cannot drain partially through a transaction
322 for (ThreadID tid = 0; tid < numThreads; tid++) {
323 if (executingHtmTransaction(tid)) {
324 panic("cannot drain partially through a HTM transaction");
325 }
326 }
327}
328
329bool
331{
332 /* Make sure no one is executing microcode. There are two reasons
333 * for this:
334 * - Hardware virtualized CPUs can't switch into the middle of a
335 * microcode sequence.
336 * - The current fetch implementation will most likely get very
337 * confused if it tries to start fetching an instruction that
338 * is executing in the middle of a ucode sequence that changes
339 * address mappings. This can happen on for example x86.
340 */
341 for (ThreadID tid = 0; tid < numThreads; tid++) {
342 if (pc[tid]->microPC() != 0)
343 return false;
344 }
345
346 /* Make sure that all instructions have finished committing before
347 * declaring the system as drained. We want the pipeline to be
348 * completely empty when we declare the CPU to be drained. This
349 * makes debugging easier since CPU handover and restoring from a
350 * checkpoint with a different CPU should have the same timing.
351 */
352 return rob->isEmpty() &&
354}
355
356void
358{
359 _status = Active;
361 for (ThreadID tid = 0; tid < numThreads; tid++) {
362 commitStatus[tid] = Idle;
363 changedROBNumEntries[tid] = false;
364 trapSquash[tid] = false;
365 tcSquash[tid] = false;
366 squashAfterInst[tid] = NULL;
367 }
368 rob->takeOverFrom();
369}
370
371void
373{
374 auto thread_it = std::find(
375 priority_list.begin(), priority_list.end(), tid);
376
377 if (thread_it != priority_list.end()) {
378 priority_list.erase(thread_it);
379 }
380}
381
382bool
384{
385 if (tid == InvalidThreadID)
386 return false;
387 else
388 return (htmStarts[tid] > htmStops[tid]);
389}
390
391void
393{
394 if (tid != InvalidThreadID)
395 {
396 htmStarts[tid] = 0;
397 htmStops[tid] = 0;
398 }
399}
400
401
402void
404{
405 // reset ROB changed variable
406 for (ThreadID tid : *activeThreads) {
407 changedROBNumEntries[tid] = false;
408
409 // Also check if any of the threads has a trap pending
410 if (commitStatus[tid] == TrapPending ||
413 }
414 }
415
416 if (_nextStatus == Inactive && _status == Active) {
417 DPRINTF(Activity, "Deactivating stage.\n");
418 cpu->deactivateStage(CPU::CommitIdx);
419 } else if (_nextStatus == Active && _status == Inactive) {
420 DPRINTF(Activity, "Activating stage.\n");
421 cpu->activateStage(CPU::CommitIdx);
422 }
423
425}
426
427bool
429{
430 for (ThreadID tid : *activeThreads) {
431 if (changedROBNumEntries[tid]) {
432 return true;
433 }
434 }
435
436 return false;
437}
438
439size_t
441{
442 return rob->numFreeEntries(tid);
443}
444
445void
447{
448 DPRINTF(Commit, "Generating trap event for [tid:%i]\n", tid);
449
451 [this, tid]{ processTrapEvent(tid); },
452 "Trap", true, Event::CPU_Tick_Pri);
453
454 Cycles latency = std::dynamic_pointer_cast<SyscallRetryFault>(inst_fault) ?
455 cpu->syscallRetryLatency : trapLatency;
456
457 // hardware transactional memory
458 if (inst_fault != nullptr &&
459 std::dynamic_pointer_cast<GenericHtmFailureFault>(inst_fault)) {
460 // TODO
461 // latency = default abort/restore latency
462 // could also do some kind of exponential back off if desired
463 }
464
465 cpu->schedule(trap, cpu->clockEdge(latency));
466 trapInFlight[tid] = true;
467 thread[tid]->trapPending = true;
468}
469
470void
472{
473 assert(!trapInFlight[tid]);
474 DPRINTF(Commit, "Generating TC squash event for [tid:%i]\n", tid);
475
476 tcSquash[tid] = true;
477}
478
479void
481{
482 // If we want to include the squashing instruction in the squash,
483 // then use one older sequence number.
484 // Hopefully this doesn't mess things up. Basically I want to squash
485 // all instructions of this thread.
486 InstSeqNum squashed_inst = rob->isEmpty(tid) ?
487 lastCommitedSeqNum[tid] : rob->readHeadInst(tid)->seqNum - 1;
488
489 // All younger instructions will be squashed. Set the sequence
490 // number as the youngest instruction in the ROB (0 in this case.
491 // Hopefully nothing breaks.)
493
494 rob->squash(squashed_inst, tid);
495 changedROBNumEntries[tid] = true;
496
497 // Send back the sequence number of the squashed instruction.
498 toIEW->commitInfo[tid].doneSeqNum = squashed_inst;
499
500 // Send back the squash signal to tell stages that they should
501 // squash.
502 toIEW->commitInfo[tid].squash = true;
503
504 // Send back the rob squashing signal so other stages know that
505 // the ROB is in the process of squashing.
506 toIEW->commitInfo[tid].robSquashing = true;
507
508 toIEW->commitInfo[tid].mispredictInst = NULL;
509 toIEW->commitInfo[tid].squashInst = NULL;
510
511 set(toIEW->commitInfo[tid].pc, pc[tid]);
512}
513
514void
516{
517 squashAll(tid);
518
519 DPRINTF(Commit, "Squashing from trap, restarting at PC %s\n", *pc[tid]);
520
521 thread[tid]->trapPending = false;
522 thread[tid]->noSquashFromTC = false;
523 trapInFlight[tid] = false;
524
525 trapSquash[tid] = false;
526
528 cpu->activityThisCycle();
529}
530
531void
533{
534 squashAll(tid);
535
536 DPRINTF(Commit, "Squashing from TC, restarting at PC %s\n", *pc[tid]);
537
538 thread[tid]->noSquashFromTC = false;
539 assert(!thread[tid]->trapPending);
540
542 cpu->activityThisCycle();
543
544 tcSquash[tid] = false;
545}
546
547void
549{
550 DPRINTF(Commit, "Squashing after squash after request, "
551 "restarting at PC %s\n", *pc[tid]);
552
553 squashAll(tid);
554 // Make sure to inform the fetch stage of which instruction caused
555 // the squash. It'll try to re-fetch an instruction executing in
556 // microcode unless this is set.
557 toIEW->commitInfo[tid].squashInst = squashAfterInst[tid];
558 squashAfterInst[tid] = NULL;
559
561 cpu->activityThisCycle();
562}
563
564void
566{
567 DPRINTF(Commit, "Executing squash after for [tid:%i] inst [sn:%llu]\n",
568 tid, head_inst->seqNum);
569
570 assert(!squashAfterInst[tid] || squashAfterInst[tid] == head_inst);
572 squashAfterInst[tid] = head_inst;
573}
574
575void
577{
578 wroteToTimeBuffer = false;
580
581 if (activeThreads->empty())
582 return;
583
584 // Check if any of the threads are done squashing. Change the
585 // status if they are done.
586 for (ThreadID tid : *activeThreads) {
587 // Clear the bit saying if the thread has committed stores
588 // this cycle.
589 committedStores[tid] = false;
590
591 if (commitStatus[tid] == ROBSquashing) {
592
593 if (rob->isDoneSquashing(tid)) {
594 commitStatus[tid] = Running;
595 } else {
596 DPRINTF(Commit,"[tid:%i] Still Squashing, cannot commit any"
597 " insts this cycle.\n", tid);
598 rob->doSquash(tid);
599 toIEW->commitInfo[tid].robSquashing = true;
600 wroteToTimeBuffer = true;
601 }
602 }
603 }
604
605 commit();
606
608
609 for (ThreadID tid : *activeThreads) {
610 if (!rob->isEmpty(tid) && rob->readHeadInst(tid)->readyToCommit()) {
611 // The ROB has more instructions it can commit. Its next status
612 // will be active.
614
615 [[maybe_unused]] const DynInstPtr &inst = rob->readHeadInst(tid);
616
617 DPRINTF(Commit,"[tid:%i] Instruction [sn:%llu] PC %s is head of"
618 " ROB and ready to commit\n",
619 tid, inst->seqNum, inst->pcState());
620
621 } else if (!rob->isEmpty(tid)) {
622 const DynInstPtr &inst = rob->readHeadInst(tid);
623
624 ppCommitStall->notify(inst);
625
626 DPRINTF(Commit,"[tid:%i] Can't commit, Instruction [sn:%llu] PC "
627 "%s is head of ROB and not ready\n",
628 tid, inst->seqNum, inst->pcState());
629 }
630
631 DPRINTF(Commit, "[tid:%i] ROB has %d insts & %d free entries.\n",
632 tid, rob->countInsts(tid), rob->numFreeEntries(tid));
633 }
634
635
636 if (wroteToTimeBuffer) {
637 DPRINTF(Activity, "Activity This Cycle.\n");
638 cpu->activityThisCycle();
639 }
640
641 updateStatus();
642}
643
644void
646{
647 // Verify that we still have an interrupt to handle
648 if (!cpu->checkInterrupts(0)) {
649 DPRINTF(Commit, "Pending interrupt is cleared by requestor before "
650 "it got handled. Restart fetching from the orig path.\n");
651 toIEW->commitInfo[0].clearInterrupt = true;
654 return;
655 }
656
657 // Wait until all in flight instructions are finished before enterring
658 // the interrupt.
659 if (canHandleInterrupts && cpu->instList.empty()) {
660 // Squash or record that I need to squash this cycle if
661 // an interrupt needed to be handled.
662 DPRINTF(Commit, "Interrupt detected.\n");
663
664 // Clear the interrupt now that it's going to be handled
665 toIEW->commitInfo[0].clearInterrupt = true;
666
667 assert(!thread[0]->noSquashFromTC);
668 thread[0]->noSquashFromTC = true;
669
670 if (cpu->checker) {
671 cpu->checker->handlePendingInt();
672 }
673
674 // CPU will handle interrupt. Note that we ignore the local copy of
675 // interrupt. This is because the local copy may no longer be the
676 // interrupt that the interrupt controller thinks is being handled.
677 cpu->processInterrupts(cpu->getInterrupts());
678
679 thread[0]->noSquashFromTC = false;
680
682
684
685 // Generate trap squash event.
687
688 avoidQuiesceLiveLock = false;
689 } else {
690 DPRINTF(Commit, "Interrupt pending: instruction is %sin "
691 "flight, ROB is %sempty\n",
692 canHandleInterrupts ? "not " : "",
693 cpu->instList.empty() ? "" : "not " );
694 }
695}
696
697void
699{
700 // Don't propagate intterupts if we are currently handling a trap or
701 // in draining and the last observable instruction has been committed.
702 if (commitStatus[0] == TrapPending || interrupt || trapSquash[0] ||
704 return;
705
706 // Process interrupts if interrupts are enabled, not in PAL
707 // mode, and no other traps or external squashes are currently
708 // pending.
709 // @todo: Allow other threads to handle interrupts.
710
711 // Get any interrupt that happened
712 interrupt = cpu->getInterrupts();
713
714 // Tell fetch that there is an interrupt pending. This
715 // will make fetch wait until it sees a non PAL-mode PC,
716 // at which point it stops fetching instructions.
717 if (interrupt != NoFault)
718 toIEW->commitInfo[0].interruptPending = true;
719}
720
721void
723{
724 if (FullSystem) {
725 // Check if we have a interrupt and get read to handle it
726 if (cpu->checkInterrupts(0))
728 }
729
731 // Check for any possible squashes, handle them first
733
734 int num_squashing_threads = 0;
735 for (ThreadID tid : *activeThreads) {
736 // Not sure which one takes priority. I think if we have
737 // both, that's a bad sign.
738 if (trapSquash[tid]) {
739 assert(!tcSquash[tid]);
740 squashFromTrap(tid);
741
742 // If the thread is trying to exit (i.e., an exit syscall was
743 // executed), this trapSquash was originated by the exit
744 // syscall earlier. In this case, schedule an exit event in
745 // the next cycle to fully terminate this thread
746 if (cpu->isThreadExiting(tid))
747 cpu->scheduleThreadExitEvent(tid);
748 } else if (tcSquash[tid]) {
749 assert(commitStatus[tid] != TrapPending);
750 squashFromTC(tid);
751 } else if (commitStatus[tid] == SquashAfterPending) {
752 // A squash from the previous cycle of the commit stage (i.e.,
753 // commitInsts() called squashAfter) is pending. Squash the
754 // thread now.
756 }
757
758 // Squashed sequence number must be older than youngest valid
759 // instruction in the ROB. This prevents squashes from younger
760 // instructions overriding squashes from older instructions.
761 if (fromIEW->squash[tid] &&
762 commitStatus[tid] != TrapPending &&
763 fromIEW->squashedSeqNum[tid] <= youngestSeqNum[tid]) {
764
765 if (fromIEW->mispredictInst[tid]) {
767 "[tid:%i] Squashing due to branch mispred "
768 "PC:%#x [sn:%llu]\n",
769 tid,
770 fromIEW->mispredictInst[tid]->pcState().instAddr(),
771 fromIEW->squashedSeqNum[tid]);
772 } else {
774 "[tid:%i] Squashing due to order violation [sn:%llu]\n",
775 tid, fromIEW->squashedSeqNum[tid]);
776 }
777
778 DPRINTF(Commit, "[tid:%i] Redirecting to PC %#x\n",
779 tid, *fromIEW->pc[tid]);
780
782
783 // If we want to include the squashing instruction in the squash,
784 // then use one older sequence number.
785 InstSeqNum squashed_inst = fromIEW->squashedSeqNum[tid];
786
787 if (fromIEW->includeSquashInst[tid]) {
788 squashed_inst--;
789 }
790
791 // All younger instructions will be squashed. Set the sequence
792 // number as the youngest instruction in the ROB.
793 youngestSeqNum[tid] = squashed_inst;
794
795 rob->squash(squashed_inst, tid);
796 changedROBNumEntries[tid] = true;
797
798 toIEW->commitInfo[tid].doneSeqNum = squashed_inst;
799
800 toIEW->commitInfo[tid].squash = true;
801
802 // Send back the rob squashing signal so other stages know that
803 // the ROB is in the process of squashing.
804 toIEW->commitInfo[tid].robSquashing = true;
805
806 toIEW->commitInfo[tid].mispredictInst =
807 fromIEW->mispredictInst[tid];
808 toIEW->commitInfo[tid].branchTaken =
809 fromIEW->branchTaken[tid];
810 toIEW->commitInfo[tid].squashInst =
811 rob->findInst(tid, squashed_inst);
812 if (toIEW->commitInfo[tid].mispredictInst) {
813 if (toIEW->commitInfo[tid].mispredictInst->isUncondCtrl()) {
814 toIEW->commitInfo[tid].branchTaken = true;
815 }
816 ++stats.branchMispredicts;
817 }
818
819 set(toIEW->commitInfo[tid].pc, fromIEW->pc[tid]);
820 }
821
822 if (commitStatus[tid] == ROBSquashing) {
823 num_squashing_threads++;
824 }
825 }
826
827 // If commit is currently squashing, then it will have activity for the
828 // next cycle. Set its next status as active.
829 if (num_squashing_threads) {
831 }
832
833 if (num_squashing_threads != numThreads) {
834 // If we're not currently squashing, then get instructions.
835 getInsts();
836
837 // Try to commit any instructions.
838 commitInsts();
839 }
840
841 //Check for any activity
842 for (ThreadID tid : *activeThreads) {
843 if (changedROBNumEntries[tid]) {
844 toIEW->commitInfo[tid].usedROB = true;
845 toIEW->commitInfo[tid].freeROBEntries = rob->numFreeEntries(tid);
846
847 wroteToTimeBuffer = true;
848 changedROBNumEntries[tid] = false;
849 if (rob->isEmpty(tid))
850 checkEmptyROB[tid] = true;
851 }
852
853 // ROB is only considered "empty" for previous stages if: a)
854 // ROB is empty, b) there are no outstanding stores, c) IEW
855 // stage has received any information regarding stores that
856 // committed.
857 // c) is checked by making sure to not consider the ROB empty
858 // on the same cycle as when stores have been committed.
859 // @todo: Make this handle multi-cycle communication between
860 // commit and IEW.
861 if (checkEmptyROB[tid] && rob->isEmpty(tid) &&
862 !iewStage->hasStoresToWB(tid) && !committedStores[tid]) {
863 checkEmptyROB[tid] = false;
864 toIEW->commitInfo[tid].usedROB = true;
865 toIEW->commitInfo[tid].emptyROB = true;
866 toIEW->commitInfo[tid].freeROBEntries = rob->numFreeEntries(tid);
867 wroteToTimeBuffer = true;
868 }
869
870 }
871}
872
873void
875{
877 // Handle commit
878 // Note that commit will be handled prior to putting new
879 // instructions in the ROB so that the ROB only tries to commit
880 // instructions it has in this current cycle, and not instructions
881 // it is writing in during this cycle. Can't commit and squash
882 // things at the same time...
884
885 DPRINTF(Commit, "Trying to commit instructions in the ROB.\n");
886
887 unsigned num_committed = 0;
888
889 DynInstPtr head_inst;
890
891 // Commit as many instructions as possible until the commit bandwidth
892 // limit is reached, or it becomes impossible to commit any more.
893 while (num_committed < commitWidth) {
894 // hardware transactionally memory
895 // If executing within a transaction,
896 // need to handle interrupts specially
897
898 ThreadID commit_thread = getCommittingThread();
899
900 // Check for any interrupt that we've already squashed for
901 // and start processing it.
902 if (interrupt != NoFault) {
903 // If inside a transaction, postpone interrupts
904 if (executingHtmTransaction(commit_thread)) {
905 cpu->clearInterrupts(0);
906 toIEW->commitInfo[0].clearInterrupt = true;
909 } else {
911 }
912 }
913
914 // ThreadID commit_thread = getCommittingThread();
915
916 if (commit_thread == -1 || !rob->isHeadReady(commit_thread))
917 break;
918
919 head_inst = rob->readHeadInst(commit_thread);
920
921 ThreadID tid = head_inst->threadNumber;
922
923 assert(tid == commit_thread);
924
926 "Trying to commit head instruction, [tid:%i] [sn:%llu]\n",
927 tid, head_inst->seqNum);
928
929 // If the head instruction is squashed, it is ready to retire
930 // (be removed from the ROB) at any time.
931 if (head_inst->isSquashed()) {
932
933 DPRINTF(Commit, "Retiring squashed instruction from "
934 "ROB.\n");
935
936 rob->retireHead(commit_thread);
937
938 ++stats.commitSquashedInsts;
939 // Notify potential listeners that this instruction is squashed
940 ppSquash->notify(head_inst);
941
942 // Record that the number of ROB entries has changed.
943 changedROBNumEntries[tid] = true;
944 // Inst at head of ROB cannot execute because the CPU
945 // does not know how to (lack of FU). This is a misconfiguration,
946 // so panic.
947 } else if (head_inst->noCapableFU() &&
948 head_inst->getFault() == NoFault) {
949 panic("CPU cannot execute [sn:%llu] op_class: %u but"
950 " did not trigger a fault. Do you need to update"
951 " the configuration and add a functional unit for"
952 " that op class?\n",
953 head_inst->seqNum,
954 head_inst->opClass());
955 } else {
956 set(pc[tid], head_inst->pcState());
957
958 // Try to commit the head instruction.
959 bool commit_success = commitHead(head_inst, num_committed);
960
961 if (commit_success) {
962 ++num_committed;
963 cpu->commitStats[tid]
964 ->committedInstType[head_inst->opClass()]++;
965 stats.committedInstType[tid][head_inst->opClass()]++;
966 ppCommit->notify(head_inst);
967
968 // hardware transactional memory
969
970 // update nesting depth
971 if (head_inst->isHtmStart())
972 htmStarts[tid]++;
973
974 // sanity check
975 if (head_inst->inHtmTransactionalState()) {
976 assert(executingHtmTransaction(tid));
977 } else {
978 assert(!executingHtmTransaction(tid));
979 }
980
981 // update nesting depth
982 if (head_inst->isHtmStop())
983 htmStops[tid]++;
984
985 changedROBNumEntries[tid] = true;
986
987 // Set the doneSeqNum to the youngest committed instruction.
988 toIEW->commitInfo[tid].doneSeqNum = head_inst->seqNum;
989
990 if (tid == 0)
991 canHandleInterrupts = !head_inst->isDelayedCommit();
992
993 // at this point store conditionals should either have
994 // been completed or predicated false
995 assert(!head_inst->isStoreConditional() ||
996 head_inst->isCompleted() ||
997 !head_inst->readPredicate());
998
999 // Updates misc. registers.
1000 head_inst->updateMiscRegs();
1001
1002 // Check instruction execution if it successfully commits and
1003 // is not carrying a fault.
1004 if (cpu->checker) {
1005 cpu->checker->verify(head_inst);
1006 }
1007
1008 cpu->traceFunctions(pc[tid]->instAddr());
1009
1010 head_inst->staticInst->advancePC(*pc[tid]);
1011
1012 // Keep track of the last sequence number commited
1013 lastCommitedSeqNum[tid] = head_inst->seqNum;
1014
1015 // If this is an instruction that doesn't play nicely with
1016 // others squash everything and restart fetch
1017 if (head_inst->isSquashAfter())
1018 squashAfter(tid, head_inst);
1019
1020 if (drainPending) {
1021 if (pc[tid]->microPC() == 0 && interrupt == NoFault &&
1022 !thread[tid]->trapPending) {
1023 // Last architectually committed instruction.
1024 // Squash the pipeline, stall fetch, and use
1025 // drainImminent to disable interrupts
1026 DPRINTF(Drain, "Draining: %i:%s\n", tid, *pc[tid]);
1027 squashAfter(tid, head_inst);
1028 cpu->commitDrained(tid);
1029 drainImminent = true;
1030 }
1031 }
1032
1033 bool onInstBoundary = !head_inst->isMicroop() ||
1034 head_inst->isLastMicroop() ||
1035 !head_inst->isDelayedCommit();
1036
1037 if (onInstBoundary) {
1038 int count = 0;
1039 Addr oldpc;
1040 // Make sure we're not currently updating state while
1041 // handling PC events.
1042 assert(!thread[tid]->noSquashFromTC &&
1043 !thread[tid]->trapPending);
1044 do {
1045 oldpc = pc[tid]->instAddr();
1046 thread[tid]->pcEventQueue.service(
1047 oldpc, thread[tid]->getTC());
1048 count++;
1049 } while (oldpc != pc[tid]->instAddr());
1050 if (count > 1) {
1052 "PC skip function event, stopping commit\n");
1053 break;
1054 }
1055 }
1056
1057 // Check if an instruction just enabled interrupts and we've
1058 // previously had an interrupt pending that was not handled
1059 // because interrupts were subsequently disabled before the
1060 // pipeline reached a place to handle the interrupt. In that
1061 // case squash now to make sure the interrupt is handled.
1062 //
1063 // If we don't do this, we might end up in a live lock
1064 // situation.
1066 onInstBoundary && cpu->checkInterrupts(0))
1067 squashAfter(tid, head_inst);
1068 } else {
1069 DPRINTF(Commit, "Unable to commit head instruction PC:%s "
1070 "[tid:%i] [sn:%llu].\n",
1071 head_inst->pcState(), tid ,head_inst->seqNum);
1072 break;
1073 }
1074 }
1075 }
1076
1077 DPRINTF(CommitRate, "%i\n", num_committed);
1078 stats.numCommittedDist.sample(num_committed);
1079
1080 if (num_committed == commitWidth) {
1081 stats.commitEligibleSamples++;
1082 }
1083}
1084
1085bool
1086Commit::commitHead(const DynInstPtr &head_inst, unsigned inst_num)
1087{
1088 assert(head_inst);
1089
1090 ThreadID tid = head_inst->threadNumber;
1091
1092 // If the instruction is not executed yet, then it will need extra
1093 // handling. Signal backwards that it should be executed.
1094 if (!head_inst->isExecuted()) {
1095 // Make sure we are only trying to commit un-executed instructions we
1096 // think are possible.
1097 assert(head_inst->isNonSpeculative() || head_inst->isStoreConditional()
1098 || head_inst->isReadBarrier() || head_inst->isWriteBarrier()
1099 || head_inst->isAtomic()
1100 || (head_inst->isLoad() && head_inst->strictlyOrdered()));
1101
1103 "Encountered a barrier or non-speculative "
1104 "instruction [tid:%i] [sn:%llu] "
1105 "at the head of the ROB, PC %s.\n",
1106 tid, head_inst->seqNum, head_inst->pcState());
1107
1108 if (inst_num > 0 || iewStage->hasStoresToWB(tid)) {
1110 "[tid:%i] [sn:%llu] "
1111 "Waiting for all stores to writeback.\n",
1112 tid, head_inst->seqNum);
1113 return false;
1114 }
1115
1116 toIEW->commitInfo[tid].nonSpecSeqNum = head_inst->seqNum;
1117
1118 // Change the instruction so it won't try to commit again until
1119 // it is executed.
1120 head_inst->clearCanCommit();
1121
1122 if (head_inst->isLoad() && head_inst->strictlyOrdered()) {
1123 DPRINTF(Commit, "[tid:%i] [sn:%llu] "
1124 "Strictly ordered load, PC %s.\n",
1125 tid, head_inst->seqNum, head_inst->pcState());
1126 toIEW->commitInfo[tid].strictlyOrdered = true;
1127 toIEW->commitInfo[tid].strictlyOrderedLoad = head_inst;
1128 } else {
1129 ++stats.commitNonSpecStalls;
1130 }
1131
1132 return false;
1133 }
1134
1135 // Check if the instruction caused a fault. If so, trap.
1136 Fault inst_fault = head_inst->getFault();
1137
1138 // hardware transactional memory
1139 // if a fault occurred within a HTM transaction
1140 // ensure that the transaction aborts
1141 if (inst_fault != NoFault && head_inst->inHtmTransactionalState()) {
1142 // There exists a generic HTM fault common to all ISAs
1143 if (!std::dynamic_pointer_cast<GenericHtmFailureFault>(inst_fault)) {
1144 DPRINTF(HtmCpu, "%s - fault (%s) encountered within transaction"
1145 " - converting to GenericHtmFailureFault\n",
1146 head_inst->staticInst->getName(), inst_fault->name());
1147 inst_fault = std::make_shared<GenericHtmFailureFault>(
1148 head_inst->getHtmTransactionUid(),
1150 }
1151 // If this point is reached and the fault inherits from the HTM fault,
1152 // then there is no need to raise a new fault
1153 }
1154
1155 // Stores mark themselves as completed.
1156 if (!head_inst->isStore() && inst_fault == NoFault) {
1157 head_inst->setCompleted();
1158 }
1159
1160 if (inst_fault != NoFault) {
1161 DPRINTF(Commit, "Inst [tid:%i] [sn:%llu] PC %s has a fault\n",
1162 tid, head_inst->seqNum, head_inst->pcState());
1163
1164 if (iewStage->hasStoresToWB(tid) || inst_num > 0) {
1166 "[tid:%i] [sn:%llu] "
1167 "Stores outstanding, fault must wait.\n",
1168 tid, head_inst->seqNum);
1169 return false;
1170 }
1171
1172 head_inst->setCompleted();
1173
1174 // If instruction has faulted, let the checker execute it and
1175 // check if it sees the same fault and control flow.
1176 if (cpu->checker) {
1177 // Need to check the instruction before its fault is processed
1178 cpu->checker->verify(head_inst);
1179 }
1180
1181 assert(!thread[tid]->noSquashFromTC);
1182
1183 // Mark that we're in state update mode so that the trap's
1184 // execution doesn't generate extra squashes.
1185 thread[tid]->noSquashFromTC = true;
1186
1187 // Execute the trap. Although it's slightly unrealistic in
1188 // terms of timing (as it doesn't wait for the full timing of
1189 // the trap event to complete before updating state), it's
1190 // needed to update the state as soon as possible. This
1191 // prevents external agents from changing any specific state
1192 // that the trap need.
1193 cpu->trap(inst_fault, tid,
1194 head_inst->notAnInst() ? nullStaticInstPtr :
1195 head_inst->staticInst);
1196
1197 // Exit state update mode to avoid accidental updating.
1198 thread[tid]->noSquashFromTC = false;
1199
1201
1203 "[tid:%i] [sn:%llu] Committing instruction with fault\n",
1204 tid, head_inst->seqNum);
1205 if (head_inst->traceData) {
1206 // We ignore ReExecution "faults" here as they are not real
1207 // (architectural) faults but signal flush/replays.
1208 if (debug::ExecFaulting
1209 && dynamic_cast<ReExec*>(inst_fault.get()) == nullptr) {
1210
1211 head_inst->traceData->setFaulting(true);
1212 head_inst->traceData->setFetchSeq(head_inst->seqNum);
1213 head_inst->traceData->setCPSeq(thread[tid]->numOp);
1214 head_inst->traceData->dump();
1215 }
1216 delete head_inst->traceData;
1217 head_inst->traceData = NULL;
1218 }
1219
1220 // Generate trap squash event.
1221 generateTrapEvent(tid, inst_fault);
1222 return false;
1223 }
1224
1225 updateComInstStats(head_inst);
1226
1228 "[tid:%i] [sn:%llu] Committing instruction with PC %s\n",
1229 tid, head_inst->seqNum, head_inst->pcState());
1230 if (head_inst->traceData) {
1231 head_inst->traceData->setFetchSeq(head_inst->seqNum);
1232 head_inst->traceData->setCPSeq(thread[tid]->numOp);
1233 head_inst->traceData->dump();
1234 delete head_inst->traceData;
1235 head_inst->traceData = NULL;
1236 }
1237 if (head_inst->isReturn()) {
1239 "[tid:%i] [sn:%llu] Return Instruction Committed PC %s \n",
1240 tid, head_inst->seqNum, head_inst->pcState());
1241 }
1242
1243 // Update the commit rename map
1244 for (int i = 0; i < head_inst->numDestRegs(); i++) {
1245 renameMap[tid]->setEntry(head_inst->flattenedDestIdx(i),
1246 head_inst->renamedDestIdx(i));
1247 }
1248
1249 // hardware transactional memory
1250 // the HTM UID is purely for correctness and debugging purposes
1251 if (head_inst->isHtmStart())
1252 iewStage->setLastRetiredHtmUid(tid, head_inst->getHtmTransactionUid());
1253
1254 // Finally clear the head ROB entry.
1255 rob->retireHead(tid);
1256
1257#if TRACING_ON
1258 if (debug::O3PipeView) {
1259 head_inst->commitTick = curTick() - head_inst->fetchTick;
1260 }
1261#endif
1262
1263 // If this was a store, record it for this cycle.
1264 if (head_inst->isStore() || head_inst->isAtomic())
1265 committedStores[tid] = true;
1266
1267 // Return true to indicate that we have committed an instruction.
1268 return true;
1269}
1270
1271void
1273{
1274 DPRINTF(Commit, "Getting instructions from Rename stage.\n");
1275
1276 // Read any renamed instructions and place them into the ROB.
1277 int insts_to_process = std::min((int)renameWidth, fromRename->size);
1278
1279 for (int inst_num = 0; inst_num < insts_to_process; ++inst_num) {
1280 const DynInstPtr &inst = fromRename->insts[inst_num];
1281 ThreadID tid = inst->threadNumber;
1282
1283 if (!inst->isSquashed() &&
1284 commitStatus[tid] != ROBSquashing &&
1285 commitStatus[tid] != TrapPending) {
1286 changedROBNumEntries[tid] = true;
1287
1288 DPRINTF(Commit, "[tid:%i] [sn:%llu] Inserting PC %s into ROB.\n",
1289 tid, inst->seqNum, inst->pcState());
1290
1291 rob->insertInst(inst);
1292
1293 assert(rob->getThreadEntries(tid) <= rob->getMaxEntries(tid));
1294
1295 youngestSeqNum[tid] = inst->seqNum;
1296 } else {
1297 DPRINTF(Commit, "[tid:%i] [sn:%llu] "
1298 "Instruction PC %s was squashed, skipping.\n",
1299 tid, inst->seqNum, inst->pcState());
1300 }
1301 }
1302}
1303
1304void
1306{
1307 // Grab completed insts out of the IEW instruction queue, and mark
1308 // instructions completed within the ROB.
1309 for (int inst_num = 0; inst_num < fromIEW->size; ++inst_num) {
1310 assert(fromIEW->insts[inst_num]);
1311 if (!fromIEW->insts[inst_num]->isSquashed()) {
1312 DPRINTF(Commit, "[tid:%i] Marking PC %s, [sn:%llu] ready "
1313 "within ROB.\n",
1314 fromIEW->insts[inst_num]->threadNumber,
1315 fromIEW->insts[inst_num]->pcState(),
1316 fromIEW->insts[inst_num]->seqNum);
1317
1318 // Mark the instruction as ready to commit.
1319 fromIEW->insts[inst_num]->setCanCommit();
1320 }
1321 }
1322}
1323
1324void
1326{
1327 ThreadID tid = inst->threadNumber;
1328
1329 if (!inst->isMicroop() || inst->isLastMicroop()) {
1330 cpu->commitStats[tid]->numInsts++;
1331 cpu->baseStats.numInsts++;
1332 }
1333 cpu->commitStats[tid]->numOps++;
1334
1335 // To match the old model, don't count nops and instruction
1336 // prefetches towards the total commit count.
1337 if (!inst->isNop() && !inst->isInstPrefetch()) {
1338 cpu->instDone(tid, inst);
1339 }
1340
1341 //
1342 // Control Instructions
1343 //
1344 cpu->commitStats[tid]->updateComCtrlStats(inst->staticInst);
1345
1346 //
1347 // Memory references
1348 //
1349 if (inst->isMemRef()) {
1350 cpu->commitStats[tid]->numMemRefs++;
1351
1352 if (inst->isLoad()) {
1353 cpu->commitStats[tid]->numLoadInsts++;
1354 }
1355
1356 if (inst->isStore()) {
1357 cpu->commitStats[tid]->numStoreInsts++;
1358 }
1359 }
1360
1361 if (inst->isFullMemBarrier()) {
1362 stats.membars[tid]++;
1363 }
1364
1365 // Integer Instruction
1366 if (inst->isInteger()) {
1367 cpu->commitStats[tid]->numIntInsts++;
1368 }
1369
1370 // Floating Point Instruction
1371 if (inst->isFloating()) {
1372 cpu->commitStats[tid]->numFpInsts++;
1373 }
1374 // Vector Instruction
1375 if (inst->isVector()) {
1376 cpu->commitStats[tid]->numVecInsts++;
1377 }
1378
1379 // Function Calls
1380 if (inst->isCall())
1381 stats.functionCalls[tid]++;
1382
1383}
1384
1386// //
1387// SMT COMMIT POLICY MAINTAINED HERE //
1388// //
1392{
1393 if (numThreads > 1) {
1394 // If a thread is exiting, we need to ensure that *all* of its
1395 // instructions will be retired in this cycle, because the
1396 // thread will be removed from the CPU at the end of this cycle.
1397 // To ensure this, we prioritize committing from exiting threads
1398 // before we consider other threads using the specified SMT
1399 // commit policy.
1400 for (ThreadID tid : *activeThreads) {
1401 if (cpu->isThreadExiting(tid) &&
1402 !rob->isEmpty(tid) &&
1403 (commitStatus[tid] == Running ||
1404 commitStatus[tid] == Idle ||
1405 commitStatus[tid] == FetchTrapPending)) {
1406 assert(rob->isHeadReady(tid) &&
1407 rob->readHeadInst(tid)->isSquashed());
1408 return tid;
1409 }
1410 }
1411
1412 switch (commitPolicy) {
1413 case CommitPolicy::RoundRobin:
1414 return roundRobin();
1415
1416 case CommitPolicy::OldestReady:
1417 return oldestReady();
1418
1419 default:
1420 return InvalidThreadID;
1421 }
1422 } else {
1423 assert(!activeThreads->empty());
1424 ThreadID tid = activeThreads->front();
1425
1426 if (commitStatus[tid] == Running ||
1427 commitStatus[tid] == Idle ||
1429 return tid;
1430 } else {
1431 return InvalidThreadID;
1432 }
1433 }
1434}
1435
1438{
1439 auto pri_iter = priority_list.begin();
1440 auto end = priority_list.end();
1441
1442 while (pri_iter != end) {
1443 ThreadID tid = *pri_iter;
1444
1445 if (commitStatus[tid] == Running ||
1446 commitStatus[tid] == Idle ||
1448
1449 if (rob->isHeadReady(tid)) {
1450 priority_list.erase(pri_iter);
1451 priority_list.push_back(tid);
1452
1453 return tid;
1454 }
1455 }
1456
1457 pri_iter++;
1458 }
1459
1460 return InvalidThreadID;
1461}
1462
1465{
1466 unsigned oldest = 0;
1467 unsigned oldest_seq_num = 0;
1468 bool first = true;
1469
1470 for (ThreadID tid : *activeThreads) {
1471 if (!rob->isEmpty(tid) &&
1472 (commitStatus[tid] == Running ||
1473 commitStatus[tid] == Idle ||
1474 commitStatus[tid] == FetchTrapPending)) {
1475
1476 if (rob->isHeadReady(tid)) {
1477
1478 const DynInstPtr &head_inst = rob->readHeadInst(tid);
1479
1480 if (first) {
1481 oldest = tid;
1482 oldest_seq_num = head_inst->seqNum;
1483 first = false;
1484 } else if (head_inst->seqNum < oldest_seq_num) {
1485 oldest = tid;
1486 oldest_seq_num = head_inst->seqNum;
1487 }
1488 }
1489 }
1490 }
1491
1492 if (!first) {
1493 return oldest;
1494 } else {
1495 return InvalidThreadID;
1496 }
1497}
1498
1499} // namespace o3
1500} // namespace gem5
#define DPRINTF(x,...)
Definition trace.hh:209
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:273
O3CPU class, has each of the stages (fetch through commit) within it, as well as all of the time buff...
Definition cpu.hh:94
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:1464
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:548
void squashAll(ThreadID tid)
Squashes all in flight instructions.
Definition commit.cc:480
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:383
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:440
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:446
void deactivateThread(ThreadID tid)
Deschedules a thread from scheduling.
Definition commit.cc:372
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:532
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:645
const Cycles fetchToCommitDelay
Definition commit.hh:388
void propagateInterrupt()
Get fetch redirecting so we can handle an interrupt.
Definition commit.cc:698
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:576
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?
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
void updateStatus()
Updates the overall status of commit with the nextStatus, and tell the CPU if commit is active/inacti...
Definition commit.cc:403
void squashAfter(ThreadID tid, const DynInstPtr &head_inst)
Handle squashing from instruction with SquashAfter set.
Definition commit.cc:565
bool commitHead(const DynInstPtr &head_inst, unsigned inst_num)
Tries to commit the head ROB instruction passed in.
Definition commit.cc:1086
void resetHtmStartsStops(ThreadID)
Definition commit.cc:392
void getInsts()
Gets instructions from rename and inserts them into the ROB.
Definition commit.cc:1272
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:315
void takeOverFrom()
Takes over from another CPU's thread.
Definition commit.cc:357
void clearStates(ThreadID tid)
Clear all thread-specific states.
Definition commit.cc:286
void drainResume()
Resumes execution after draining.
Definition commit.cc:308
TimeBuffer< RenameStruct > * renameQueue
Rename instruction queue interface, for ROB.
Definition commit.hh:335
void drain()
Initializes the draining of commit.
Definition commit.cc:305
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?
Definition commit.hh:411
void commitInsts()
Commits as many instructions as possible.
Definition commit.cc:874
void markCompletedInsts()
Marks completed instructions using information sent from IEW.
Definition commit.cc:1305
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:1437
void generateTCEvent(ThreadID tid)
Records that commit needs to initiate a squash due to an external state update through the TC.
Definition commit.cc:471
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:1325
ThreadID getCommittingThread()
Gets the thread to commit, based on the SMT policy.
Definition commit.cc:1391
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:722
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:515
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:330
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
std::array< UnifiedRenameMap, MaxThreads > PerThreadUnifiedRenameMap
STL list class.
Definition stl.hh:51
STL vector class.
Definition stl.hh:37
#define ADD_STAT(n,...)
Convenience macro to add a stat to a statistics group.
Definition group.hh:75
static const Priority CPU_Tick_Pri
CPU ticks must come after other associated CPU events (such as writebacks).
Definition eventq.hh:207
#define panic(...)
This implements a cprintf based panic() function.
Definition logging.hh:220
#define fatal(...)
This implements a cprintf based fatal() function.
Definition logging.hh:232
Bitfield< 7 > i
Definition misc_types.hh:67
Bitfield< 12, 11 > set
static constexpr int MaxThreads
Definition limits.hh:38
RefCountingPtr< DynInst > DynInstPtr
static constexpr int MaxWidth
Definition limits.hh:37
Units for Stats.
Definition units.hh:113
const FlagsType pdf
Print the percent of the total that this entry represents.
Definition info.hh:61
const FlagsType total
Print the total.
Definition info.hh:59
const FlagsType dist
Print the distribution.
Definition info.hh:65
Copyright (c) 2024 Arm Limited 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
const ThreadID InvalidThreadID
Definition types.hh:236
Tick curTick()
The universal simulation clock.
Definition cur_tick.hh:46
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
Definition root.cc:220
const StaticInstPtr nullStaticInstPtr
Statically allocated null StaticInstPtr.
constexpr decltype(nullptr) NoFault
Definition types.hh:253
uint64_t InstSeqNum
Definition inst_seq.hh:40
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 Mon May 26 2025 09:19:08 for gem5 by doxygen 1.13.2