Simple CPU: Make sure only instructions which complete without faulting are counted.
authorGabe Black <gblack@eecs.umich.edu>
Mon, 27 Aug 2007 03:25:42 +0000 (20:25 -0700)
committerGabe Black <gblack@eecs.umich.edu>
Mon, 27 Aug 2007 03:25:42 +0000 (20:25 -0700)
--HG--
extra : convert_revision : 01019c7129ed762d8826c3e6519989aa3fc3b5fd

src/cpu/simple/atomic.cc
src/cpu/simple/base.cc
src/cpu/simple/base.hh
src/cpu/simple/timing.cc

index 379c50b51c3e16bcd6190a1dada56d4acb584f14..86deb84e61d28ea218a73a5fa101dc914e9a7c29 100644 (file)
@@ -546,6 +546,11 @@ AtomicSimpleCPU::tick()
             if(curStaticInst)
             {
                 fault = curStaticInst->execute(this, traceData);
+
+                // keep an instruction count
+                if (fault == NoFault)
+                    countInst();
+
                 postExecute();
             }
 
index aabaf19714da938f27a27b93326a124ff44df2df..d6b124efc3cb60a4af1a6883864b2639bf6a6c98 100644 (file)
@@ -357,12 +357,6 @@ BaseSimpleCPU::preExecute()
     thread->setFloatReg(ZeroReg, 0.0);
 #endif // ALPHA_ISA
 
-    // keep an instruction count
-    numInst++;
-    numInsts++;
-
-    thread->funcExeInst++;
-
     // check for instruction-count-based events
     comInstEventQueue[0]->serviceEvents(numInst);
 
index 843fd025c6820d9341e1c3e31ccea76902f72f3c..2bc329b68747a0552b8a30dca4464d9ac2be6f9e 100644 (file)
@@ -157,6 +157,14 @@ class BaseSimpleCPU : public BaseCPU
     Counter startNumInst;
     Stats::Scalar<> numInsts;
 
+    void countInst()
+    {
+        numInst++;
+        numInsts++;
+
+        thread->funcExeInst++;
+    }
+
     virtual Counter totalInstructions() const
     {
         return numInst - startNumInst;
index 70b774debdf5c855e12c7cdf901475aa560ff915..046b2fe3b23b88cb1d0e621e73f1ddcddf11c106 100644 (file)
@@ -540,13 +540,23 @@ TimingSimpleCPU::completeIfetch(PacketPtr pkt)
                 delete dcache_pkt->req;
                 delete dcache_pkt;
                 dcache_pkt = NULL;
+
+                // keep an instruction count
+                if (fault == NoFault)
+                    countInst();
             }
+
             postExecute();
             advanceInst(fault);
         }
     } else {
         // non-memory instruction: execute completely now
         Fault fault = curStaticInst->execute(this, traceData);
+
+        // keep an instruction count
+        if (fault == NoFault)
+            countInst();
+
         postExecute();
         advanceInst(fault);
     }
@@ -615,6 +625,10 @@ TimingSimpleCPU::completeDataAccess(PacketPtr pkt)
 
     Fault fault = curStaticInst->completeAcc(pkt, this, traceData);
 
+    // keep an instruction count
+    if (fault == NoFault)
+        countInst();
+
     if (pkt->isRead() && pkt->isLocked()) {
         TheISA::handleLockedRead(thread, pkt->req);
     }