summaryrefslogtreecommitdiff
path: root/src/cpu/simple/atomic.cc
diff options
context:
space:
mode:
authorDam Sunwoo <dam.sunwoo@arm.com>2014-09-20 17:17:43 -0400
committerDam Sunwoo <dam.sunwoo@arm.com>2014-09-20 17:17:43 -0400
commitca3513d63038e562782cd193c00c3892a276bb5d (patch)
treec8f92b165105989fdb9b9b75d594880157da541f /src/cpu/simple/atomic.cc
parent7329c0e20ba2c78f57dd53e90246ccbe3efa158d (diff)
downloadgem5-ca3513d63038e562782cd193c00c3892a276bb5d.tar.xz
cpu: use probes infrastructure to do simpoint profiling
Instead of having code embedded in cpu model to do simpoint profiling use the probes infrastructure to do it.
Diffstat (limited to 'src/cpu/simple/atomic.cc')
-rw-r--r--src/cpu/simple/atomic.cc95
1 files changed, 12 insertions, 83 deletions
diff --git a/src/cpu/simple/atomic.cc b/src/cpu/simple/atomic.cc
index 219e94043..0ac4a5495 100644
--- a/src/cpu/simple/atomic.cc
+++ b/src/cpu/simple/atomic.cc
@@ -110,20 +110,9 @@ AtomicSimpleCPU::AtomicSimpleCPU(AtomicSimpleCPUParams *p)
drain_manager(NULL),
icachePort(name() + ".icache_port", this),
dcachePort(name() + ".dcache_port", this),
- fastmem(p->fastmem),
- simpoint(p->simpoint_profile),
- intervalSize(p->simpoint_interval),
- intervalCount(0),
- intervalDrift(0),
- simpointStream(NULL),
- currentBBV(0, 0),
- currentBBVInstCount(0)
+ fastmem(p->fastmem)
{
_status = Idle;
-
- if (simpoint) {
- simpointStream = simout.create(p->simpoint_profile_file, false);
- }
}
@@ -132,9 +121,6 @@ AtomicSimpleCPU::~AtomicSimpleCPU()
if (tickEvent.scheduled()) {
deschedule(tickEvent);
}
- if (simpointStream) {
- simout.close(simpointStream);
- }
}
unsigned int
@@ -574,8 +560,13 @@ AtomicSimpleCPU::tick()
fault = curStaticInst->execute(this, traceData);
// keep an instruction count
- if (fault == NoFault)
+ if (fault == NoFault) {
countInst();
+ if (!curStaticInst->isMicroop() ||
+ curStaticInst->isLastMicroop()) {
+ ppCommit->notify(std::make_pair(thread, curStaticInst));
+ }
+ }
else if (traceData && !DTRACE(ExecFaulting)) {
delete traceData;
traceData = NULL;
@@ -589,13 +580,6 @@ AtomicSimpleCPU::tick()
curStaticInst->isFirstMicroop()))
instCnt++;
- // profile for SimPoints if enabled and macro inst is finished
- if (simpoint && curStaticInst && (fault == NoFault) &&
- (!curStaticInst->isMicroop() ||
- curStaticInst->isLastMicroop())) {
- profileSimPoint();
- }
-
Tick stall_ticks = 0;
if (simulate_inst_stalls && icache_access)
stall_ticks += icache_latency;
@@ -627,72 +611,17 @@ AtomicSimpleCPU::tick()
schedule(tickEvent, curTick() + latency);
}
-
void
-AtomicSimpleCPU::printAddr(Addr a)
+AtomicSimpleCPU::regProbePoints()
{
- dcachePort.printAddr(a);
+ ppCommit = new ProbePointArg<pair<SimpleThread*, const StaticInstPtr>>
+ (getProbeManager(), "Commit");
}
void
-AtomicSimpleCPU::profileSimPoint()
+AtomicSimpleCPU::printAddr(Addr a)
{
- if (!currentBBVInstCount)
- currentBBV.first = thread->pcState().instAddr();
-
- ++intervalCount;
- ++currentBBVInstCount;
-
- // If inst is control inst, assume end of basic block.
- if (curStaticInst->isControl()) {
- currentBBV.second = thread->pcState().instAddr();
-
- auto map_itr = bbMap.find(currentBBV);
- if (map_itr == bbMap.end()){
- // If a new (previously unseen) basic block is found,
- // add a new unique id, record num of insts and insert into bbMap.
- BBInfo info;
- info.id = bbMap.size() + 1;
- info.insts = currentBBVInstCount;
- info.count = currentBBVInstCount;
- bbMap.insert(std::make_pair(currentBBV, info));
- } else {
- // If basic block is seen before, just increment the count by the
- // number of insts in basic block.
- BBInfo& info = map_itr->second;
- info.count += currentBBVInstCount;
- }
- currentBBVInstCount = 0;
-
- // Reached end of interval if the sum of the current inst count
- // (intervalCount) and the excessive inst count from the previous
- // interval (intervalDrift) is greater than/equal to the interval size.
- if (intervalCount + intervalDrift >= intervalSize) {
- // summarize interval and display BBV info
- std::vector<pair<uint64_t, uint64_t> > counts;
- for (auto map_itr = bbMap.begin(); map_itr != bbMap.end();
- ++map_itr) {
- BBInfo& info = map_itr->second;
- if (info.count != 0) {
- counts.push_back(std::make_pair(info.id, info.count));
- info.count = 0;
- }
- }
- std::sort(counts.begin(), counts.end());
-
- // Print output BBV info
- *simpointStream << "T";
- for (auto cnt_itr = counts.begin(); cnt_itr != counts.end();
- ++cnt_itr) {
- *simpointStream << ":" << cnt_itr->first
- << ":" << cnt_itr->second << " ";
- }
- *simpointStream << "\n";
-
- intervalDrift = (intervalCount + intervalDrift) - intervalSize;
- intervalCount = 0;
- }
- }
+ dcachePort.printAddr(a);
}
////////////////////////////////////////////////////////////////////////