Add unary variable to CachePlotWidget
MODIFY
src/cachesim/cacheplotwidget.cpp
src/cachesim/cacheplotwidget.cpp
@@ -177,7 +177,7 @@ void CachePlotWidget::savePlot() {
void CachePlotWidget::copyPlotDataToClipboard() const {
std::vector<Variable> allVariables;
- for (int i = 0; i < N_Variables; i++) {
+ for (int i = 0; i < N_TraceVars; i++) {
allVariables.push_back(static_cast<Variable>(i));
}
const auto& allData = gatherData();
@@ -227,7 +227,7 @@ std::map<CachePlotWidget::Variable, QList<QPoint>> CachePlotWidget::gatherData(u
std::map<Variable, QList<QPoint>> cacheData;
const auto& trace = m_cache->getAccessTrace();
- for (int i = 0; i < N_Variables; i++) {
+ for (int i = 0; i < N_TraceVars; i++) {
cacheData[static_cast<Variable>(i)].reserve(trace.size());
}
@@ -273,7 +273,7 @@ void resample(QLineSeries* series, unsigned target, double& step) {
void CachePlotWidget::updateRatioPlot() {
const auto newCacheData = gatherData(m_lastCyclePlotted);
- const int nNewPoints = newCacheData.at(m_numerator).size();
+ const int nNewPoints = newCacheData.at(Accesses).size();
if (nNewPoints == 0) {
return;
}
@@ -291,9 +291,7 @@ void CachePlotWidget::updateRatioPlot() {
}
};
- const auto& numerator = newCacheData.at(m_numerator);
- const auto& denominator = newCacheData.at(m_denominator);
- m_lastCyclePlotted = numerator.last().x();
+ m_lastCyclePlotted = newCacheData.at(Accesses).last().x();
QList<QPointF> newPoints;
QList<QPointF> newWindowPoints;
@@ -304,9 +302,12 @@ void CachePlotWidget::updateRatioPlot() {
lastPoint = QPointF(-1, 0);
}
for (int i = 0; i < nNewPoints; i++) {
- // Cummulative plot
- const auto& p1 = numerator.at(i);
- const auto& p2 = denominator.at(i);
+ // Cummulative plot. For the unary variable, "Accesses" is just used to index into the cache data for accessing
+ // the x variable.
+ const auto& p1 =
+ m_numerator == Unary ? QPoint(newCacheData.at(Accesses).at(i).x(), 1) : newCacheData.at(m_numerator).at(i);
+ const auto& p2 = m_denominator == Unary ? QPoint(newCacheData.at(Accesses).at(i).x(), 1)
+ : newCacheData.at(m_denominator).at(i);
Q_ASSERT(p1.x() == p2.x() && "Data inconsistency");
double ratio = 0;
if (p2.y() != 0) {

MODIFY
src/cachesim/cacheplotwidget.h
src/cachesim/cacheplotwidget.h
@@ -44,7 +44,7 @@ class CachePlotWidget : public QWidget {
Q_OBJECT
public:
- enum Variable { Writes = 0, Reads, Hits, Misses, Writebacks, Accesses, N_Variables };
+ enum Variable { Writes = 0, Reads, Hits, Misses, Writebacks, Accesses, N_TraceVars, Unary };
explicit CachePlotWidget(QWidget* parent = nullptr);
void setCache(std::shared_ptr<CacheSim> cache);
~CachePlotWidget();
@@ -109,7 +109,9 @@ const static std::map<CachePlotWidget::Variable, QString> s_cacheVariableStrings
{CachePlotWidget::Variable::Hits, "Hits"},
{CachePlotWidget::Variable::Misses, "Misses"},
{CachePlotWidget::Variable::Writebacks, "Writebacks"},
- {CachePlotWidget::Variable::Accesses, "Total accesses"}};
+ {CachePlotWidget::Variable::Accesses, "Total accesses"},
+ {CachePlotWidget::Variable::Unary, "1"},
+};
} // namespace Ripes

Add unary variable to CachePlotWidget