Include average bandwidth windowing.

This commit is contained in:
Lukas Steiner
2020-11-11 09:51:31 +01:00
parent ed8ee0ec06
commit 3be2d9f56b
10 changed files with 76 additions and 18 deletions

View File

@@ -7,6 +7,7 @@ DROP TABLE IF EXISTS Transactions;
DROP TABLE IF EXISTS DebugMessages;
DROP TABLE IF EXISTS Power;
DROP TABLE IF EXISTS BufferDepth;
DROP TABLE IF EXISTS Bandwidth;
CREATE TABLE Phases(
ID INTEGER PRIMARY KEY,
@@ -66,6 +67,11 @@ CREATE TABLE BufferDepth(
AverageBufferDepth DOUBLE
);
CREATE TABLE Bandwidth(
Time DOUBLE,
AverageBandwidth DOUBLE
);
CREATE TABLE Comments(
Time INTEGER,
Text TEXT

View File

@@ -81,6 +81,7 @@ TlmRecorder::~TlmRecorder()
sqlite3_finalize(updateDataStrobeStatement);
sqlite3_finalize(insertPowerStatement);
sqlite3_finalize(insertBufferDepthStatement);
sqlite3_finalize(insertBandwidthStatement);
}
void TlmRecorder::recordPower(double timeInSeconds, double averagePower)
@@ -101,6 +102,13 @@ void TlmRecorder::recordBufferDepth(double timeInSeconds, const std::vector<doub
}
}
void TlmRecorder::recordBandwidth(double timeInSeconds, double averageBandwidth)
{
sqlite3_bind_double(insertBandwidthStatement, 1, timeInSeconds);
sqlite3_bind_double(insertBandwidthStatement, 2, averageBandwidth);
executeSqlStatement(insertBandwidthStatement);
}
void TlmRecorder::recordPhase(tlm_generic_payload &trans,
tlm_phase phase, sc_time time)
{
@@ -323,6 +331,7 @@ void TlmRecorder::prepareSqlStatements()
insertPowerString = "INSERT INTO Power VALUES (:time,:averagePower)";
insertBufferDepthString = "INSERT INTO BufferDepth VALUES (:time,:bufferNumber,:averageBufferDepth)";
insertBandwidthString = "INSERT INTO Bandwidth VALUES (:time,:averageBandwidth)";
sqlite3_prepare_v2(db, insertTransactionString.c_str(), -1, &insertTransactionStatement, 0);
sqlite3_prepare_v2(db, insertRangeString.c_str(), -1, &insertRangeStatement, 0);
@@ -335,6 +344,7 @@ void TlmRecorder::prepareSqlStatements()
sqlite3_prepare_v2(db, insertDebugMessageString.c_str(), -1, &insertDebugMessageStatement, 0);
sqlite3_prepare_v2(db, insertPowerString.c_str(), -1, &insertPowerStatement, 0);
sqlite3_prepare_v2(db, insertBufferDepthString.c_str(), -1, &insertBufferDepthStatement, 0);
sqlite3_prepare_v2(db, insertBandwidthString.c_str(), -1, &insertBandwidthStatement, 0);
}
void TlmRecorder::insertDebugMessageInDB(std::string message, const sc_time &time)

View File

@@ -78,6 +78,7 @@ public:
sc_time time);
void recordPower(double timeInSeconds, double averagePower);
void recordBufferDepth(double timeInSeconds, const std::vector<double> &averageBufferDepth);
void recordBandwidth(double timeInSeconds, double averageBandwidth);
void recordDebugMessage(std::string message, sc_time time);
void updateDataStrobe(const sc_time &begin, const sc_time &end,
tlm::tlm_generic_payload &trans);
@@ -145,11 +146,11 @@ private:
*updateRangeStatement, *insertPhaseStatement, *updatePhaseStatement,
*insertGeneralInfoStatement, *insertCommandLengthsStatement,
*insertDebugMessageStatement, *updateDataStrobeStatement,
*insertPowerStatement, *insertBufferDepthStatement;
*insertPowerStatement, *insertBufferDepthStatement, *insertBandwidthStatement;
std::string insertTransactionString, insertRangeString, updateRangeString, insertPhaseString,
updatePhaseString, insertGeneralInfoString, insertCommandLengthsString,
insertDebugMessageString, updateDataStrobeString, insertPowerString,
insertBufferDepthString;
insertBufferDepthString, insertBandwidthString;
};
#endif // TLMRECORDER_H

