Moved Bandwidth recording out of the Controller
This commit is contained in:
@@ -1,33 +1,55 @@
|
||||
#include "TlmRecorderWrapper.h"
|
||||
#include "DRAMSys/configuration/memspec/MemSpec.h"
|
||||
#include "DRAMSys/controller/Command.h"
|
||||
#include "DRAMSys/simulation/SimConfig.h"
|
||||
#include <sysc/kernel/sc_module.h>
|
||||
#include <sysc/kernel/sc_simcontext.h>
|
||||
#include <tlm_core/tlm_2/tlm_generic_payload/tlm_phase.h>
|
||||
|
||||
namespace DRAMSys
|
||||
{
|
||||
// TlmRecorderWrapper::TlmRecorderWrapper(const std::string& name,
|
||||
// const SimConfig& simConfig,
|
||||
// const McConfig& mcConfig,
|
||||
// const MemSpec& memSpec,
|
||||
// const std::string& dbName,
|
||||
// const std::string& mcconfig,
|
||||
// const std::string& memspec,
|
||||
// const std::string& traces) :
|
||||
// tlmRecorder(name, simConfig, mcConfig, memSpec, dbName, mcconfig, memspec, traces)
|
||||
// {
|
||||
// // TODO: Nothing??
|
||||
// }
|
||||
|
||||
TlmRecorderWrapper::TlmRecorderWrapper(const sc_core::sc_module_name& name,
|
||||
const SimConfig& simConfig,
|
||||
const MemSpec& memSpec,
|
||||
TlmRecorder& tlmRecorder) :
|
||||
sc_module(name),
|
||||
tlmRecorder(tlmRecorder)
|
||||
tlmRecorder(tlmRecorder),
|
||||
enableWindowing(simConfig.enableWindowing),
|
||||
pseudoChannelMode(memSpec.pseudoChannelMode()),
|
||||
ranksPerChannel(memSpec.ranksPerChannel),
|
||||
windowSizeTime(simConfig.windowSize * memSpec.tCK),
|
||||
numberOfBeatsServed(memSpec.ranksPerChannel, 0),
|
||||
activeTimeMultiplier(memSpec.tCK / memSpec.dataRate)
|
||||
{
|
||||
iSocket.register_nb_transport_bw(this, &TlmRecorderWrapper::nb_transport_bw);
|
||||
tSocket.register_nb_transport_fw(this, &TlmRecorderWrapper::nb_transport_fw);
|
||||
|
||||
SC_METHOD(recordBandwidth);
|
||||
sensitive << windowEvent;
|
||||
|
||||
if (enableWindowing)
|
||||
{
|
||||
windowEvent.notify(windowSizeTime);
|
||||
nextWindowEventTime = windowSizeTime;
|
||||
}
|
||||
}
|
||||
|
||||
tlm::tlm_sync_enum TlmRecorderWrapper::nb_transport_fw(tlm::tlm_generic_payload& trans,
|
||||
tlm::tlm_phase& phase,
|
||||
sc_core::sc_time& delay)
|
||||
{
|
||||
if (enableWindowing)
|
||||
{
|
||||
Command cmd{phase};
|
||||
if (cmd.isCasCommand())
|
||||
{
|
||||
auto rank = ControllerExtension::getRank(trans);
|
||||
numberOfBeatsServed[static_cast<std::size_t>(rank)] +=
|
||||
ControllerExtension::getBurstLength(trans);
|
||||
}
|
||||
}
|
||||
|
||||
tlmRecorder.recordPhase(trans, phase, delay);
|
||||
return iSocket->nb_transport_fw(trans, phase, delay);
|
||||
}
|
||||
@@ -40,4 +62,29 @@ tlm::tlm_sync_enum TlmRecorderWrapper::nb_transport_bw(tlm::tlm_generic_payload&
|
||||
return tSocket->nb_transport_bw(trans, phase, delay);
|
||||
}
|
||||
|
||||
void TlmRecorderWrapper::recordBandwidth()
|
||||
{
|
||||
if (enableWindowing && sc_core::sc_time_stamp() == nextWindowEventTime)
|
||||
{
|
||||
windowEvent.notify(windowSizeTime);
|
||||
nextWindowEventTime += windowSizeTime;
|
||||
|
||||
std::uint64_t totalNumberOfBeatsServed =
|
||||
std::accumulate(numberOfBeatsServed.begin(), numberOfBeatsServed.end(), 0);
|
||||
|
||||
uint64_t windowNumberOfBeatsServed = totalNumberOfBeatsServed - lastNumberOfBeatsServed;
|
||||
lastNumberOfBeatsServed = totalNumberOfBeatsServed;
|
||||
|
||||
// HBM specific, pseudo channels get averaged
|
||||
if (pseudoChannelMode)
|
||||
windowNumberOfBeatsServed /= ranksPerChannel;
|
||||
|
||||
sc_core::sc_time windowActiveTime =
|
||||
activeTimeMultiplier * static_cast<double>(windowNumberOfBeatsServed);
|
||||
double windowAverageBandwidth = windowActiveTime / windowSizeTime;
|
||||
std::cout << "recordBandwidth: " << sc_core::sc_time_stamp().to_seconds() << "\n";
|
||||
tlmRecorder.recordBandwidth(sc_core::sc_time_stamp().to_seconds(), windowAverageBandwidth);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace DRAMSys
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
#define TLMRECORDERWRAPPER_H
|
||||
|
||||
#include "DRAMSys/configuration/memspec/MemSpec.h"
|
||||
#include "DRAMSys/controller/McConfig.h"
|
||||
#include "DRAMSys/simulation/SimConfig.h"
|
||||
#include "TlmRecorder.h"
|
||||
|
||||
#include <sysc/kernel/sc_module.h>
|
||||
#include <tlm>
|
||||
#include <tlm_utils/simple_initiator_socket.h>
|
||||
#include <tlm_utils/simple_target_socket.h>
|
||||
#include <vector>
|
||||
|
||||
namespace DRAMSys
|
||||
{
|
||||
@@ -16,25 +17,16 @@ namespace DRAMSys
|
||||
class TlmRecorderWrapper : public sc_core::sc_module
|
||||
|
||||
{
|
||||
SC_HAS_PROCESS(TlmRecorderWrapper);
|
||||
|
||||
public:
|
||||
tlm_utils::simple_initiator_socket<TlmRecorderWrapper> iSocket;
|
||||
tlm_utils::simple_target_socket<TlmRecorderWrapper> tSocket;
|
||||
|
||||
// TlmRecorderWrapper(const std::string& name,
|
||||
// const SimConfig& simConfig,
|
||||
// const McConfig& mcConfig,
|
||||
// const MemSpec& memSpec,
|
||||
// const std::string& dbName,
|
||||
// const std::string& mcconfig,
|
||||
// const std::string& memspec,
|
||||
// const std::string& traces);
|
||||
|
||||
TlmRecorderWrapper(const sc_core::sc_module_name& name, TlmRecorder& tlmRecorder);
|
||||
|
||||
// TlmRecorderWrapper(const TlmRecorderWrapper&) = delete;
|
||||
// TlmRecorderWrapper(TlmRecorderWrapper&&) = default;
|
||||
// TlmRecorderWrapper& operator=(const TlmRecorderWrapper&) = delete;
|
||||
// TlmRecorderWrapper& operator=(TlmRecorderWrapper&&) = delete;
|
||||
TlmRecorderWrapper(const sc_core::sc_module_name& name,
|
||||
const SimConfig& simConfig,
|
||||
const MemSpec& memspec,
|
||||
TlmRecorder& tlmRecorder);
|
||||
~TlmRecorderWrapper() = default;
|
||||
|
||||
tlm::tlm_sync_enum nb_transport_fw(tlm::tlm_generic_payload& trans,
|
||||
@@ -45,8 +37,19 @@ public:
|
||||
sc_core::sc_time& delay);
|
||||
|
||||
private:
|
||||
// TODO: Refactor with shared pointers?
|
||||
// HACK: Refactor with shared pointers?
|
||||
TlmRecorder& tlmRecorder;
|
||||
const bool enableWindowing;
|
||||
const bool pseudoChannelMode;
|
||||
const unsigned int ranksPerChannel;
|
||||
const sc_core::sc_time windowSizeTime;
|
||||
sc_core::sc_event windowEvent;
|
||||
sc_core::sc_time nextWindowEventTime;
|
||||
std::vector<uint64_t> numberOfBeatsServed;
|
||||
uint64_t lastNumberOfBeatsServed = 0;
|
||||
const sc_core::sc_time activeTimeMultiplier;
|
||||
|
||||
void recordBandwidth();
|
||||
};
|
||||
|
||||
} // namespace DRAMSys
|
||||
|
||||
@@ -112,20 +112,6 @@ void ControllerRecordable::controllerMethod()
|
||||
tlmRecorder.recordBufferDepth(sc_time_stamp().to_seconds(), windowAverageBufferDepth);
|
||||
|
||||
Controller::controllerMethod();
|
||||
|
||||
std::uint64_t totalNumberOfBeatsServed = std::accumulate(numberOfBeatsServed.begin(), numberOfBeatsServed.end(), 0);
|
||||
|
||||
uint64_t windowNumberOfBeatsServed = totalNumberOfBeatsServed - lastNumberOfBeatsServed;
|
||||
lastNumberOfBeatsServed = totalNumberOfBeatsServed;
|
||||
|
||||
// HBM specific, pseudo channels get averaged
|
||||
if (memSpec.pseudoChannelMode())
|
||||
windowNumberOfBeatsServed /= memSpec.ranksPerChannel;
|
||||
|
||||
sc_time windowActiveTime =
|
||||
activeTimeMultiplier * static_cast<double>(windowNumberOfBeatsServed);
|
||||
double windowAverageBandwidth = windowActiveTime / windowSizeTime;
|
||||
tlmRecorder.recordBandwidth(sc_time_stamp().to_seconds(), windowAverageBandwidth);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -123,7 +123,10 @@ DRAMSys::DRAMSys(const sc_core::sc_module_name& name, const Config::Configuratio
|
||||
("TLMCheckerController" + std::to_string(i)).c_str()));
|
||||
|
||||
tlmWrappers.emplace_back(std::make_unique<TlmRecorderWrapper>(
|
||||
("TlmRecorderWrapper" + std::to_string(i)).c_str(), tlmRecorders[i]));
|
||||
("TlmRecorderWrapper" + std::to_string(i)).c_str(),
|
||||
simConfig,
|
||||
*memSpec,
|
||||
tlmRecorders[i]));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user