Add # instructions retired and register file telemetry
MODIFY
src/cmd/cmdoptions.cpp
src/cmd/cmdoptions.cpp
@@ -51,13 +51,15 @@ void addCmdOptions(QCommandLineParser &parser, Ripes::CmdModeOptions &options) {
// Telemtry reporting
options.telemetry.push_back(std::make_shared<CyclesTelemetry>());
+ options.telemetry.push_back(std::make_shared<InstrsRetiredTelemetry>());
options.telemetry.push_back(std::make_shared<CPITelemetry>());
options.telemetry.push_back(std::make_shared<IPCTelemetry>());
options.telemetry.push_back(std::make_shared<PipelineTelemetry>());
+ options.telemetry.push_back(std::make_shared<RegisterTelemetry>());
for (auto &telemetry : options.telemetry) {
- QCommandLineOption telemetryOption(telemetry->key(),
- telemetry->description());
+ QString desc = "Report " + telemetry->description();
+ QCommandLineOption telemetryOption(telemetry->key(), desc);
parser.addOption(telemetryOption);
}
}

MODIFY
src/cmd/cmdrunner.cpp
src/cmd/cmdrunner.cpp
@@ -107,8 +107,10 @@ int CmdRunner::postRun() {
}
for (auto &telemetry : m_options.telemetry)
- if (telemetry->isEnabled())
+ if (telemetry->isEnabled()) {
+ *stream << "===== " << telemetry->description() << "\n";
telemetry->report(*stream);
+ }
// Close output file if necessary
if (!m_options.outputFile.isEmpty())

MODIFY
src/cmd/telemetry.h
src/cmd/telemetry.h
#include "pipelinediagrammodel.h"
#include "processorhandler.h"
+#include "radix.h"
#include <memory>
@@ -35,7 +36,7 @@ private:
class CPITelemetry : public Telemetry {
QString key() const override { return "cpi"; }
QString description() const override {
- return "Report cycles per instruction";
+ return "cycles per instruction (CPI)";
}
void report(QTextStream &out) override {
const auto cycleCount = ProcessorHandler::getProcessor()->getCycleCount();
@@ -43,14 +44,14 @@ class CPITelemetry : public Telemetry {
ProcessorHandler::getProcessor()->getInstructionsRetired();
const double cpi =
static_cast<double>(cycleCount) / static_cast<double>(instrsRetired);
- out << "CPI: " << QString::number(cpi) << "\n";
+ out << QString::number(cpi) << "\n";
}
};
class IPCTelemetry : public Telemetry {
QString key() const override { return "ipc"; }
QString description() const override {
- return "Report instructions per cycle";
+ return "instructions per cycle (IPC)";
}
void report(QTextStream &out) override {
const auto cycleCount = ProcessorHandler::getProcessor()->getCycleCount();
@@ -59,18 +60,26 @@ class IPCTelemetry : public Telemetry {
const double cpi =
static_cast<double>(cycleCount) / static_cast<double>(instrsRetired);
const double ipc = 1 / cpi;
- out << "IPC: " << QString::number(ipc) << "\n";
+ out << QString::number(ipc) << "\n";
}
};
class CyclesTelemetry : public Telemetry {
QString key() const override { return "cycles"; }
- QString description() const override {
- return "Report total number of cycles";
- }
+ QString description() const override { return "cycles"; }
void report(QTextStream &out) override {
const auto cycleCount = ProcessorHandler::getProcessor()->getCycleCount();
- out << "Cycles: " << QString::number(cycleCount) << "\n";
+ out << QString::number(cycleCount) << "\n";
+ }
+};
+
+class InstrsRetiredTelemetry : public Telemetry {
+ QString key() const override { return "iret"; }
+ QString description() const override { return "instructions retired"; }
+ void report(QTextStream &out) override {
+ const auto instrsRetired =
+ ProcessorHandler::getProcessor()->getInstructionsRetired();
+ out << QString::number(instrsRetired) << "\n";
}
};
@@ -83,16 +92,30 @@ public:
}
QString key() const override { return "pipeline"; }
- QString description() const override { return "Report pipeline state"; }
+ QString description() const override { return "pipeline state"; }
void report(QTextStream &out) override {
// Simply grab the current state of the pipeline diagram model and print it.
- out << "===== Pipeline diagram\n";
out << m_pipelineDiagramModel->toString() << "\n";
- out << "=====\n";
}
private:
std::shared_ptr<PipelineDiagramModel> m_pipelineDiagramModel;
};
+class RegisterTelemetry : public Telemetry {
+public:
+ RegisterTelemetry() {}
+ QString key() const override { return "regs"; }
+ QString description() const override { return "register values"; }
+ void report(QTextStream &out) override {
+ auto *isa = ProcessorHandler::currentISA();
+ for (unsigned i = 0; i < isa->regCnt(); i++) {
+ auto v = ProcessorHandler::getRegisterValue(RegisterFileType::GPR, i);
+ out << isa->regName(i) << ":\t"
+ << encodeRadixValue(v, Radix::Signed, isa->bytes()) << "\t";
+ out << "(" << encodeRadixValue(v, Radix::Hex, isa->bytes()) << ")\n";
+ }
+ }
+};
+
} // namespace Ripes

Add # instructions retired and register file telemetry