From c5f89293bd7c982b4c5341f364df3c74e6302eb4 Mon Sep 17 00:00:00 2001 From: Lukas Steiner Date: Mon, 23 Nov 2020 11:50:44 +0100 Subject: [PATCH] Insert window bandwidth/buffer depth only when windowing is enabled. --- .../src/controller/ControllerRecordable.cpp | 66 +++++++++++-------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/DRAMSys/library/src/controller/ControllerRecordable.cpp b/DRAMSys/library/src/controller/ControllerRecordable.cpp index 076e5f04..c8ab5efd 100644 --- a/DRAMSys/library/src/controller/ControllerRecordable.cpp +++ b/DRAMSys/library/src/controller/ControllerRecordable.cpp @@ -40,12 +40,15 @@ using namespace tlm; ControllerRecordable::ControllerRecordable(sc_module_name name, TlmRecorder *tlmRecorder) : Controller(name), tlmRecorder(tlmRecorder) { - sensitive << windowEvent; - windowSizeTime = Configuration::getInstance().windowSize * memSpec->tCK; - slidingAverageBufferDepth = std::vector(scheduler->getBufferDepth().size()); - windowAverageBufferDepth = std::vector(scheduler->getBufferDepth().size()); - windowEvent.notify(windowSizeTime); - nextWindowEventTime = windowSizeTime; + if (Configuration::getInstance().enableWindowing) + { + sensitive << windowEvent; + windowSizeTime = Configuration::getInstance().windowSize * memSpec->tCK; + slidingAverageBufferDepth = std::vector(scheduler->getBufferDepth().size()); + windowAverageBufferDepth = std::vector(scheduler->getBufferDepth().size()); + windowEvent.notify(windowSizeTime); + nextWindowEventTime = windowSizeTime; + } } tlm_sync_enum ControllerRecordable::nb_transport_fw(tlm_generic_payload &trans, @@ -104,33 +107,40 @@ 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 &bufferDepth = scheduler->getBufferDepth(); - - for (size_t index = 0; index < slidingAverageBufferDepth.size(); index++) - slidingAverageBufferDepth[index] += bufferDepth[index] * timeDiff; - - if (sc_time_stamp() == nextWindowEventTime) + if (Configuration::getInstance().enableWindowing) { - windowEvent.notify(windowSizeTime); - nextWindowEventTime += windowSizeTime; + sc_time timeDiff = sc_time_stamp() - lastTimeCalled; + lastTimeCalled = sc_time_stamp(); + const std::vector &bufferDepth = scheduler->getBufferDepth(); for (size_t index = 0; index < slidingAverageBufferDepth.size(); index++) + slidingAverageBufferDepth[index] += bufferDepth[index] * timeDiff; + + if (sc_time_stamp() == nextWindowEventTime) { - windowAverageBufferDepth[index] = slidingAverageBufferDepth[index] / windowSizeTime; - slidingAverageBufferDepth[index] = SC_ZERO_TIME; + windowEvent.notify(windowSizeTime); + nextWindowEventTime += windowSizeTime; + + for (size_t index = 0; index < slidingAverageBufferDepth.size(); index++) + { + windowAverageBufferDepth[index] = slidingAverageBufferDepth[index] / windowSizeTime; + slidingAverageBufferDepth[index] = SC_ZERO_TIME; + } + + tlmRecorder->recordBufferDepth(sc_time_stamp().to_seconds(), windowAverageBufferDepth); + + 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(); } - - tlmRecorder->recordBufferDepth(sc_time_stamp().to_seconds(), windowAverageBufferDepth); - - 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 {