Moved ifs from the method body to the invocation

This commit is contained in:
Jonathan Hager
2025-04-10 10:21:58 +02:00
parent 950dbd690d
commit 8266d825f3
3 changed files with 54 additions and 64 deletions

View File

@@ -11,10 +11,10 @@ namespace DRAMSys
{
TlmRecorderController::TlmRecorderController(const sc_core::sc_module_name& name,
const SimConfig& simConfig,
const MemSpec& memSpec,
TlmRecorder& tlmRecorder,
bool enableBandwidth) :
const SimConfig& simConfig,
const MemSpec& memSpec,
TlmRecorder& tlmRecorder,
bool enableBandwidth) :
sc_module(name),
memSpec(memSpec),
tlmRecorder(tlmRecorder),
@@ -31,22 +31,20 @@ TlmRecorderController::TlmRecorderController(const sc_core::sc_module_name& name
tSocket.register_b_transport(this, &TlmRecorderController::b_transport);
tSocket.register_transport_dbg(this, &TlmRecorderController::transport_dbg);
if (enableBandwidth)
if (enableBandwidth && enableWindowing)
{
SC_METHOD(recordBandwidth);
dont_initialize();
sensitive << windowEvent;
if (enableWindowing)
{
windowEvent.notify(windowSizeTime);
nextWindowEventTime = windowSizeTime;
}
windowEvent.notify(windowSizeTime);
nextWindowEventTime = windowSizeTime;
}
}
tlm::tlm_sync_enum TlmRecorderController::nb_transport_fw(tlm::tlm_generic_payload& trans,
tlm::tlm_phase& phase,
sc_core::sc_time& delay)
tlm::tlm_phase& phase,
sc_core::sc_time& delay)
{
if (enableBandwidth && enableWindowing)
{
@@ -59,8 +57,8 @@ tlm::tlm_sync_enum TlmRecorderController::nb_transport_fw(tlm::tlm_generic_paylo
}
tlm::tlm_sync_enum TlmRecorderController::nb_transport_bw(tlm::tlm_generic_payload& trans,
tlm::tlm_phase& phase,
sc_core::sc_time& delay)
tlm::tlm_phase& phase,
sc_core::sc_time& delay)
{
if (enableBandwidth && enableWindowing)
{
@@ -84,22 +82,19 @@ unsigned int TlmRecorderController::transport_dbg(tlm::tlm_generic_payload& tran
void TlmRecorderController::recordBandwidth()
{
if (enableBandwidth && enableWindowing && sc_core::sc_time_stamp() == nextWindowEventTime)
{
windowEvent.notify(windowSizeTime);
nextWindowEventTime += windowSizeTime;
windowEvent.notify(windowSizeTime);
nextWindowEventTime += windowSizeTime;
uint64_t windowNumberOfBytesServed = numberOfBytesServed - lastNumberOfBytesServed;
lastNumberOfBytesServed = numberOfBytesServed;
uint64_t windowNumberOfBytesServed = numberOfBytesServed - lastNumberOfBytesServed;
lastNumberOfBytesServed = numberOfBytesServed;
// HBM specific, pseudo channels get averaged
if (pseudoChannelMode)
windowNumberOfBytesServed /= ranksPerChannel;
// HBM specific, pseudo channels get averaged
if (pseudoChannelMode)
windowNumberOfBytesServed /= ranksPerChannel;
double windowBandwidth =
static_cast<double>(windowNumberOfBytesServed) / (windowSizeTime.to_seconds());
tlmRecorder.recordBandwidth(sc_core::sc_time_stamp().to_seconds(), windowBandwidth);
}
double windowBandwidth =
static_cast<double>(windowNumberOfBytesServed) / (windowSizeTime.to_seconds());
tlmRecorder.recordBandwidth(sc_core::sc_time_stamp().to_seconds(), windowBandwidth);
}
} // namespace DRAMSys

View File

@@ -29,16 +29,14 @@ TlmRecorderDram::TlmRecorderDram(const sc_core::sc_module_name& name,
tSocket.register_b_transport(this, &TlmRecorderDram::b_transport);
tSocket.register_transport_dbg(this, &TlmRecorderDram::transport_dbg);
if (enableBandwidth)
if (enableBandwidth && enableWindowing)
{
SC_METHOD(recordBandwidth);
dont_initialize();
sensitive << windowEvent;
if (enableWindowing)
{
windowEvent.notify(windowSizeTime);
nextWindowEventTime = windowSizeTime;
}
windowEvent.notify(windowSizeTime);
nextWindowEventTime = windowSizeTime;
}
}
@@ -81,26 +79,23 @@ unsigned int TlmRecorderDram::transport_dbg(tlm::tlm_generic_payload& trans)
void TlmRecorderDram::recordBandwidth()
{
if (enableBandwidth && enableWindowing && sc_core::sc_time_stamp() == nextWindowEventTime)
{
windowEvent.notify(windowSizeTime);
nextWindowEventTime += windowSizeTime;
windowEvent.notify(windowSizeTime);
nextWindowEventTime += windowSizeTime;
std::uint64_t totalNumberOfBeatsServed =
std::accumulate(numberOfBeatsServed.begin(), numberOfBeatsServed.end(), 0);
std::uint64_t totalNumberOfBeatsServed =
std::accumulate(numberOfBeatsServed.begin(), numberOfBeatsServed.end(), 0);
uint64_t windowNumberOfBeatsServed = totalNumberOfBeatsServed - lastNumberOfBeatsServed;
lastNumberOfBeatsServed = totalNumberOfBeatsServed;
uint64_t windowNumberOfBeatsServed = totalNumberOfBeatsServed - lastNumberOfBeatsServed;
lastNumberOfBeatsServed = totalNumberOfBeatsServed;
// HBM specific, pseudo channels get averaged
if (pseudoChannelMode)
windowNumberOfBeatsServed /= ranksPerChannel;
// HBM specific, pseudo channels get averaged
if (pseudoChannelMode)
windowNumberOfBeatsServed /= ranksPerChannel;
sc_core::sc_time windowActiveTime =
activeTimeMultiplier * static_cast<double>(windowNumberOfBeatsServed);
double windowAverageBandwidth = windowActiveTime / windowSizeTime;
tlmRecorder.recordBandwidth(sc_core::sc_time_stamp().to_seconds(), windowAverageBandwidth);
}
sc_core::sc_time windowActiveTime =
activeTimeMultiplier * static_cast<double>(windowNumberOfBeatsServed);
double windowAverageBandwidth = windowActiveTime / windowSizeTime;
tlmRecorder.recordBandwidth(sc_core::sc_time_stamp().to_seconds(), windowAverageBandwidth);
}
} // namespace DRAMSys

View File

@@ -102,9 +102,13 @@ Controller::Controller(const sc_module_name& name,
minBytesPerBurst(memSpec.defaultBytesPerBurst),
maxBytesPerBurst(memSpec.maxBytesPerBurst)
{
SC_METHOD(recordBufferDepth);
sensitive << windowEvent;
windowEvent.notify(windowSizeTime);
if (simConfig.databaseRecording && tlmRecorder != nullptr)
{
SC_METHOD(recordBufferDepth);
dont_initialize();
sensitive << windowEvent;
windowEvent.notify(windowSizeTime);
}
SC_METHOD(controllerMethod);
sensitive << beginReqEvent << endRespEvent << controllerEvent << dataResponseEvent;
@@ -342,20 +346,16 @@ void Controller::registerIdleCallback(std::function<void()> idleCallback)
void Controller::recordBufferDepth()
{
if (sc_time_stamp() == nextWindowEventTime)
windowEvent.notify(windowSizeTime);
nextWindowEventTime += windowSizeTime;
for (std::size_t index = 0; index < slidingAverageBufferDepth.size(); index++)
{
windowEvent.notify(windowSizeTime);
nextWindowEventTime += windowSizeTime;
for (std::size_t index = 0; index < slidingAverageBufferDepth.size(); index++)
{
windowAverageBufferDepth[index] = slidingAverageBufferDepth[index] / windowSizeTime;
slidingAverageBufferDepth[index] = SC_ZERO_TIME;
}
if (simConfig.databaseRecording && tlmRecorder != nullptr)
tlmRecorder->recordBufferDepth(sc_time_stamp().to_seconds(), windowAverageBufferDepth);
windowAverageBufferDepth[index] = slidingAverageBufferDepth[index] / windowSizeTime;
slidingAverageBufferDepth[index] = SC_ZERO_TIME;
}
tlmRecorder->recordBufferDepth(sc_time_stamp().to_seconds(), windowAverageBufferDepth);
}
void Controller::controllerMethod()