summaryrefslogtreecommitdiff
path: root/src/sim
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2012-01-16 04:27:10 -0800
committerGabe Black <gblack@eecs.umich.edu>2012-01-16 04:27:10 -0800
commitda2a4acc26ba264c3c4a12495776fd6a1c4fb133 (patch)
treef142100388b9d1403492c97b0d323728ce18ef8a /src/sim
parent241cc0c8402f1b9f2ec20d1cc152d96930959b2a (diff)
parenta7394ad6807bd5e85f680184bf308673ca00534a (diff)
downloadgem5-da2a4acc26ba264c3c4a12495776fd6a1c4fb133.tar.xz
Merge yet again with the main repository.
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/System.py2
-rw-r--r--src/sim/pseudo_inst.cc2
-rw-r--r--src/sim/system.cc50
-rw-r--r--src/sim/system.hh14
4 files changed, 65 insertions, 3 deletions
diff --git a/src/sim/System.py b/src/sim/System.py
index db214abc0..39505c01a 100644
--- a/src/sim/System.py
+++ b/src/sim/System.py
@@ -54,8 +54,8 @@ class System(SimObject):
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 --git a/src/sim/pseudo_inst.cc b/src/sim/pseudo_inst.cc
index 749afeb3b..d5bc8fa0e 100644
--- a/src/sim/pseudo_inst.cc
+++ b/src/sim/pseudo_inst.cc
@@ -417,6 +417,7 @@ workbegin(ThreadContext *tc, uint64_t workid, uint64_t threadid)
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);
@@ -473,6 +474,7 @@ workend(ThreadContext *tc, uint64_t workid, uint64_t threadid)
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 --git a/src/sim/system.cc b/src/sim/system.cc
index 3051cb64b..d3bee1ad1 100644
--- a/src/sim/system.cc
+++ b/src/sim/system.cc
@@ -1,4 +1,16 @@
/*
+ * Copyright (c) 2011 ARM Limited
+ * All rights reserved
+ *
+ * The license below extends only to copyright in the software and shall
+ * not be construed as granting a license to any other intellectual
+ * property including but not limited to intellectual property relating
+ * to a hardware implementation of the functionality of the software
+ * licensed hereunder. You may use the software subject to the license
+ * terms below provided that you ensure that this notice is replicated
+ * unmodified and in its entirety in all distributions of the software,
+ * modified or unmodified, in source code or in binary form.
+ *
* Copyright (c) 2003-2006 The Regents of The University of Michigan
* Copyright (c) 2011 Regents of the University of California
* All rights reserved.
@@ -43,6 +55,7 @@
#include "config/the_isa.hh"
#include "cpu/thread_context.hh"
#include "debug/Loader.hh"
+#include "debug/WorkItems.hh"
#include "kern/kernel_stats.hh"
#include "mem/mem_object.hh"
#include "mem/physical.hh"
@@ -68,8 +81,9 @@ System::System(Params *p)
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
@@ -158,6 +172,9 @@ System::~System()
{
delete kernelSymtab;
delete kernel;
+
+ for (uint32_t j = 0; j < numWorkIds; j++)
+ delete workItemStats[j];
}
void
@@ -320,6 +337,37 @@ System::unserialize(Checkpoint *cp, const string &section)
}
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<uint32_t,uint32_t> 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);
+ lastWorkItemStarted.erase(p);
+}
+
+void
System::printSystems()
{
vector<System *>::iterator i = systemList.begin();
diff --git a/src/sim/system.hh b/src/sim/system.hh
index 00d8360e0..d675eb727 100644
--- a/src/sim/system.hh
+++ b/src/sim/system.hh
@@ -157,14 +157,16 @@ class System : public SimObject
Enums::MemoryMode memoryMode;
uint64_t workItemsBegin;
uint64_t workItemsEnd;
+ uint32_t numWorkIds;
std::vector<bool> 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;
@@ -198,6 +200,14 @@ class System : public SimObject
return count;
}
+ inline void workItemBegin(uint32_t tid, uint32_t workid)
+ {
+ std::pair<uint32_t,uint32_t> p(tid, workid);
+ lastWorkItemStarted[p] = curTick();
+ }
+
+ void workItemEnd(uint32_t tid, uint32_t workid);
+
/**
* Fix up an address used to match PCs for hooking simulator
* events on to target function executions. See comment in
@@ -285,6 +295,8 @@ class System : public SimObject
public:
Counter totalNumInsts;
EventQueue instEventQueue;
+ std::map<std::pair<uint32_t,uint32_t>, Tick> lastWorkItemStarted;
+ std::map<uint32_t, Stats::Histogram*> workItemStats;
////////////////////////////////////////////
//