View File

@@ -422,6 +422,7 @@ void Controller::startBeginResp()
{
transToRelease.time = sc_max_time();
sendToFrontend(transToRelease.payload, BEGIN_RESP);
numberOfTransactionsServed++;
}
else
{
@@ -441,7 +442,6 @@ void Controller::finishEndResp()
transToRelease.payload->release();
transToRelease.payload = nullptr;
numberOfTransactionsServed++;
totalNumberOfPayloads--;
if (totalNumberOfPayloads == 0)

View File

@@ -40,11 +40,12 @@ using namespace tlm;
ControllerRecordable::ControllerRecordable(sc_module_name name, TlmRecorder *tlmRecorder)
: Controller(name), tlmRecorder(tlmRecorder)
{
sensitive << bufferDepthWindowEvent;
bufferDepthWindowSize = Configuration::getInstance().windowSize * memSpec->tCK;
sensitive << windowEvent;
windowSizeTime = Configuration::getInstance().windowSize * memSpec->tCK;
slidingAverageBufferDepth = std::vector<sc_time>(scheduler->getBufferDepth().size());
averageBufferDepth = std::vector<double>(scheduler->getBufferDepth().size());
bufferDepthWindowEvent.notify(bufferDepthWindowSize);
windowAverageBufferDepth = std::vector<double>(scheduler->getBufferDepth().size());
windowEvent.notify(windowSizeTime);
nextWindowEventTime = windowSizeTime;
}
tlm_sync_enum ControllerRecordable::nb_transport_fw(tlm_generic_payload &trans,
@@ -104,25 +105,35 @@ void ControllerRecordable::recordPhase(tlm_generic_payload &trans, tlm_phase pha
void ControllerRecordable::controllerMethod()
{
sc_time timeDiff = sc_time_stamp() - lastTimeCalled;
lastTimeCalled = sc_time_stamp();
const std::vector<unsigned> &bufferDepth = scheduler->getBufferDepth();
for (size_t index = 0; index < slidingAverageBufferDepth.size(); index++)
slidingAverageBufferDepth[index] += bufferDepth[index] * timeDiff;
lastTimeCalled = sc_time_stamp();
if (sc_time_stamp() % bufferDepthWindowSize == SC_ZERO_TIME && timeDiff != SC_ZERO_TIME)
if (sc_time_stamp() == nextWindowEventTime)
{
bufferDepthWindowEvent.notify(bufferDepthWindowSize);
windowEvent.notify(windowSizeTime);
nextWindowEventTime += windowSizeTime;
for (size_t index = 0; index < slidingAverageBufferDepth.size(); index++)
{
averageBufferDepth[index] = slidingAverageBufferDepth[index] / bufferDepthWindowSize;
windowAverageBufferDepth[index] = slidingAverageBufferDepth[index] / windowSizeTime;
slidingAverageBufferDepth[index] = SC_ZERO_TIME;
}
tlmRecorder->recordBufferDepth(sc_time_stamp().to_seconds(), averageBufferDepth);
}
tlmRecorder->recordBufferDepth(sc_time_stamp().to_seconds(), windowAverageBufferDepth);
Controller::controllerMethod();
Controller::controllerMethod();
uint64_t windowNumberOfTransactionsServed = numberOfTransactionsServed - lastNumberOfTransactionsServed;
lastNumberOfTransactionsServed = numberOfTransactionsServed;
sc_time windowActiveTime = windowNumberOfTransactionsServed * activeTimeMultiplier;
double windowAverageBandwidth = windowActiveTime / windowSizeTime;
tlmRecorder->recordBandwidth(sc_time_stamp().to_seconds(), windowAverageBandwidth);
}
else
{
Controller::controllerMethod();
}
}

View File

@@ -59,11 +59,17 @@ private:
void recordPhase(tlm::tlm_generic_payload &trans, tlm::tlm_phase phase, sc_time delay);
TlmRecorder *tlmRecorder;
sc_event bufferDepthWindowEvent;
sc_time bufferDepthWindowSize;
sc_event windowEvent;
sc_time windowSizeTime;
sc_time nextWindowEventTime;
std::vector<sc_time> slidingAverageBufferDepth;
std::vector<double> averageBufferDepth;
std::vector<double> windowAverageBufferDepth;
sc_time lastTimeCalled = SC_ZERO_TIME;
uint64_t lastNumberOfTransactionsServed = 0;
sc_time activeTimeMultiplier = Configuration::getInstance().memSpec->burstLength
/ Configuration::getInstance().memSpec->dataRate
* Configuration::getInstance().memSpec->tCK;
};
#endif // CONTROLLERRECORDABLE_H

View File

@@ -7,6 +7,7 @@ DROP TABLE IF EXISTS Transactions;
DROP TABLE IF EXISTS DebugMessages;
DROP TABLE IF EXISTS Power;
DROP TABLE IF EXISTS BufferDepth;
DROP TABLE IF EXISTS Bandwidth;
CREATE TABLE Phases(
ID INTEGER PRIMARY KEY,
@@ -66,6 +67,11 @@ CREATE TABLE BufferDepth(
AverageBufferDepth DOUBLE
);
CREATE TABLE Bandwidth(
Time DOUBLE,
AverageBandwidth DOUBLE
);
CREATE TABLE Comments(
Time INTEGER,
Text TEXT

View File

@@ -7,6 +7,7 @@ DROP TABLE IF EXISTS Transactions;
DROP TABLE IF EXISTS DebugMessages;
DROP TABLE IF EXISTS Power;
DROP TABLE IF EXISTS BufferDepth;
DROP TABLE IF EXISTS Bandwidth;
CREATE TABLE Phases(
ID INTEGER PRIMARY KEY,
@@ -66,6 +67,11 @@ CREATE TABLE BufferDepth(
AverageBufferDepth DOUBLE
);
CREATE TABLE Bandwidth(
Time DOUBLE,
AverageBandwidth DOUBLE
);
CREATE TABLE Comments(
Time INTEGER,
Text TEXT

View File

@@ -7,6 +7,7 @@ DROP TABLE IF EXISTS Transactions;
DROP TABLE IF EXISTS DebugMessages;
DROP TABLE IF EXISTS Power;
DROP TABLE IF EXISTS BufferDepth;
DROP TABLE IF EXISTS Bandwidth;
CREATE TABLE Phases(
ID INTEGER PRIMARY KEY,
@@ -66,6 +67,11 @@ CREATE TABLE BufferDepth(
AverageBufferDepth DOUBLE
);
CREATE TABLE Bandwidth(
Time DOUBLE,
AverageBandwidth DOUBLE
);
CREATE TABLE Comments(
Time INTEGER,
Text TEXT

View File

@@ -7,6 +7,7 @@ DROP TABLE IF EXISTS Transactions;
DROP TABLE IF EXISTS DebugMessages;
DROP TABLE IF EXISTS Power;
DROP TABLE IF EXISTS BufferDepth;
DROP TABLE IF EXISTS Bandwidth;
CREATE TABLE Phases(
ID INTEGER PRIMARY KEY,
@@ -66,6 +67,11 @@ CREATE TABLE BufferDepth(
AverageBufferDepth DOUBLE
);
CREATE TABLE Bandwidth(
Time DOUBLE,
AverageBandwidth DOUBLE
);
CREATE TABLE Comments(
Time INTEGER,
Text TEXT