Add pipeline diagram telemetry
MODIFY
src/cmd/cmdoptions.cpp
src/cmd/cmdoptions.cpp
@@ -53,6 +53,7 @@ void addCmdOptions(QCommandLineParser &parser, Ripes::CmdModeOptions &options) {
options.telemetry.push_back(std::make_shared<CyclesTelemetry>());
options.telemetry.push_back(std::make_shared<CPITelemetry>());
options.telemetry.push_back(std::make_shared<IPCTelemetry>());
+ options.telemetry.push_back(std::make_shared<PipelineTelemetry>());
for (auto &telemetry : options.telemetry) {
QCommandLineOption telemetryOption(telemetry->key(),

MODIFY
src/cmd/telemetry.h
src/cmd/telemetry.h
#include <QTextStream>
+#include "pipelinediagrammodel.h"
#include "processorhandler.h"
+#include <memory>
+
namespace Ripes {
/// A class for
@@ -71,4 +74,25 @@ class CyclesTelemetry : public Telemetry {
}
};
+class PipelineTelemetry : public Telemetry {
+public:
+ PipelineTelemetry() {
+ // The PipelineDiagramModel will automatically, upon construction, connect
+ // to the ProcessorHandler and record information during execution.
+ m_pipelineDiagramModel = std::make_shared<PipelineDiagramModel>();
+ }
+
+ QString key() const override { return "pipeline"; }
+ QString description() const override { return "Report 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;
+};
+
} // namespace Ripes

MODIFY
src/pipelinediagrammodel.cpp
src/pipelinediagrammodel.cpp
@@ -73,11 +73,13 @@ void PipelineDiagramModel::prepareForView() {
void PipelineDiagramModel::gatherStageInfo() {
long long cycleCount = ProcessorHandler::getProcessor()->getCycleCount();
auto stageInfoForCycle = m_cycleStageInfos.find(cycleCount);
- if (stageInfoForCycle == m_cycleStageInfos.end()) {
+ if (stageInfoForCycle != m_cycleStageInfos.end()) {
+ // Already gathered stage info for this cycle.
return;
}
+ m_cycleStageInfos[cycleCount];
for (auto idx : ProcessorHandler::getProcessor()->structure().stageIt())
- stageInfoForCycle->second[idx] =
+ m_cycleStageInfos[cycleCount][idx] =
ProcessorHandler::getProcessor()->stageInfo(idx);
}
@@ -130,4 +132,28 @@ QVariant PipelineDiagramModel::data(const QModelIndex &index, int role) const {
return stagesForAddr.join('/');
}
+
+QString PipelineDiagramModel::toString() const {
+ QString textualRepr;
+
+ // Copy headers
+ textualRepr.append('\t');
+ for (int j = 0; j < columnCount(); j++) {
+ textualRepr.append(headerData(j, Qt::Horizontal).toString());
+ textualRepr.append('\t');
+ }
+ textualRepr.append('\n');
+ // Copy data
+ for (int i = 0; i < rowCount(); ++i) {
+ textualRepr.append(headerData(i, Qt::Vertical).toString());
+ textualRepr.append('\t');
+ for (int j = 0; j < columnCount(); j++) {
+ textualRepr.append(data(index(i, j)).toString());
+ textualRepr.append('\t');
+ }
+ textualRepr.append('\n');
+ }
+ return textualRepr;
+}
+
} // namespace Ripes

MODIFY
src/pipelinediagrammodel.h
src/pipelinediagrammodel.h
@@ -20,6 +20,9 @@ public:
int role = Qt::DisplayRole) const override;
void prepareForView();
+ /// Returns a tab-separated stringified version of this pipeline diagram.
+ QString toString() const;
+
public slots:
void processorWasClocked();
void reset();

Add pipeline diagram telemetry