diff -r 612332751cbc -r a2fc624bdcc9 src/base/statistics.hh --- a/src/base/statistics.hh Fri Dec 16 15:31:17 2011 -0600 +++ b/src/base/statistics.hh Fri Dec 16 15:31:50 2011 -0600 @@ -1477,6 +1477,8 @@ /** The current sum. */ Counter sum; + /** The sum of logarithm of each sample, used to compute geometric mean. */ + Counter logs; /** The sum of squares. */ Counter squares; /** The number of samples. */ @@ -1528,6 +1530,7 @@ sum += val * number; squares += val * val * number; + logs += log(val) * number; samples += number; } @@ -1567,6 +1570,7 @@ data.cvec[i] = cvec[i]; data.sum = sum; + data.logs = logs; data.squares = squares; data.samples = samples; } @@ -1589,6 +1593,7 @@ sum = Counter(); squares = Counter(); samples = Counter(); + logs = Counter(); } }; diff -r 612332751cbc -r a2fc624bdcc9 src/base/stats/info.hh --- a/src/base/stats/info.hh Fri Dec 16 15:31:17 2011 -0600 +++ b/src/base/stats/info.hh Fri Dec 16 15:31:50 2011 -0600 @@ -183,6 +183,7 @@ VCounter cvec; Counter sum; Counter squares; + Counter logs; Counter samples; }; diff -r 612332751cbc -r a2fc624bdcc9 src/base/stats/text.cc --- a/src/base/stats/text.cc Fri Dec 16 15:31:17 2011 -0600 +++ b/src/base/stats/text.cc Fri Dec 16 15:31:50 2011 -0600 @@ -367,6 +367,12 @@ print.value = data.samples ? data.sum / data.samples : NAN; print(stream); + if (data.type == Hist) { + print.name = base + "Geometric_mean"; + print.value = data.samples ? exp(data.logs / data.samples) : NAN; + print(stream); + } + Result stdev = NAN; if (data.samples) stdev = sqrt((data.samples * data.squares - data.sum * data.sum) / diff -r 612332751cbc -r a2fc624bdcc9 src/python/m5/main.py --- a/src/python/m5/main.py Fri Dec 16 15:31:17 2011 -0600 +++ b/src/python/m5/main.py Fri Dec 16 15:31:50 2011 -0600 @@ -123,7 +123,6 @@ execfile(options_file, scope) arguments = options.parse_args() - return options,arguments def interact(scope): diff -r 612332751cbc -r a2fc624bdcc9 src/sim/System.py --- a/src/sim/System.py Fri Dec 16 15:31:17 2011 -0600 +++ b/src/sim/System.py Fri Dec 16 15:31:50 2011 -0600 @@ -54,8 +54,8 @@ physmem = Param.PhysicalMemory("Physical Memory") mem_mode = Param.MemoryMode('atomic', "The mode the memory system is in") memories = VectorParam.PhysicalMemory(Self.all, "All memories is the system") - work_item_id = Param.Int(-1, "specific work item id") + num_work_ids = Param.Int(16, "Number of distinct work item types") work_begin_cpu_id_exit = Param.Int(-1, "work started on specific id, now exit simulation") work_begin_ckpt_count = Param.Counter(0, diff -r 612332751cbc -r a2fc624bdcc9 src/sim/pseudo_inst.cc --- a/src/sim/pseudo_inst.cc Fri Dec 16 15:31:17 2011 -0600 +++ b/src/sim/pseudo_inst.cc Fri Dec 16 15:31:50 2011 -0600 @@ -383,6 +383,7 @@ tc->getCpuPtr()->workItemBegin(); System *sys = tc->getSystemPtr(); const System::Params *params = sys->params(); + sys->workItemBegin(threadid, workid); DPRINTF(WorkItems, "Work Begin workid: %d, threadid %d\n", workid, threadid); @@ -439,6 +440,7 @@ tc->getCpuPtr()->workItemEnd(); System *sys = tc->getSystemPtr(); const System::Params *params = sys->params(); + sys->workItemEnd(threadid, workid); DPRINTF(WorkItems, "Work End workid: %d, threadid %d\n", workid, threadid); diff -r 612332751cbc -r a2fc624bdcc9 src/sim/system.hh --- a/src/sim/system.hh Fri Dec 16 15:31:17 2011 -0600 +++ b/src/sim/system.hh Fri Dec 16 15:31:50 2011 -0600 @@ -171,14 +171,16 @@ Enums::MemoryMode memoryMode; uint64_t workItemsBegin; uint64_t workItemsEnd; + uint32_t numWorkIds; std::vector activeCpus; public: + virtual void regStats(); /** * Called by pseudo_inst to track the number of work items started by this * system. */ - uint64_t + uint64_t incWorkItemsBegin() { return ++workItemsBegin; @@ -212,6 +214,14 @@ return count; } + inline void workItemBegin(uint32_t tid, uint32_t workid) + { + std::pair p(tid, workid); + lastWorkItemStarted[p] = curTick(); + } + + void workItemEnd(uint32_t tid, uint32_t workid); + #if FULL_SYSTEM /** * Fix up an address used to match PCs for hooking simulator @@ -303,6 +313,8 @@ public: Counter totalNumInsts; EventQueue instEventQueue; + std::map, Tick> lastWorkItemStarted; + std::map workItemStats; //////////////////////////////////////////// // diff -r 612332751cbc -r a2fc624bdcc9 src/sim/system.cc --- a/src/sim/system.cc Fri Dec 16 15:31:17 2011 -0600 +++ b/src/sim/system.cc Fri Dec 16 15:31:50 2011 -0600 @@ -43,6 +43,7 @@ #include "config/the_isa.hh" #include "cpu/thread_context.hh" #include "debug/Loader.hh" +#include "debug/WorkItems.hh" #include "mem/mem_object.hh" #include "mem/physical.hh" #include "sim/byteswap.hh" @@ -76,8 +77,9 @@ memoryMode(p->mem_mode), workItemsBegin(0), workItemsEnd(0), + numWorkIds(p->num_work_ids), _params(p), - totalNumInsts(0), + totalNumInsts(0), instEventQueue("system instruction-based event queue") { // add self to global system list @@ -171,6 +173,9 @@ panic("System::fixFuncEventAddr needs to be rewritten " "to work with syscall emulation"); #endif // FULL_SYSTEM} + + for (uint32_t j = 0; j < numWorkIds; j++) + delete workItemStats[j]; } void @@ -340,6 +345,37 @@ } void +System::regStats() +{ + for (uint32_t j = 0; j < numWorkIds ; j++) { + workItemStats[j] = new Stats::Histogram(); + stringstream namestr; + ccprintf(namestr, "work_item_type%d", j); + workItemStats[j]->init(20) + .name(name() + "." + namestr.str()) + .desc("Run time stat for" + namestr.str()) + .prereq(*workItemStats[j]); + } +} + +void +System::workItemEnd(uint32_t tid, uint32_t workid) +{ + std::pair p(tid, workid); + if (!lastWorkItemStarted.count(p)) + return; + + Tick samp = curTick() - lastWorkItemStarted[p]; + DPRINTF(WorkItems, "Work item end: %d\t%d\t%lld\n", tid, workid, samp); + + if (workid >= numWorkIds) + fatal("Got workid greater than specified in system configuration\n"); + + workItemStats[workid]->sample(samp); + workItemStats.erase(workid); +} + +void System::printSystems() { vector::iterator i = systemList.begin();