Skip to content

Stall and Flush Counter (Initial Iteration) #203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 39 additions & 2 deletions src/processortab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ ProcessorTab::ProcessorTab(QToolBar *controlToolbar,
connect(ProcessorHandler::get(), &ProcessorHandler::stopping, this,
&ProcessorTab::pause);

connect(ProcessorHandler::get(), &ProcessorHandler::processorClocked, this,
&ProcessorTab::processorClocked);
connect(ProcessorHandler::get(), &ProcessorHandler::processorReversed, this,
&ProcessorTab::processorReversed);

// Make processor view stretch wrt. consoles
m_ui->pipelinesplitter->setStretchFactor(0, 1);
m_ui->pipelinesplitter->setStretchFactor(1, 0);
Expand Down Expand Up @@ -308,6 +313,7 @@ void ProcessorTab::updateStatistics() {
const auto cycleCount = ProcessorHandler::getProcessor()->getCycleCount();
const auto instrsRetired =
ProcessorHandler::getProcessor()->getInstructionsRetired();

const auto timeDiff = std::chrono::duration_cast<std::chrono::milliseconds>(
timeNow - lastUpdateTime)
.count() /
Expand All @@ -318,10 +324,14 @@ void ProcessorTab::updateStatistics() {
m_ui->cycleCount->setText(QString::number(cycleCount));
// Instructions retired
m_ui->instructionsRetired->setText(QString::number(instrsRetired));
// Stall Count
m_ui->stallCount->setText(QString::number(m_stallCount));
// Flush Cycle Count
m_ui->flushCycleCount->setText(QString::number(m_flushCycleCount));

QString cpiText, ipcText;
if (cycleCount != 0 && instrsRetired != 0) {
const double cpi =
static_cast<double>(cycleCount) / static_cast<double>(instrsRetired);
const double cpi = static_cast<double>(cycleCount) / static_cast<double>(instrsRetired);
const double ipc = 1 / cpi;
cpiText = QString::number(cpi, 'g', 3);
ipcText = QString::number(ipc, 'g', 3);
Expand Down Expand Up @@ -499,6 +509,10 @@ void ProcessorTab::reset() {
m_autoClockAction->setChecked(false);
enableSimulatorControls();
SystemIO::printString("\n");

// Reset Statistics
m_stallCount = 0;
m_flushCycleCount = 0;
}

void ProcessorTab::setInstructionViewCenterRow(int row) {
Expand Down Expand Up @@ -582,4 +596,27 @@ void ProcessorTab::showPipelineDiagram() {
auto w = PipelineDiagramWidget(m_stageModel);
w.exec();
}

void ProcessorTab::processorClocked() {
const auto proc = ProcessorHandler::get()->getProcessor();
for (auto lane : proc->structure()) {
const auto laneLastStage = proc->stageInfo({lane.first, lane.second - 1});
if (laneLastStage.state == StageInfo::State::Stalled)
m_stallCount++;
if (laneLastStage.state == StageInfo::State::Flushed)
m_flushCycleCount++;
}
}

void ProcessorTab::processorReversed() {
const auto proc = ProcessorHandler::get()->getProcessor();
for (auto lane : proc->structure()) {
const auto laneLastStage = proc->stageInfo({lane.first, lane.second - 1});
if (laneLastStage.state == StageInfo::State::Stalled)
m_stallCount--;
if (laneLastStage.state == StageInfo::State::Flushed)
m_flushCycleCount--;
}
}

} // namespace Ripes
6 changes: 6 additions & 0 deletions src/processortab.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public slots:
void reverse();
void processorFinished();
void runFinished();
void processorClocked();
void processorReversed();
void updateStatistics();
void updateInstructionLabels();
void fitToScreen();
Expand Down Expand Up @@ -73,6 +75,10 @@ private slots:

std::map<StageIndex, vsrtl::Label *> m_stageInstructionLabels;

// Statistics
long long m_stallCount = 0;
long long m_flushCycleCount = 0;

QTimer *m_statUpdateTimer;

// Actions
Expand Down
140 changes: 93 additions & 47 deletions src/processortab.ui
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,6 @@
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0">
<layout class="QGridLayout" name="gridLayout_7">
<item row="1" column="1">
<widget class="QLineEdit" name="instructionsRetired">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label">
<property name="toolTip">
Expand All @@ -82,25 +66,19 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="cpi">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Cycles:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="readOnly">
<bool>true</bool>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
</widget>
</item>
Expand All @@ -114,24 +92,47 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="nInstrExecutedLabel">
<item row="5" column="1">
<widget class="QLineEdit" name="stallCount">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>An instruction has been retired once leaving the final stage of the processor</string>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="clockRate">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Instrs. retired:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>Clock rate:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="cycleCount">
<item row="1" column="1">
<widget class="QLineEdit" name="instructionsRetired">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -168,31 +169,76 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Stalls</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="cpi">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="nInstrExecutedLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>An instruction has been retired once leaving the final stage of the processor</string>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Cycles:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Instrs. retired:&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="cycleCount">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<item row="6" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Clock rate:</string>
<string>Flush Cycles</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLineEdit" name="clockRate">
<item row="6" column="1">
<widget class="QLineEdit" name="flushCycleCount">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand Down