From a4d7bb113aa4ed398a2ec7f6fb01b6d866fba60c Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Wed, 12 May 2004 15:49:01 -0400 Subject: Make a new stat type of Value which is a scalar stat that proxies for a real C/C++ scalar value or scalar functor. This replaces the scalar() and functor() terms that were previously used in formulas. This helps when dumping statistics because the formulas are not supposed to change. cpu/base_cpu.cc: Add a number of cycles stat to the cpu object that tracks the number of cycles that the cpu has executed. This starts to pave the way for cpu cycles being different from event ticks. cpu/base_cpu.hh: provide a functor for calculating all simulated instructions of all CPUs and a virtual function for determining that number. To deal with the change from functor() to Value::functor() cpu/simple_cpu/simple_cpu.cc: simTicks -> numCycles numInsts is now a real Scalar stat, not a Formula cpu/simple_cpu/simple_cpu.hh: numInsts is now a real Scalar stat, not a Formula count all instructions sim/stat_control.cc: simInsts, simTicks, hostMemory, and hostSeconds are no longer Statistics::Formula but rather Statistics::Value add new stat for tick frequency sim/stats.hh: don't need everything to be extern. test/Makefile: Make stuff work a tad bit better test/stattest.cc: test out Statistics::Value --HG-- extra : convert_revision : c812e8baa2b17c08abf3a68ed1e1125dc6f2cfb4 --- cpu/base_cpu.hh | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'cpu/base_cpu.hh') diff --git a/cpu/base_cpu.hh b/cpu/base_cpu.hh index 648035732..c4826cf15 100644 --- a/cpu/base_cpu.hh +++ b/cpu/base_cpu.hh @@ -31,10 +31,10 @@ #include +#include "base/statistics.hh" #include "sim/eventq.hh" #include "sim/sim_object.hh" - -#include "targetarch/isa_traits.hh" // for Addr +#include "targetarch/isa_traits.hh" #ifdef FULL_SYSTEM class System; @@ -147,11 +147,27 @@ class BaseCPU : public SimObject */ virtual BranchPred *getBranchPred() { return NULL; }; + virtual Counter totalInstructions() const { return 0; } + private: static std::vector cpuList; //!< Static global cpu list public: static int numSimulatedCPUs() { return cpuList.size(); } + static Counter numSimulatedInstructions() + { + Counter total = 0; + + int size = cpuList.size(); + for (int i = 0; i < size; ++i) + total += cpuList[i]->totalInstructions(); + + return total; + } + + public: + // Number of CPU cycles simulated + Statistics::Scalar<> numCycles; }; #endif // __BASE_CPU_HH__ -- cgit v1.2.3