From 6988dd10d2e041d245880789eb36a0c0a22856af Mon Sep 17 00:00:00 2001 From: Derek Christ Date: Wed, 11 May 2022 16:25:24 +0200 Subject: [PATCH] Show relevant attributes in Phases in TA --- .../businessObjects/phases/phase.cpp | 6 + .../businessObjects/phases/phase.h | 223 ++++++++++++++++-- .../presentation/transactiontreewidget.cpp | 58 +++-- 3 files changed, 246 insertions(+), 41 deletions(-) diff --git a/DRAMSys/traceAnalyzer/businessObjects/phases/phase.cpp b/DRAMSys/traceAnalyzer/businessObjects/phases/phase.cpp index 5ddec5a2..8f8460b5 100644 --- a/DRAMSys/traceAnalyzer/businessObjects/phases/phase.cpp +++ b/DRAMSys/traceAnalyzer/businessObjects/phases/phase.cpp @@ -372,3 +372,9 @@ void Phase::addDependency(std::shared_ptr dependency) { mDependencies.push_back(dependency); } + +RelevantAttributes Phase::getRelevantAttributes() const +{ + return RelevantAttributes::Rank | RelevantAttributes::Bankgroup | RelevantAttributes::Bank | + RelevantAttributes::Column | RelevantAttributes::Row; +} diff --git a/DRAMSys/traceAnalyzer/businessObjects/phases/phase.h b/DRAMSys/traceAnalyzer/businessObjects/phases/phase.h index 942c8929..29bdfc1f 100644 --- a/DRAMSys/traceAnalyzer/businessObjects/phases/phase.h +++ b/DRAMSys/traceAnalyzer/businessObjects/phases/phase.h @@ -54,6 +54,25 @@ typedef unsigned int ID; //enum TextPositioning; class Transaction; +enum class RelevantAttributes +{ + Rank = 0x01, + Bankgroup = 0x02, + Bank = 0x04, + Row = 0x08, + Column = 0x10 +}; + +inline RelevantAttributes operator|(RelevantAttributes a, RelevantAttributes b) +{ + return static_cast(static_cast(a) | static_cast(b)); +} + +inline RelevantAttributes operator&(RelevantAttributes a, RelevantAttributes b) +{ + return static_cast(static_cast(a) & static_cast(b)); +} + class Phase { public: @@ -70,14 +89,44 @@ public: const TraceDrawingProperties &drawingProperties) const; bool isSelected(Timespan timespan, double yVal, const TraceDrawingProperties &drawingproperties) const; bool isColumnCommand() const; + const Timespan &Span() const { return span; } + ID Id() const { return id; } + + unsigned int getRank() const + { + return rank; + } + + unsigned int getBankgroup() const + { + return bankGroup; + } + + unsigned int getBank() const + { + return bank; + } + + unsigned int getRow() const + { + return row; + } + + unsigned int getColumn() const + { + return column; + } + + virtual RelevantAttributes getRelevantAttributes() const; + virtual QString Name() const = 0; void addDependency(std::shared_ptr dependency); @@ -123,6 +172,7 @@ class REQ final : public Phase { public: using Phase::Phase; + protected: QColor getPhaseColor() const override { @@ -133,6 +183,11 @@ protected: return "REQ"; } + RelevantAttributes getRelevantAttributes() const override + { + return static_cast(0); + } + std::vector getYVals(const TraceDrawingProperties &drawingProperties) const override; }; @@ -140,6 +195,7 @@ class RESP final : public Phase { public: using Phase::Phase; + protected: QColor getPhaseColor() const override { @@ -150,6 +206,11 @@ protected: return "RESP"; } + RelevantAttributes getRelevantAttributes() const override + { + return static_cast(0); + } + std::vector getYVals(const TraceDrawingProperties &drawingProperties) const override; }; /* @@ -172,6 +233,7 @@ class PREPB final : public Phase { public: using Phase::Phase; + protected: QColor getPhaseColor() const override { @@ -181,12 +243,18 @@ protected: { return "PREPB"; } + + RelevantAttributes getRelevantAttributes() const override + { + return RelevantAttributes::Rank | RelevantAttributes::Bankgroup | RelevantAttributes::Bank; + } }; class PRESB final : public Phase { public: using Phase::Phase; + protected: QString Name() const override { @@ -196,10 +264,10 @@ protected: { return {span.Begin()}; } - QColor getColor(const TraceDrawingProperties &drawingProperties) const - override + QColor getColor(const TraceDrawingProperties &drawingProperties) const override { - Q_UNUSED(drawingProperties) return getPhaseColor(); + Q_UNUSED(drawingProperties) + return getPhaseColor(); } QColor getPhaseColor() const override { @@ -209,12 +277,18 @@ protected: { return Granularity::Groupwise; } + + RelevantAttributes getRelevantAttributes() const override + { + return RelevantAttributes::Rank | RelevantAttributes::Bankgroup | RelevantAttributes::Bank; + } }; class PREAB final : public Phase { public: using Phase::Phase; + protected: QString Name() const override { @@ -224,10 +298,10 @@ protected: { return {span.Begin()}; } - QColor getColor(const TraceDrawingProperties &drawingProperties) const - override + QColor getColor(const TraceDrawingProperties &drawingProperties) const override { - Q_UNUSED(drawingProperties) return getPhaseColor(); + Q_UNUSED(drawingProperties) + return getPhaseColor(); } QColor getPhaseColor() const override { @@ -237,6 +311,11 @@ protected: { return Granularity::Rankwise; } + + RelevantAttributes getRelevantAttributes() const override + { + return RelevantAttributes::Rank; + } }; /* class ACTB final : public Phase @@ -258,6 +337,7 @@ class ACT final : public Phase { public: using Phase::Phase; + protected: QColor getPhaseColor() const override { @@ -267,12 +347,19 @@ protected: { return "ACT"; } + + RelevantAttributes getRelevantAttributes() const override + { + return RelevantAttributes::Rank | RelevantAttributes::Bankgroup | RelevantAttributes::Bank | + RelevantAttributes::Row; + } }; class RD final : public Phase { public: using Phase::Phase; + protected: QColor getPhaseColor() const override { @@ -282,12 +369,19 @@ protected: { return "RD"; } + + RelevantAttributes getRelevantAttributes() const override + { + return RelevantAttributes::Rank | RelevantAttributes::Bankgroup | RelevantAttributes::Bank | + RelevantAttributes::Column; + } }; class RDA final : public Phase { public: using Phase::Phase; + protected: QColor getPhaseColor() const override { @@ -297,12 +391,19 @@ protected: { return "RDA"; } + + RelevantAttributes getRelevantAttributes() const override + { + return RelevantAttributes::Rank | RelevantAttributes::Bankgroup | RelevantAttributes::Bank | + RelevantAttributes::Column; + } }; class WR final : public Phase { public: using Phase::Phase; + protected: QColor getPhaseColor() const override { @@ -312,12 +413,19 @@ protected: { return "WR"; } + + RelevantAttributes getRelevantAttributes() const override + { + return RelevantAttributes::Rank | RelevantAttributes::Bankgroup | RelevantAttributes::Bank | + RelevantAttributes::Column; + } }; class WRA final : public Phase { public: using Phase::Phase; + protected: QColor getPhaseColor() const override { @@ -327,12 +435,19 @@ protected: { return "WRA"; } + + RelevantAttributes getRelevantAttributes() const override + { + return RelevantAttributes::Rank | RelevantAttributes::Bankgroup | RelevantAttributes::Bank | + RelevantAttributes::Column; + } }; class AUTO_REFRESH : public Phase { public: using Phase::Phase; + protected: QString Name() const override { @@ -342,10 +457,10 @@ protected: { return {span.Begin()}; } - QColor getColor(const TraceDrawingProperties &drawingProperties) const - override + QColor getColor(const TraceDrawingProperties &drawingProperties) const override { - Q_UNUSED(drawingProperties) return getPhaseColor(); + Q_UNUSED(drawingProperties) + return getPhaseColor(); } QColor getPhaseColor() const override { @@ -359,6 +474,7 @@ class REFAB final : public AUTO_REFRESH { public: using AUTO_REFRESH::AUTO_REFRESH; + protected: QString Name() const override { @@ -368,12 +484,18 @@ protected: { return Granularity::Rankwise; } + + RelevantAttributes getRelevantAttributes() const override + { + return RelevantAttributes::Rank; + } }; class RFMAB final : public AUTO_REFRESH { public: using AUTO_REFRESH::AUTO_REFRESH; + protected: QString Name() const override { @@ -389,23 +511,35 @@ protected: phaseColor.setAlpha(130); return phaseColor; } + + RelevantAttributes getRelevantAttributes() const override + { + return RelevantAttributes::Rank; + } }; class REFPB final : public AUTO_REFRESH { public: using AUTO_REFRESH::AUTO_REFRESH; + protected: QString Name() const override { return "REFPB"; } + + RelevantAttributes getRelevantAttributes() const override + { + return RelevantAttributes::Rank | RelevantAttributes::Bankgroup | RelevantAttributes::Bank; + } }; class RFMPB final : public AUTO_REFRESH { public: using AUTO_REFRESH::AUTO_REFRESH; + protected: QString Name() const override { @@ -417,12 +551,18 @@ protected: phaseColor.setAlpha(130); return phaseColor; } + + RelevantAttributes getRelevantAttributes() const override + { + return RelevantAttributes::Rank | RelevantAttributes::Bankgroup | RelevantAttributes::Bank; + } }; class REFP2B final : public AUTO_REFRESH { public: using AUTO_REFRESH::AUTO_REFRESH; + protected: QString Name() const override { @@ -432,12 +572,18 @@ protected: { return Granularity::TwoBankwise; } + + RelevantAttributes getRelevantAttributes() const override + { + return RelevantAttributes::Rank | RelevantAttributes::Bankgroup | RelevantAttributes::Bank; + } }; class RFMP2B final : public AUTO_REFRESH { public: using AUTO_REFRESH::AUTO_REFRESH; + protected: QString Name() const override { @@ -453,12 +599,18 @@ protected: phaseColor.setAlpha(130); return phaseColor; } + + RelevantAttributes getRelevantAttributes() const override + { + return RelevantAttributes::Rank | RelevantAttributes::Bankgroup | RelevantAttributes::Bank; + } }; class REFSB final : public AUTO_REFRESH { public: using AUTO_REFRESH::AUTO_REFRESH; + protected: QString Name() const override { @@ -468,12 +620,18 @@ protected: { return Granularity::Groupwise; } + + RelevantAttributes getRelevantAttributes() const override + { + return RelevantAttributes::Rank | RelevantAttributes::Bankgroup | RelevantAttributes::Bank; + } }; class RFMSB final : public AUTO_REFRESH { public: using AUTO_REFRESH::AUTO_REFRESH; + protected: QString Name() const override { @@ -489,6 +647,11 @@ protected: phaseColor.setAlpha(130); return phaseColor; } + + RelevantAttributes getRelevantAttributes() const override + { + return RelevantAttributes::Rank | RelevantAttributes::Bankgroup | RelevantAttributes::Bank; + } }; class PDNAB : public Phase @@ -506,10 +669,10 @@ protected: { return Qt::Dense6Pattern; } - QColor getColor(const TraceDrawingProperties &drawingProperties) const - override + QColor getColor(const TraceDrawingProperties &drawingProperties) const override { - Q_UNUSED(drawingProperties) return getPhaseColor(); + Q_UNUSED(drawingProperties) + return getPhaseColor(); } QColor getPhaseColor() const override { @@ -519,12 +682,18 @@ protected: { return PhaseSymbol::Rect; } + + RelevantAttributes getRelevantAttributes() const override + { + return RelevantAttributes::Rank; + } }; class PDNA final : public PDNAB { public: using PDNAB::PDNAB; + protected: QString Name() const override { @@ -534,6 +703,11 @@ protected: { return Granularity::Rankwise; } + + RelevantAttributes getRelevantAttributes() const override + { + return RelevantAttributes::Rank; + } }; class PDNPB : public Phase @@ -551,10 +725,10 @@ protected: { return Qt::Dense4Pattern; } - QColor getColor(const TraceDrawingProperties &drawingProperties) const - override + QColor getColor(const TraceDrawingProperties &drawingProperties) const override { - Q_UNUSED(drawingProperties) return getPhaseColor(); + Q_UNUSED(drawingProperties) + return getPhaseColor(); } QColor getPhaseColor() const override { @@ -564,12 +738,18 @@ protected: { return PhaseSymbol::Rect; } + + RelevantAttributes getRelevantAttributes() const override + { + return RelevantAttributes::Rank | RelevantAttributes::Bankgroup | RelevantAttributes::Bank; + } }; class PDNP final : public PDNPB { public: using PDNPB::PDNPB; + protected: QString Name() const override { @@ -596,10 +776,10 @@ protected: { return Qt::Dense1Pattern; } - QColor getColor(const TraceDrawingProperties &drawingProperties) const - override + QColor getColor(const TraceDrawingProperties &drawingProperties) const override { - Q_UNUSED(drawingProperties) return getPhaseColor(); + Q_UNUSED(drawingProperties) + return getPhaseColor(); } QColor getPhaseColor() const override { @@ -609,12 +789,18 @@ protected: { return PhaseSymbol::Rect; } + + RelevantAttributes getRelevantAttributes() const override + { + return RelevantAttributes::Rank | RelevantAttributes::Bankgroup | RelevantAttributes::Bank; + } }; class SREF : public SREFB { public: using SREFB::SREFB; + protected: QString Name() const override { @@ -626,5 +812,4 @@ protected: } }; - #endif // BANKPHASE_H diff --git a/DRAMSys/traceAnalyzer/presentation/transactiontreewidget.cpp b/DRAMSys/traceAnalyzer/presentation/transactiontreewidget.cpp index 96c6617a..6f65ce58 100644 --- a/DRAMSys/traceAnalyzer/presentation/transactiontreewidget.cpp +++ b/DRAMSys/traceAnalyzer/presentation/transactiontreewidget.cpp @@ -38,16 +38,14 @@ #include "transactiontreewidget.h" #include "data/tracedb.h" #include -#include #include +#include using namespace std; -TransactionTreeWidget::TransactionTreeWidget(QWidget *parent) : QTreeWidget( - parent), isInitialized(false) +TransactionTreeWidget::TransactionTreeWidget(QWidget *parent) : QTreeWidget(parent), isInitialized(false) { - QObject::connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, - SLOT(ContextMenuRequested(QPoint))); + QObject::connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(ContextMenuRequested(QPoint))); setContextMenuPolicy(Qt::CustomContextMenu); goToTransaction = new QAction("Move to", this); } @@ -62,19 +60,17 @@ void TransactionTreeWidget::init(TraceNavigator *navigator) setHeaderLabels(QStringList({"Transaction", "Value", "Value"})); } -void TransactionTreeWidget::AppendTransaction(const shared_ptr - &transaction) +void TransactionTreeWidget::AppendTransaction(const shared_ptr &transaction) { - QTreeWidgetItem *node = new TransactionTreeItem(this, transaction, - navigator->GeneralTraceInfo()); + QTreeWidgetItem *node = new TransactionTreeItem(this, transaction, navigator->GeneralTraceInfo()); addTopLevelItem(node); } void TransactionTreeWidget::ContextMenuRequested(QPoint point) { - if (selectedItems().count() > 0 - && selectedItems().at(0)->type() == - TransactionTreeWidget::TransactionTreeItem::transactionTreeItemType) { + if (selectedItems().count() > 0 && + selectedItems().at(0)->type() == TransactionTreeWidget::TransactionTreeItem::transactionTreeItemType) + { QMenu contextMenu; contextMenu.addActions({goToTransaction}); QAction *selectedContextMenuItems = contextMenu.exec(mapToGlobal(point)); @@ -97,16 +93,10 @@ TransactionTreeWidget::TransactionTreeItem::TransactionTreeItem(QTreeWidget *par bool isControllerTransaction = (transaction->thread == generalInfo.controllerThread); - auto* time = new QTreeWidgetItem({"Timespan"}); + auto *time = new QTreeWidgetItem({"Timespan"}); AppendTimespan(time, transaction->span); this->addChild(time); this->addChild(new QTreeWidgetItem({"Length", prettyFormatTime(transaction->span.timeCovered())})); - // TODO: move to phase - //this->addChild(new QTreeWidgetItem({"Rank", QString::number(transaction->rank)})); - //this->addChild(new QTreeWidgetItem({"Bankgroup", QString::number(transaction->bankgroup % generalInfo.groupsPerRank)})); - //this->addChild(new QTreeWidgetItem({"Bank", QString::number(transaction->bank % generalInfo.banksPerGroup)})); - //this->addChild(new QTreeWidgetItem({"Row", QString::number(transaction->row)})); - //this->addChild(new QTreeWidgetItem({"Column", QString::number(transaction->column)})); this->addChild(new QTreeWidgetItem({"Address", QString("0x") + QString::number(transaction->address, 16)})); if (!isControllerTransaction) this->addChild(new QTreeWidgetItem({"Data Length", QString::number(transaction->dataLength)})); @@ -114,20 +104,44 @@ TransactionTreeWidget::TransactionTreeItem::TransactionTreeItem(QTreeWidget *par if (!isControllerTransaction) this->addChild(new QTreeWidgetItem({"Thread", QString::number(transaction->thread)})); - auto* phasesNode = new QTreeWidgetItem(this); + auto *phasesNode = new QTreeWidgetItem(this); phasesNode->setText(0, "Phases"); phasesNode->addChild(new QTreeWidgetItem({"", "Begin", "End"})); - for (const std::shared_ptr& phase : transaction->Phases()) + for (const std::shared_ptr &phase : transaction->Phases()) AppendPhase(phasesNode, *phase); } void TransactionTreeWidget::TransactionTreeItem::AppendPhase(QTreeWidgetItem *parent, const Phase &phase) { - auto* node = new QTreeWidgetItem(parent); + auto *node = new QTreeWidgetItem(parent); node->setText(0, phase.Name() + QString(" [") + QString::number(phase.Id()) + QString("]")); AppendTimespan(node, phase.Span()); + + auto addMapping = [node](std::string_view label, unsigned value) + { + auto *mappingNode = new QTreeWidgetItem(node); + mappingNode->setText(0, label.data()); + mappingNode->setText(1, QString::number(value)); + }; + + { + if (static_cast(phase.getRelevantAttributes() & RelevantAttributes::Rank)) + addMapping("Rank", phase.getRank()); + + if (static_cast(phase.getRelevantAttributes() & RelevantAttributes::Bankgroup)) + addMapping("Bankgroup", phase.getBankgroup()); + + if (static_cast(phase.getRelevantAttributes() & RelevantAttributes::Bank)) + addMapping("Bank", phase.getBank()); + + if (static_cast(phase.getRelevantAttributes() & RelevantAttributes::Row)) + addMapping("Row", phase.getRow()); + + if (static_cast(phase.getRelevantAttributes() & RelevantAttributes::Column)) + addMapping("Column", phase.getColumn()); + } } void TransactionTreeWidget::TransactionTreeItem::AppendTimespan(QTreeWidgetItem *parent, const Timespan ×pan)