Skip to content

Commit 8ef695e

Browse files
authored
cpu-o3: add more performance counter in resolve queue (#666)
Change-Id: Ic2a77e02704a21611e68598cd5b71cf9542c8462
1 parent ac0a89a commit 8ef695e

File tree

2 files changed

+44
-24
lines changed

2 files changed

+44
-24
lines changed

src/cpu/o3/fetch.cc

Lines changed: 38 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,16 @@ Fetch::FetchStatGroup::FetchStatGroup(CPU *cpu, Fetch *fetch)
251251
statistics::units::Count, statistics::units::Cycle>::get(),
252252
"Frontend Bandwidth Bound",
253253
frontendBound - frontendLatencyBound),
254-
ADD_STAT(resolveQueueFullCycles, statistics::units::Count::get(),
255-
"Number of cycles the resolve queue is full"),
256254
ADD_STAT(resolveQueueFullEvents, statistics::units::Count::get(),
257255
"Number of events the resolve queue becomes full"),
258256
ADD_STAT(resolveEnqueueFailEvent, statistics::units::Count::get(),
259-
"Number of times an entry could not be enqueued to the resolve queue")
257+
"Number of times an entry could not be enqueued to the resolve queue"),
258+
ADD_STAT(resolveDequeueCount, statistics::units::Count::get(),
259+
"Number of times an entry is dequeued from the resolve queue"),
260+
ADD_STAT(resolveEnqueueCount, statistics::units::Count::get(),
261+
"Number of times an entry is enqueued to the resolve queue"),
262+
ADD_STAT(resolveQueueOccupancy, statistics::units::Count::get(),
263+
"Number of entries in the resolve queue")
260264
{
261265
icacheStallCycles
262266
.prereq(icacheStallCycles);
@@ -326,6 +330,10 @@ Fetch::FetchStatGroup::FetchStatGroup(CPU *cpu, Fetch *fetch)
326330
.flags(statistics::total);
327331
frontendBandwidthBound
328332
.flags(statistics::total);
333+
resolveEnqueueCount
334+
.init(1, 8, 1);
335+
resolveQueueOccupancy
336+
.init(0, 32, 1);
329337
}
330338
void
331339
Fetch::setTimeBuffer(TimeBuffer<TimeStruct> *time_buffer)
@@ -1502,32 +1510,39 @@ Fetch::handleIEWSignals()
15021510
}
15031511

15041512
auto &incoming = fromIEW->iewInfo->resolvedCFIs;
1513+
uint8_t enqueueSize = fromIEW->iewInfo->resolvedCFIs.size();
1514+
uint8_t enqueueCount = 0;
15051515

1506-
for (const auto &resolved : incoming) {
1507-
bool merged = false;
1508-
for (auto &queued : resolveQueue) {
1509-
if (queued.resolvedFSQId == resolved.fsqId) {
1510-
queued.resolvedInstPC.push_back(resolved.pc);
1511-
merged = true;
1512-
break;
1516+
if (resolveQueueSize && resolveQueue.size() > resolveQueueSize - 4) {
1517+
fetchStats.resolveQueueFullEvents++;
1518+
fetchStats.resolveEnqueueFailEvent += enqueueSize;
1519+
} else {
1520+
1521+
for (const auto &resolved : incoming) {
1522+
bool merged = false;
1523+
for (auto &queued : resolveQueue) {
1524+
if (queued.resolvedFSQId == resolved.fsqId) {
1525+
queued.resolvedInstPC.push_back(resolved.pc);
1526+
merged = true;
1527+
break;
1528+
}
15131529
}
1514-
}
15151530

1516-
if (merged) {
1517-
continue;
1518-
}
1531+
if (merged) {
1532+
continue;
1533+
}
15191534

1520-
if (resolveQueueSize && resolveQueue.size() >= resolveQueueSize) {
1521-
fetchStats.resolveQueueFullEvents++;
1522-
continue;
1535+
ResolveQueueEntry new_entry;
1536+
new_entry.resolvedFSQId = resolved.fsqId;
1537+
new_entry.resolvedInstPC.push_back(resolved.pc);
1538+
resolveQueue.push_back(std::move(new_entry));
1539+
enqueueCount++;
15231540
}
1524-
1525-
ResolveQueueEntry new_entry;
1526-
new_entry.resolvedFSQId = resolved.fsqId;
1527-
new_entry.resolvedInstPC.push_back(resolved.pc);
1528-
resolveQueue.push_back(std::move(new_entry));
1541+
fetchStats.resolveEnqueueCount.sample(enqueueCount);
15291542
}
15301543

1544+
fetchStats.resolveQueueOccupancy.sample(resolveQueue.size());
1545+
15311546
if (!resolveQueue.empty()) {
15321547
auto &entry = resolveQueue.front();
15331548
unsigned int stream_id = entry.resolvedFSQId;
@@ -1539,6 +1554,7 @@ Fetch::handleIEWSignals()
15391554
if (success) {
15401555
dbpbtb->notifyResolveSuccess();
15411556
resolveQueue.pop_front();
1557+
fetchStats.resolveDequeueCount++;
15421558
} else {
15431559
dbpbtb->notifyResolveFailure();
15441560
}

src/cpu/o3/fetch.hh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,11 +1103,15 @@ class Fetch
11031103
/** Frontend Bandwidth Bound */
11041104
statistics::Formula frontendBandwidthBound;
11051105
/** Stat for total cycles the resolve queue is full. */
1106-
statistics::Scalar resolveQueueFullCycles;
1107-
/** Stat for total events of the resolve queue becomes full. */
11081106
statistics::Scalar resolveQueueFullEvents;
11091107
/** Stat for total number of resolve enqueue fail events. */
11101108
statistics::Scalar resolveEnqueueFailEvent;
1109+
/** Stat for total number of resolve dequeue events. */
1110+
statistics::Scalar resolveDequeueCount;
1111+
/** Stat for total number of resolve enqueue events. */
1112+
statistics::Distribution resolveEnqueueCount;
1113+
/** Stat for entry occupancy distribution of the resolve queue. */
1114+
statistics::Distribution resolveQueueOccupancy;
11111115
} fetchStats;
11121116

11131117
SquashVersion localSquashVer;

0 commit comments

Comments
 (0)