gem5 v25.0.0.1
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(); i <= cpu->timeBuffer.getFuture();
301 ++i) {
302 cpu->timeBuffer[i].commitInfo[tid] = {};
303 }
304}
305
306void Commit::drain() { drainPending = true; }
307
308void
310{
311 drainPending = false;
312 drainImminent = false;
313}
314
315void
317{
318 assert(isDrained());
319 rob->drainSanityCheck();
320
321 // hardware transactional memory
322 // cannot drain partially through a transaction
323 for (ThreadID tid = 0; tid < numThreads; tid++) {
324 if (executingHtmTransaction(tid)) {
325 panic("cannot drain partially through a HTM transaction");
326 }
327 }
328}
329
330bool
332{
333 /* Make sure no one is executing microcode. There are two reasons
334 * for this:
335 * - Hardware virtualized CPUs can't switch into the middle of a
336 * microcode sequence.
337 * - The current fetch implementation will most likely get very
338 * confused if it tries to start fetching an instruction that
339 * is executing in the middle of a ucode sequence that changes
340 * address mappings. This can happen on for example x86.
341 */
342 for (ThreadID tid = 0; tid < numThreads; tid++) {
343 if (pc[tid]->microPC() != 0)
344 return false;
345 }
346
347 /* Make sure that all instructions have finished committing before
348 * declaring the system as drained. We want the pipeline to be
349 * completely empty when we declare the CPU to be drained. This
350 * makes debugging easier since CPU handover and restoring from a
351 * checkpoint with a different CPU should have the same timing.
352 */
353 return rob->isEmpty() &&
355}
356
357void
359{
360 _status = Active;
362 for (ThreadID tid = 0; tid < numThreads; tid++) {
363 commitStatus[tid] = Idle;
364 changedROBNumEntries[tid] = false;
365 trapSquash[tid] = false;
366 tcSquash[tid] = false;
367 squashAfterInst[tid] = NULL;
368 }
369 rob->takeOverFrom();
370}
371
372void
374{
375 auto thread_it = std::find(
376 priority_list.begin(), priority_list.end(), tid);
377
378 if (thread_it != priority_list.end()) {
379 priority_list.erase(thread_it);
380 }
381}
382
383bool
385{
386 if (tid == InvalidThreadID)
387 return false;
388 else
389 return (htmStarts[tid] > htmStops[tid]);
390}
391
392void
394{
395 if (tid != InvalidThreadID)
396 {
397 htmStarts[tid] = 0;
398 htmStops[tid] = 0;
399 }
400}
401
402
403void
405{
406 // reset ROB changed variable
407 for (ThreadID tid : *activeThreads) {
408 changedROBNumEntries[tid] = false;
409
410 // Also check if any of the threads has a trap pending
411 if (commitStatus[tid] == TrapPending ||
414 }
415 }
416
417 if (_nextStatus == Inactive && _status == Active) {
418 DPRINTF(Activity, "Deactivating stage.\n");
419 cpu->deactivateStage(CPU::CommitIdx);
420 } else if (_nextStatus == Active && _status == Inactive) {
421 DPRINTF(Activity, "Activating stage.\n");
422 cpu->activateStage(CPU::CommitIdx);
423 }
424
426}
427
428bool
430{
431 for (ThreadID tid : *activeThreads) {
432 if (changedROBNumEntries[tid]) {
433 return true;
434 }
435 }
436
437 return false;
438}
439
440size_t
442{
443 return rob->numFreeEntries(tid);
444}
445
446void
448{
449 DPRINTF(Commit, "Generating trap event for [tid:%i]\n", tid);
450
452 [this, tid]{ processTrapEvent(tid); },
453 "Trap", true, Event::CPU_Tick_Pri);
454
455 Cycles latency = std::dynamic_pointer_cast<SyscallRetryFault>(inst_fault) ?
456 cpu->syscallRetryLatency : trapLatency;
457
458 // hardware transactional memory
459 if (inst_fault != nullptr &&
460 std::dynamic_pointer_cast<GenericHtmFailureFault>(inst_fault)) {
461 // TODO
462 // latency = default abort/restore latency
463 // could also do some kind of exponential back off if desired
464 }
465
466 cpu->schedule(trap, cpu->clockEdge(latency));
467 trapInFlight[tid] = true;
468 thread[tid]->trapPending = true;
469}
470
471void
473{
474 assert(!trapInFlight[tid]);
475 DPRINTF(Commit, "Generating TC squash event for [tid:%i]\n", tid);
476
477 tcSquash[tid] = true;
478}
479
480void
482{
483 // If we want to include the squashing instruction in the squash,
484 // then use one older sequence number.
485 // Hopefully this doesn't mess things up. Basically I want to squash
486 // all instructions of this thread.
487 InstSeqNum squashed_inst = rob->isEmpty(tid) ?
488 lastCommitedSeqNum[tid] : rob->readHeadInst(tid)->seqNum - 1;
489
490 // All younger instructions will be squashed. Set the sequence
491 // number as the youngest instruction in the ROB (0 in this case.
492 // Hopefully nothing breaks.)
494
495 rob->squash(squashed_inst, tid);
496 changedROBNumEntries[tid] = true;
497
498 // Send back the sequence number of the squashed instruction.
499 toIEW->commitInfo[tid].doneSeqNum = squashed_inst;
500
501 // Send back the squash signal to tell stages that they should
502 // squash.
503 toIEW->commitInfo[tid].squash = true;
504
505 // Send back the rob squashing signal so other stages know that
506 // the ROB is in the process of squashing.
507 toIEW->commitInfo[tid].robSquashing = true;
508
509 toIEW->commitInfo[tid].mispredictInst = NULL;
510 toIEW->commitInfo[tid].squashInst = NULL;
511
512 set(toIEW->commitInfo[tid].pc, pc[tid]);
513}
514
515void
517{
518 squashAll(tid);
519
520 DPRINTF(Commit, "Squashing from trap, restarting at PC %s\n", *pc[tid]);
521
522 thread[tid]->trapPending = false;
523 thread[tid]->noSquashFromTC = false;
524 trapInFlight[tid] = false;
525
526 trapSquash[tid] = false;
527
529 cpu->activityThisCycle();
530}
531
532void
534{
535 squashAll(tid);
536
537 DPRINTF(Commit, "Squashing from TC, restarting at PC %s\n", *pc[tid]);
538
539 thread[tid]->noSquashFromTC = false;
540 assert(!thread[tid]->trapPending);
541
543 cpu->activityThisCycle();
544
545 tcSquash[tid] = false;
546}
547
548void
550{
551 DPRINTF(Commit, "Squashing after squash after request, "
552 "restarting at PC %s\n", *pc[tid]);
553
554 squashAll(tid);
555 // Make sure to inform the fetch stage of which instruction caused
556 // the squash. It'll try to re-fetch an instruction executing in
557 // microcode unless this is set.
558 toIEW->commitInfo[tid].squashInst = squashAfterInst[tid];
559 squashAfterInst[tid] = NULL;
560
562 cpu->activityThisCycle();
563}
564
565void
567{
568 DPRINTF(Commit, "Executing squash after for [tid:%i] inst [sn:%llu]\n",
569 tid, head_inst->seqNum);
570
571 assert(!squashAfterInst[tid] || squashAfterInst[tid] == head_inst);
573 squashAfterInst[tid] = head_inst;
574}
575
576void
578{
579 wroteToTimeBuffer = false;
581
582 if (activeThreads->empty())
583 return;
584
585 // Check if any of the threads are done squashing. Change the
586 // status if they are done.
587 for (ThreadID tid : *activeThreads) {
588 // Clear the bit saying if the thread has committed stores
589 // this cycle.
590 committedStores[tid] = false;
591
592 if (commitStatus[tid] == ROBSquashing) {
593
594 if (rob->isDoneSquashing(tid)) {
595 commitStatus[tid] = Running;
596 } else {
597 DPRINTF(Commit,"[tid:%i] Still Squashing, cannot commit any"
598 " insts this cycle.\n", tid);
599 rob->doSquash(tid);
600 toIEW->commitInfo[tid].robSquashing = true;
601 wroteToTimeBuffer = true;
602 }
603 }
604 }
605
606 commit();
607
609
610 for (ThreadID tid : *activeThreads) {
611 if (!rob->isEmpty(tid) && rob->readHeadInst(tid)->readyToCommit()) {
612 // The ROB has more instructions it can commit. Its next status
613 // will be active.
615
616 [[maybe_unused]] const DynInstPtr &inst = rob->readHeadInst(tid);
617
618 DPRINTF(Commit,"[tid:%i] Instruction [sn:%llu] PC %s is head of"
619 " ROB and ready to commit\n",
620 tid, inst->seqNum, inst->pcState());
621
622 } else if (!rob->isEmpty(tid)) {
623 const DynInstPtr &inst = rob->readHeadInst(tid);
624
625 ppCommitStall->notify(inst);
626
627 DPRINTF(Commit,"[tid:%i] Can't commit, Instruction [sn:%llu] PC "
628 "%s is head of ROB and not ready\n",
629 tid, inst->seqNum, inst->pcState());
630 }
631
632 DPRINTF(Commit, "[tid:%i] ROB has %d insts & %d free entries.\n",
633 tid, rob->countInsts(tid), rob->numFreeEntries(tid));
634 }
635
636
637 if (wroteToTimeBuffer) {
638 DPRINTF(Activity, "Activity This Cycle.\n");
639 cpu->activityThisCycle();
640 }
641
642 updateStatus();
643}
644
645void
647{
648 // Verify that we still have an interrupt to handle
649 if (!cpu->checkInterrupts(0)) {
650 DPRINTF(Commit, "Pending interrupt is cleared by requestor before "
651 "it got handled. Restart fetching from the orig path.\n");
652 toIEW->commitInfo[0].clearInterrupt = true;
655 return;
656 }
657
658 // Wait until all in flight instructions are finished before enterring
659 // the interrupt.
660 if (canHandleInterrupts && cpu->instList.empty()) {
661 // Squash or record that I need to squash this cycle if
662 // an interrupt needed to be handled.
663 DPRINTF(Commit, "Interrupt detected.\n");
664
665 // Clear the interrupt now that it's going to be handled
666 toIEW->commitInfo[0].clearInterrupt = true;
667
668 assert(!thread[0]->noSquashFromTC);
669 thread[0]->noSquashFromTC = true;
670
671 if (cpu->checker) {
672 cpu->checker->handlePendingInt();
673 }
674
675 // CPU will handle interrupt. Note that we ignore the local copy of
676 // interrupt. This is because the local copy may no longer be the
677 // interrupt that the interrupt controller thinks is being handled.
678 cpu->processInterrupts(cpu->getInterrupts());
679
680 thread[0]->noSquashFromTC = false;
681
683
685
686 // Generate trap squash event.
688
689 avoidQuiesceLiveLock = false;
690 } else {
691 DPRINTF(Commit, "Interrupt pending: instruction is %sin "
692 "flight, ROB is %sempty\n",
693 canHandleInterrupts ? "not " : "",
694 cpu->instList.empty() ? "" : "not " );
695 }
696}
697
698void
700{
701 // Don't propagate intterupts if we are currently handling a trap or
702 // in draining and the last observable instruction has been committed.
703 if (commitStatus[0] == TrapPending || interrupt || trapSquash[0] ||
705 return;
706
707 // Process interrupts if interrupts are enabled, not in PAL
708 // mode, and no other traps or external squashes are currently
709 // pending.
710 // @todo: Allow other threads to handle interrupts.
711
712 // Get any interrupt that happened
713 interrupt = cpu->getInterrupts();
714
715 // Tell fetch that there is an interrupt pending. This
716 // will make fetch wait until it sees a non PAL-mode PC,
717 // at which point it stops fetching instructions.
718 if (interrupt != NoFault)
719 toIEW->commitInfo[0].interruptPending = true;
720}
721
722void
724{
725 if (FullSystem) {
726 // Check if we have a interrupt and get read to handle it
727 if (cpu->checkInterrupts(0))
729 }
730
732 // Check for any possible squashes, handle them first
734
735 int num_squashing_threads = 0;
736 for (ThreadID tid : *activeThreads) {
737 // Not sure which one takes priority. I think if we have
738 // both, that's a bad sign.
739 if (trapSquash[tid]) {
740 assert(!tcSquash[tid]);
741 squashFromTrap(tid);
742
743 // If the thread is trying to exit (i.e., an exit syscall was
744 // executed), this trapSquash was originated by the exit
745 // syscall earlier. In this case, schedule an exit event in
746 // the next cycle to fully terminate this thread
747 if (cpu->isThreadExiting(tid))
748 cpu->scheduleThreadExitEvent(tid);
749 } else if (tcSquash[tid]) {
750 assert(commitStatus[tid] != TrapPending);
751 squashFromTC(tid);
752 } else if (commitStatus[tid] == SquashAfterPending) {
753 // A squash from the previous cycle of the commit stage (i.e.,
754 // commitInsts() called squashAfter) is pending. Squash the
755 // thread now.
757 }
758
759 // Squashed sequence number must be older than youngest valid
760 // instruction in the ROB. This prevents squashes from younger
761 // instructions overriding squashes from older instructions.
762 if (fromIEW->squash[tid] &&
763 commitStatus[tid] != TrapPending &&
764 fromIEW->squashedSeqNum[tid] <= youngestSeqNum[tid]) {
765
766 if (fromIEW->mispredictInst[tid]) {
768 "[tid:%i] Squashing due to branch mispred "
769 "PC:%#x [sn:%llu]\n",
770 tid,
771 fromIEW->mispredictInst[tid]->pcState().instAddr(),
772 fromIEW->squashedSeqNum[tid]);
773 } else {
775 "[tid:%i] Squashing due to order violation [sn:%llu]\n",
776 tid, fromIEW->squashedSeqNum[tid]);
777 }
778
779 DPRINTF(Commit, "[tid:%i] Redirecting to PC %#x\n",
780 tid, *fromIEW->pc[tid]);
781
783
784 // If we want to include the squashing instruction in the squash,
785 // then use one older sequence number.
786 InstSeqNum squashed_inst = fromIEW->squashedSeqNum[tid];
787
788 if (fromIEW->includeSquashInst[tid]) {
789 squashed_inst--;
790 }
791
792 // All younger instructions will be squashed. Set the sequence
793 // number as the youngest instruction in the ROB.
794 youngestSeqNum[tid] = squashed_inst;
795
796 rob->squash(squashed_inst, tid);
797 changedROBNumEntries[tid] = true;
798
799 toIEW->commitInfo[tid].doneSeqNum = squashed_inst;
800
801 toIEW->commitInfo[tid].squash = true;
802
803 // Send back the rob squashing signal so other stages know that
804 // the ROB is in the process of squashing.
805 toIEW->commitInfo[tid].robSquashing = true;
806
807 toIEW->commitInfo[tid].mispredictInst =
808 fromIEW->mispredictInst[tid];
809 toIEW->commitInfo[tid].branchTaken =
810 fromIEW->branchTaken[tid];
811 toIEW->commitInfo[tid].squashInst =
812 rob->findInst(tid, squashed_inst);
813 if (toIEW->commitInfo[tid].mispredictInst) {
814 if (toIEW->commitInfo[tid].mispredictInst->isUncondCtrl()) {
815 toIEW->commitInfo[tid].branchTaken = true;
816 }
817 ++stats.branchMispredicts;
818 }
819
820 set(toIEW->commitInfo[tid].pc, fromIEW->pc[tid]);
821 }
822
823 if (commitStatus[tid] == ROBSquashing) {
824 num_squashing_threads++;
825 }
826 }
827
828 // If commit is currently squashing, then it will have activity for the
829 // next cycle. Set its next status as active.
830 if (num_squashing_threads) {
832 }
833
834 if (num_squashing_threads != numThreads) {
835 // If we're not currently squashing, then get instructions.
836 getInsts();
837
838 // Try to commit any instructions.
839 commitInsts();
840 }
841
842 //Check for any activity
843 for (ThreadID tid : *activeThreads) {
844 if (changedROBNumEntries[tid]) {
845 toIEW->commitInfo[tid].usedROB = true;
846 toIEW->commitInfo[tid].freeROBEntries = rob->numFreeEntries(tid);
847
848 wroteToTimeBuffer = true;
849 changedROBNumEntries[tid] = false;
850 if (rob->isEmpty(tid))
851 checkEmptyROB[tid] = true;
852 }
853
854 // ROB is only considered "empty" for previous stages if: a)
855 // ROB is empty, b) there are no outstanding stores, c) IEW
856 // stage has received any information regarding stores that
857 // committed.
858 // c) is checked by making sure to not consider the ROB empty
859 // on the same cycle as when stores have been committed.
860 // @todo: Make this handle multi-cycle communication between
861 // commit and IEW.
862 if (checkEmptyROB[tid] && rob->isEmpty(tid) &&
863 !iewStage->hasStoresToWB(tid) && !committedStores[tid]) {
864 checkEmptyROB[tid] = false;
865 toIEW->commitInfo[tid].usedROB = true;
866 toIEW->commitInfo[tid].emptyROB = true;
867 toIEW->commitInfo[tid].freeROBEntries = rob->numFreeEntries(tid);
868 wroteToTimeBuffer = true;
869 }
870
871 }
872}
873
874void
876{
878 // Handle commit
879 // Note that commit will be handled prior to putting new
880 // instructions in the ROB so that the ROB only tries to commit
881 // instructions it has in this current cycle, and not instructions
882 // it is writing in during this cycle. Can't commit and squash
883 // things at the same time...
885
886 DPRINTF(Commit, "Trying to commit instructions in the ROB.\n");
887
888 unsigned num_committed = 0;
889
890 DynInstPtr head_inst;
891
892 // Commit as many instructions as possible until the commit bandwidth
893 // limit is reached, or it becomes impossible to commit any more.
894 while (num_committed < commitWidth) {
895 // hardware transactionally memory
896 // If executing within a transaction,
897 // need to handle interrupts specially
898
899 ThreadID commit_thread = getCommittingThread();
900
901 // Check for any interrupt that we've already squashed for
902 // and start processing it.
903 if (interrupt != NoFault) {
904 // If inside a transaction, postpone interrupts
905 if (executingHtmTransaction(commit_thread)) {
906 cpu->clearInterrupts(0);
907 toIEW->commitInfo[0].clearInterrupt = true;
910 } else {
912 }
913 }
914
915 // ThreadID commit_thread = getCommittingThread();
916
917 if (commit_thread == -1 || !rob->isHeadReady(commit_thread))
918 break;
919
920 head_inst = rob->readHeadInst(commit_thread);
921
922 ThreadID tid = head_inst->threadNumber;
923
924 assert(tid == commit_thread);
925
927 "Trying to commit head instruction, [tid:%i] [sn:%llu]\n",
928 tid, head_inst->seqNum);
929
930 // If the head instruction is squashed, it is ready to retire
931 // (be removed from the ROB) at any time.
932 if (head_inst->isSquashed()) {
933
934 DPRINTF(Commit, "Retiring squashed instruction from "
935 "ROB.\n");
936
937 rob->retireHead(commit_thread);
938
939 ++stats.commitSquashedInsts;
940 // Notify potential listeners that this instruction is squashed
941 ppSquash->notify(head_inst);
942
943 // Record that the number of ROB entries has changed.
944 changedROBNumEntries[tid] = true;
945 // Inst at head of ROB cannot execute because the CPU
946 // does not know how to (lack of FU). This is a misconfiguration,
947 // so panic.
948 } else if (head_inst->noCapableFU() &&
949 head_inst->getFault() == NoFault) {
950 panic("CPU cannot execute [sn:%llu] op_class: %u but"
951 " did not trigger a fault. Do you need to update"
952 " the configuration and add a functional unit for"
953 " that op class?\n",
954 head_inst->seqNum,
955 head_inst->opClass());
956 } else {
957 set(pc[tid], head_inst->pcState());
958
959 // Try to commit the head instruction.
960 bool commit_success = commitHead(head_inst, num_committed);
961
962 if (commit_success) {
963 ++num_committed;
964 cpu->commitStats[tid]
965 ->committedInstType[head_inst->opClass()]++;
966 stats.committedInstType[tid][head_inst->opClass()]++;
967 ppCommit->notify(head_inst);
968
969 // hardware transactional memory
970
971 // update nesting depth
972 if (head_inst->isHtmStart())
973 htmStarts[tid]++;
974
975 // sanity check
976 if (head_inst->inHtmTransactionalState()) {
977 assert(executingHtmTransaction(tid));
978 } else {
979 assert(!executingHtmTransaction(tid));
980 }
981
982 // update nesting depth
983 if (head_inst->isHtmStop())
984 htmStops[tid]++;
985
986 changedROBNumEntries[tid] = true;
987
988 // Set the doneSeqNum to the youngest committed instruction.
989 toIEW->commitInfo[tid].doneSeqNum = head_inst->seqNum;
990
991 if (tid == 0)
992 canHandleInterrupts = !head_inst->isDelayedCommit();
993
994 // at this point store conditionals should either have
995 // been completed or predicated false
996 assert(!head_inst->isStoreConditional() ||
997 head_inst->isCompleted() ||
998 !head_inst->readPredicate());
999
1000 // Updates misc. registers.
1001 head_inst->updateMiscRegs();
1002
1003 // Check instruction execution if it successfully commits and
1004 // is not carrying a fault.
1005 if (cpu->checker) {
1006 cpu->checker->verify(head_inst);
1007 }
1008
1009 cpu->traceFunctions(pc[tid]->instAddr());
1010
1011 head_inst->staticInst->advancePC(*pc[tid]);
1012
1013 // Keep track of the last sequence number commited
1014 lastCommitedSeqNum[tid] = head_inst->seqNum;
1015
1016 // If this is an instruction that doesn't play nicely with
1017 // others squash everything and restart fetch
1018 if (head_inst->isSquashAfter())
1019 squashAfter(tid, head_inst);
1020
1021 if (drainPending) {
1022 if (pc[tid]->microPC() == 0 && interrupt == NoFault &&
1023 !thread[tid]->trapPending) {
1024 // Last architectually committed instruction.
1025 // Squash the pipeline, stall fetch, and use
1026 // drainImminent to disable interrupts
1027 DPRINTF(Drain, "Draining: %i:%s\n", tid, *pc[tid]);
1028 squashAfter(tid, head_inst);
1029 cpu->commitDrained(tid);
1030 drainImminent = true;
1031 }
1032 }
1033
1034 bool onInstBoundary = !head_inst->isMicroop() ||
1035 head_inst->isLastMicroop() ||
1036 !head_inst->isDelayedCommit();
1037
1038 if (onInstBoundary) {
1039 int count = 0;
1040 Addr oldpc;
1041 // Make sure we're not currently updating state while
1042 // handling PC events.
1043 assert(!thread[tid]->noSquashFromTC &&
1044 !thread[tid]->trapPending);
1045 do {
1046 oldpc = pc[tid]->instAddr();
1047 thread[tid]->pcEventQueue.service(
1048 oldpc, thread[tid]->getTC());
1049 count++;
1050 } while (oldpc != pc[tid]->instAddr());
1051 if (count > 1) {
1053 "PC skip function event, stopping commit\n");
1054 break;
1055 }
1056 }
1057
1058 // Check if an instruction just enabled interrupts and we've
1059 // previously had an interrupt pending that was not handled
1060 // because interrupts were subsequently disabled before the
1061 // pipeline reached a place to handle the interrupt. In that
1062 // case squash now to make sure the interrupt is handled.
1063 //
1064 // If we don't do this, we might end up in a live lock
1065 // situation.
1067 onInstBoundary && cpu->checkInterrupts(0))
1068 squashAfter(tid, head_inst);
1069 } else {
1070 DPRINTF(Commit, "Unable to commit head instruction PC:%s "
1071 "[tid:%i] [sn:%llu].\n",
1072 head_inst->pcState(), tid ,head_inst->seqNum);
1073 break;
1074 }
1075 }
1076 }
1077
1078 DPRINTF(CommitRate, "%i\n", num_committed);
1079 stats.numCommittedDist.sample(num_committed);
1080
1081 if (num_committed == commitWidth) {
1082 stats.commitEligibleSamples++;
1083 }
1084}
1085
1086bool
1087Commit::commitHead(const DynInstPtr &head_inst, unsigned inst_num)
1088{
1089 assert(head_inst);
1090
1091 ThreadID tid = head_inst->threadNumber;
1092
1093 // If the instruction is not executed yet, then it will need extra
1094 // handling. Signal backwards that it should be executed.
1095 if (!head_inst->isExecuted()) {
1096 // Make sure we are only trying to commit un-executed instructions we
1097 // think are possible.
1098 assert(head_inst->isNonSpeculative() || head_inst->isStoreConditional()
1099 || head_inst->isReadBarrier() || head_inst->isWriteBarrier()
1100 || head_inst->isAtomic()
1101 || (head_inst->isLoad() && head_inst->strictlyOrdered()));
1102
1104 "Encountered a barrier or non-speculative "
1105 "instruction [tid:%i] [sn:%llu] "
1106 "at the head of the ROB, PC %s.\n",
1107 tid, head_inst->seqNum, head_inst->pcState());
1108
1109 if (inst_num > 0 || iewStage->hasStoresToWB(tid)) {
1111 "[tid:%i] [sn:%llu] "
1112 "Waiting for all stores to writeback.\n",
1113 tid, head_inst->seqNum);
1114 return false;
1115 }
1116
1117 toIEW->commitInfo[tid].nonSpecSeqNum = head_inst->seqNum;
1118
1119 // Change the instruction so it won't try to commit again until
1120 // it is executed.
1121 head_inst->clearCanCommit();
1122
1123 if (head_inst->isLoad() && head_inst->strictlyOrdered()) {
1124 DPRINTF(Commit, "[tid:%i] [sn:%llu] "
1125 "Strictly ordered load, PC %s.\n",
1126 tid, head_inst->seqNum, head_inst->pcState());
1127 toIEW->commitInfo[tid].strictlyOrdered = true;
1128 toIEW->commitInfo[tid].strictlyOrderedLoad = head_inst;
1129 } else {
1130 ++stats.commitNonSpecStalls;
1131 }
1132
1133 return false;
1134 }
1135
1136 // Check if the instruction caused a fault. If so, trap.
1137 Fault inst_fault = head_inst->getFault();
1138
1139 // hardware transactional memory
1140 // if a fault occurred within a HTM transaction
1141 // ensure that the transaction aborts
1142 if (inst_fault != NoFault && head_inst->inHtmTransactionalState()) {
1143 // There exists a generic HTM fault common to all ISAs
1144 if (!std::dynamic_pointer_cast<GenericHtmFailureFault>(inst_fault)) {
1145 DPRINTF(HtmCpu, "%s - fault (%s) encountered within transaction"
1146 " - converting to GenericHtmFailureFault\n",
1147 head_inst->staticInst->getName(), inst_fault->name());
1148 inst_fault = std::make_shared<GenericHtmFailureFault>(
1149 head_inst->getHtmTransactionUid(),
1151 }
1152 // If this point is reached and the fault inherits from the HTM fault,
1153 // then there is no need to raise a new fault
1154 }
1155
1156 // Stores mark themselves as completed.
1157 if (!head_inst->isStore() && inst_fault == NoFault) {
1158 head_inst->setCompleted();
1159 }
1160
1161 if (inst_fault != NoFault) {
1162 DPRINTF(Commit, "Inst [tid:%i] [sn:%llu] PC %s has a fault\n",
1163 tid, head_inst->seqNum, head_inst->pcState());
1164
1165 if (iewStage->hasStoresToWB(tid) || inst_num > 0) {
1167 "[tid:%i] [sn:%llu] "
1168 "Stores outstanding, fault must wait.\n",
1169 tid, head_inst->seqNum);
1170 return false;
1171 }
1172
1173 head_inst->setCompleted();
1174
1175 // If instruction has faulted, let the checker execute it and
1176 // check if it sees the same fault and control flow.
1177 if (cpu->checker) {
1178 // Need to check the instruction before its fault is processed
1179 cpu->checker->verify(head_inst);
1180 }
1181
1182 assert(!thread[tid]->noSquashFromTC);
1183
1184 // Mark that we're in state update mode so that the trap's
1185 // execution doesn't generate extra squashes.
1186 thread[tid]->noSquashFromTC = true;
1187
1188 // Execute the trap. Although it's slightly unrealistic in
1189 // terms of timing (as it doesn't wait for the full timing of
1190 // the trap event to complete before updating state), it's
1191 // needed to update the state as soon as possible. This
1192 // prevents external agents from changing any specific state
1193 // that the trap need.
1194 cpu->trap(inst_fault, tid,
1195 head_inst->notAnInst() ? nullStaticInstPtr :
1196 head_inst->staticInst);
1197
1198 // Exit state update mode to avoid accidental updating.
1199 thread[tid]->noSquashFromTC = false;
1200
1202
1204 "[tid:%i] [sn:%llu] Committing instruction with fault\n",
1205 tid, head_inst->seqNum);
1206 if (head_inst->traceData) {
1207 // We ignore ReExecution "faults" here as they are not real
1208 // (architectural) faults but signal flush/replays.
1209 if (debug::ExecFaulting
1210 && dynamic_cast<ReExec*>(inst_fault.get()) == nullptr) {
1211
1212 head_inst->traceData->setFaulting(true);
1213 head_inst->traceData->setFetchSeq(head_inst->seqNum);
1214 head_inst->traceData->setCPSeq(thread[tid]->numOp);
1215 head_inst->traceData->dump();
1216 }
1217 delete head_inst->traceData;
1218 head_inst->traceData = NULL;
1219 }
1220
1221 // Generate trap squash event.
1222 generateTrapEvent(tid, inst_fault);
1223 return false;
1224 }
1225
1226 updateComInstStats(head_inst);
1227
1229 "[tid:%i] [sn:%llu] Committing instruction with PC %s\n",
1230 tid, head_inst->seqNum, head_inst->pcState());
1231 if (head_inst->traceData) {
1232 head_inst->traceData->setFetchSeq(head_inst->seqNum);
1233 head_inst->traceData->setCPSeq(thread[tid]->numOp);
1234 head_inst->traceData->dump();
1235 delete head_inst->traceData;
1236 head_inst->traceData = NULL;
1237 }
1238 if (head_inst->isReturn()) {
1240 "[tid:%i] [sn:%llu] Return Instruction Committed PC %s \n",
1241 tid, head_inst->seqNum, head_inst->pcState());
1242 }
1243
1244 // Update the commit rename map
1245 for (int i = 0; i < head_inst->numDestRegs(); i++) {
1246 renameMap[tid]->setEntry(head_inst->flattenedDestIdx(i),
1247 head_inst->renamedDestIdx(i));
1248 }
1249
1250 // hardware transactional memory
1251 // the HTM UID is purely for correctness and debugging purposes
1252 if (head_inst->isHtmStart())
1253 iewStage->setLastRetiredHtmUid(tid, head_inst->getHtmTransactionUid());
1254
1255 // Finally clear the head ROB entry.
1256 rob->retireHead(tid);
1257
1258#if TRACING_ON
1259 if (debug::O3PipeView) {
1260 head_inst->commitTick = curTick() - head_inst->fetchTick;
1261 }
1262#endif
1263
1264 // If this was a store, record it for this cycle.
1265 if (head_inst->isStore() || head_inst->isAtomic())
1266 committedStores[tid] = true;
1267
1268 // Return true to indicate that we have committed an instruction.
1269 return true;
1270}
1271
1272void
1274{
1275 DPRINTF(Commit, "Getting instructions from Rename stage.\n");
1276
1277 // Read any renamed instructions and place them into the ROB.
1278 int insts_to_process = std::min((int)renameWidth, fromRename->size);
1279
1280 for (int inst_num = 0; inst_num < insts_to_process; ++inst_num) {
1281 const DynInstPtr &inst = fromRename->insts[inst_num];
1282 ThreadID tid = inst->threadNumber;
1283
1284 if (!inst->isSquashed() &&
1285 commitStatus[tid] != ROBSquashing &&
1286 commitStatus[tid] != TrapPending) {
1287 changedROBNumEntries[tid] = true;
1288
1289 DPRINTF(Commit, "[tid:%i] [sn:%llu] Inserting PC %s into ROB.\n",
1290 tid, inst->seqNum, inst->pcState());
1291
1292 rob->insertInst(inst);
1293
1294 assert(rob->getThreadEntries(tid) <= rob->getMaxEntries(tid));
1295
1296 youngestSeqNum[tid] = inst->seqNum;
1297 } else {
1298 DPRINTF(Commit, "[tid:%i] [sn:%llu] "
1299 "Instruction PC %s was squashed, skipping.\n",
1300 tid, inst->seqNum, inst->pcState());
1301 }
1302 }
1303}
1304
1305void
1307{
1308 // Grab completed insts out of the IEW instruction queue, and mark
1309 // instructions completed within the ROB.
1310 for (int inst_num = 0; inst_num < fromIEW->size; ++inst_num) {
1311 assert(fromIEW->insts[inst_num]);
1312 if (!fromIEW->insts[inst_num]->isSquashed()) {
1313 DPRINTF(Commit, "[tid:%i] Marking PC %s, [sn:%llu] ready "
1314 "within ROB.\n",
1315 fromIEW->insts[inst_num]->threadNumber,
1316 fromIEW->insts[inst_num]->pcState(),
1317 fromIEW->insts[inst_num]->seqNum);
1318
1319 // Mark the instruction as ready to commit.
1320 fromIEW->insts[inst_num]->setCanCommit();
1321 }
1322 }
1323}
1324
1325void
1327{
1328 ThreadID tid = inst->threadNumber;
1329
1330 if (!inst->isMicroop() || inst->isLastMicroop()) {
1331 cpu->commitStats[tid]->numInsts++;
1332 cpu->baseStats.numInsts++;
1333 }
1334 cpu->commitStats[tid]->numOps++;
1335
1336 // To match the old model, don't count nops and instruction
1337 // prefetches towards the total commit count.
1338 if (!inst->isNop() && !inst->isInstPrefetch()) {
1339 cpu->instDone(tid, inst);
1340 }
1341
1342 //
1343 // Control Instructions
1344 //
1345 cpu->commitStats[tid]->updateComCtrlStats(inst->staticInst);
1346
1347 //
1348 // Memory references
1349 //
1350 if (inst->isMemRef()) {
1351 cpu->commitStats[tid]->numMemRefs++;
1352
1353 if (inst->isLoad()) {
1354 cpu->commitStats[tid]->numLoadInsts++;
1355 }
1356
1357 if (inst->isStore()) {
1358 cpu->commitStats[tid]->numStoreInsts++;
1359 }
1360 }
1361
1362 if (inst->isFullMemBarrier()) {
1363 stats.membars[tid]++;
1364 }
1365
1366 // Integer Instruction
1367 if (inst->isInteger()) {
1368 cpu->commitStats[tid]->numIntInsts++;
1369 }
1370
1371 // Floating Point Instruction
1372 if (inst->isFloating()) {
1373 cpu->commitStats[tid]->numFpInsts++;
1374 }
1375 // Vector Instruction
1376 if (inst->isVector()) {
1377 cpu->commitStats[tid]->numVecInsts++;
1378 }
1379
1380 // Function Calls
1381 if (inst->isCall())
1382 stats.functionCalls[tid]++;
1383
1384}
1385
1387// //
1388// SMT COMMIT POLICY MAINTAINED HERE //
1389// //
1393{
1394 if (numThreads > 1) {
1395 // If a thread is exiting, we need to ensure that *all* of its
1396 // instructions will be retired in this cycle, because the
1397 // thread will be removed from the CPU at the end of this cycle.
1398 // To ensure this, we prioritize committing from exiting threads
1399 // before we consider other threads using the specified SMT
1400 // commit policy.
1401 for (ThreadID tid : *activeThreads) {
1402 if (cpu->isThreadExiting(tid) &&
1403 !rob->isEmpty(tid) &&
1404 (commitStatus[tid] == Running ||
1405 commitStatus[tid] == Idle ||
1406 commitStatus[tid] == FetchTrapPending)) {
1407 assert(rob->isHeadReady(tid) &&
1408 rob->readHeadInst(tid)->isSquashed());
1409 return tid;
1410 }
1411 }
1412
1413 switch (commitPolicy) {
1414 case CommitPolicy::RoundRobin:
1415 return roundRobin();
1416
1417 case CommitPolicy::OldestReady:
1418 return oldestReady();
1419
1420 default:
1421 return InvalidThreadID;
1422 }
1423 } else {
1424 assert(!activeThreads->empty());
1425 ThreadID tid = activeThreads->front();
1426
1427 if (commitStatus[tid] == Running ||
1428 commitStatus[tid] == Idle ||
1430 return tid;
1431 } else {
1432 return InvalidThreadID;
1433 }
1434 }
1435}
1436
1439{
1440 auto pri_iter = priority_list.begin();
1441 auto end = priority_list.end();
1442
1443 while (pri_iter != end) {
1444 ThreadID tid = *pri_iter;
1445
1446 if (commitStatus[tid] == Running ||
1447 commitStatus[tid] == Idle ||
1449
1450 if (rob->isHeadReady(tid)) {
1451 priority_list.erase(pri_iter);
1452 priority_list.push_back(tid);
1453
1454 return tid;
1455 }
1456 }
1457
1458 pri_iter++;
1459 }
1460
1461 return InvalidThreadID;
1462}
1463
1466{
1467 unsigned oldest = 0;
1468 unsigned oldest_seq_num = 0;
1469 bool first = true;
1470
1471 for (ThreadID tid : *activeThreads) {
1472 if (!rob->isEmpty(tid) &&
1473 (commitStatus[tid] == Running ||
1474 commitStatus[tid] == Idle ||
1475 commitStatus[tid] == FetchTrapPending)) {
1476
1477 if (rob->isHeadReady(tid)) {
1478
1479 const DynInstPtr &head_inst = rob->readHeadInst(tid);
1480
1481 if (first) {
1482 oldest = tid;
1483 oldest_seq_num = head_inst->seqNum;
1484 first = false;
1485 } else if (head_inst->seqNum < oldest_seq_num) {
1486 oldest = tid;
1487 oldest_seq_num = head_inst->seqNum;
1488 }
1489 }
1490 }
1491 }
1492
1493 if (!first) {
1494 return oldest;
1495 } else {
1496 return InvalidThreadID;
1497 }
1498}
1499
1500} // namespace o3
1501} // 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:1465
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:549
void squashAll(ThreadID tid)
Squashes all in flight instructions.
Definition commit.cc:481
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:429
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:384
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:441
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:447
void deactivateThread(ThreadID tid)
Deschedules a thread from scheduling.
Definition commit.cc:373
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:533
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:646
const Cycles fetchToCommitDelay
Definition commit.hh:388
void propagateInterrupt()
Get fetch redirecting so we can handle an interrupt.
Definition commit.cc:699
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:577
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:404
void squashAfter(ThreadID tid, const DynInstPtr &head_inst)
Handle squashing from instruction with SquashAfter set.
Definition commit.cc:566
bool commitHead(const DynInstPtr &head_inst, unsigned inst_num)
Tries to commit the head ROB instruction passed in.
Definition commit.cc:1087
void resetHtmStartsStops(ThreadID)
Definition commit.cc:393
void getInsts()
Gets instructions from rename and inserts them into the ROB.
Definition commit.cc:1273
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:316
void takeOverFrom()
Takes over from another CPU's thread.
Definition commit.cc:358
void clearStates(ThreadID tid)
Clear all thread-specific states.
Definition commit.cc:286
void drainResume()
Resumes execution after draining.
Definition commit.cc:309
TimeBuffer< RenameStruct > * renameQueue
Rename instruction queue interface, for ROB.
Definition commit.hh:335
void drain()
Initializes the draining of commit.
Definition commit.cc:306
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:875
void markCompletedInsts()
Marks completed instructions using information sent from IEW.
Definition commit.cc:1306
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:1438
void generateTCEvent(ThreadID tid)
Records that commit needs to initiate a squash due to an external state update through the TC.
Definition commit.cc:472
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:1326
ThreadID getCommittingThread()
Gets the thread to commit, based on the SMT policy.
Definition commit.cc:1392
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:723
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:516
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:331
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 Sat Oct 18 2025 08:06:42 for gem5 by doxygen 1.14.0