From 0ca254aa8381ba2fae61a4a056301e35da9ffab3 Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Thu, 28 Feb 2019 17:07:16 +0800 Subject: invisispec-1.0 source --- src/cpu/o3/commit_impl.hh | 62 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) (limited to 'src/cpu/o3/commit_impl.hh') diff --git a/src/cpu/o3/commit_impl.hh b/src/cpu/o3/commit_impl.hh index d32493cbc..d83011a66 100644 --- a/src/cpu/o3/commit_impl.hh +++ b/src/cpu/o3/commit_impl.hh @@ -143,6 +143,7 @@ DefaultCommit::DefaultCommit(O3CPU *_cpu, DerivO3CPUParams *params) lastCommitedSeqNum[tid] = 0; squashAfterInst[tid] = NULL; } + lastCommitTick = curTick(); interrupt = NoFault; } @@ -183,6 +184,28 @@ DefaultCommit::regStats() .desc("The number of times a branch was mispredicted") .prereq(branchMispredicts); + // [InvisiSpec] stat for squash due to invalidation, failed validation + loadHitInvalidations + .name(name() + ".loadHitInvalidations") + .desc("The number of times a load hits a invalidation"); + //.prereq(loadHitInvalidations); + + loadHitExternalEvictions + .name(name() + ".loadHitExternalEvictions") + .desc("The number of times a load hits an external invalidation"); + //.prereq(loadHitInvalidations); + + loadValidationFails + .name(name() + ".loadValidationFails") + .desc("The number of times a load fails validation"); + //.prereq(loadValidationFails); + + validationStalls + .name(name() + ".validationStalls") + .desc("The number of ticks the commit is stalled due to waiting " + "for validation responses"); + //.prereq(loadValidationFails); + numCommittedDist .init(0,commitWidth,1) .name(name() + ".committed_per_cycle") @@ -579,6 +602,9 @@ DefaultCommit::squashAll(ThreadID tid) toIEW->commitInfo[tid].squashInst = NULL; toIEW->commitInfo[tid].pc = pc[tid]; + + //TODO: send a packet to SpecBuffer to indicate flush + // } template @@ -705,13 +731,21 @@ DefaultCommit::tick() } else if (!rob->isEmpty(tid)) { DynInstPtr inst = rob->readHeadInst(tid); + if (inst->isExecuted() && inst->needPostFetch() + && !inst->isExposeCompleted()){ + //stall due to waiting for validation response + if (curTick()-lastCommitTick > 0){ + validationStalls+= curTick()-lastCommitTick; + } + + } ppCommitStall->notify(inst); DPRINTF(Commit,"[tid:%i]: Can't commit, Instruction [sn:%lli] PC " "%s is head of ROB and not ready\n", tid, inst->seqNum, inst->pcState()); } - + lastCommitTick = curTick(); DPRINTF(Commit, "[tid:%i]: ROB has %d insts & %d free entries.\n", tid, rob->countInsts(tid), rob->numFreeEntries(tid)); } @@ -832,6 +866,7 @@ DefaultCommit::commit() squashFromTrap(tid); } else if (tcSquash[tid]) { assert(commitStatus[tid] != TrapPending); + //TC: thread context. [mengjia] squashFromTC(tid); } else if (commitStatus[tid] == SquashAfterPending) { // A squash from the previous cycle of the commit stage (i.e., @@ -1039,6 +1074,7 @@ DefaultCommit::commitInsts() toIEW->commitInfo[tid].doneSeqNum = head_inst->seqNum; if (tid == 0) { + //maybe we can use this to mask interrupts [mengjia] canHandleInterrupts = (!head_inst->isDelayedCommit()) && ((THE_ISA != ALPHA_ISA) || (!(pc[0].instAddr() & 0x3))); @@ -1219,6 +1255,8 @@ DefaultCommit::commitHead(DynInstPtr &head_inst, unsigned inst_num) // execution doesn't generate extra squashes. thread[tid]->noSquashFromTC = true; + // [InvisiSpec] update squash stat for invalidation or validation fails + updateSquashStats(head_inst); // Execute the trap. Although it's slightly unrealistic in // terms of timing (as it doesn't wait for the full timing of // the trap event to complete before updating state), it's @@ -1350,6 +1388,7 @@ DefaultCommit::markCompletedInsts() // Grab completed insts out of the IEW instruction queue, and mark // instructions completed within the ROB. for (int inst_num = 0; inst_num < fromIEW->size; ++inst_num) { + DPRINTF(Commit, "get the inst [num:%d]\n", inst_num); assert(fromIEW->insts[inst_num]); if (!fromIEW->insts[inst_num]->isSquashed()) { DPRINTF(Commit, "[tid:%i]: Marking PC %s, [sn:%lli] ready " @@ -1362,6 +1401,27 @@ DefaultCommit::markCompletedInsts() fromIEW->insts[inst_num]->setCanCommit(); } } + + // [InvisiSpec] + // update load status + // isPrevInstsCompleted; isPrevBrsResolved + rob->updateVisibleState(); +} + +// [InvisiSpec] update squash stat for loads +template +void +DefaultCommit::updateSquashStats(DynInstPtr &inst) +{ + if (inst->hitInvalidation()){ + loadHitInvalidations++; + } + if (inst->validationFail()){ + loadValidationFails++; + } + if (inst->hitExternalEviction()){ + loadHitExternalEvictions++; + } } template -- cgit v1.2.3