Moved DramRecordable logic to Dram
This commit is contained in:
@@ -114,18 +114,16 @@ DRAMSys::DRAMSys(const sc_core::sc_module_name& name, const Config::Configuratio
|
||||
*addressDecoder,
|
||||
tlmRecorders[i]));
|
||||
|
||||
// drams.emplace_back(std::make_unique<DramRecordable>(
|
||||
// ("dram" + std::to_string(i)).c_str(), simConfig, *memSpec, tlmRecorders[i]));
|
||||
|
||||
drams.emplace_back(
|
||||
std::make_unique<Dram>(("dram" + std::to_string(i)).c_str(), simConfig, *memSpec));
|
||||
drams.emplace_back(std::make_unique<Dram>(
|
||||
("dram" + std::to_string(i)).c_str(), simConfig, *memSpec, tlmRecorders[i]));
|
||||
|
||||
if (simConfig.checkTLM2Protocol)
|
||||
controllersTlmCheckers.emplace_back(
|
||||
std::make_unique<tlm_utils::tlm2_base_protocol_checker<>>(
|
||||
("TLMCheckerController" + std::to_string(i)).c_str()));
|
||||
|
||||
tlmWrappers.emplace_back(std::make_unique<TlmRecorderWrapper>(("TlmRecorderWrapper" + std::to_string(i)).c_str(), tlmRecorders[i]));
|
||||
tlmWrappers.emplace_back(std::make_unique<TlmRecorderWrapper>(
|
||||
("TlmRecorderWrapper" + std::to_string(i)).c_str(), tlmRecorders[i]));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -135,8 +133,8 @@ DRAMSys::DRAMSys(const sc_core::sc_module_name& name, const Config::Configuratio
|
||||
controllers.emplace_back(std::make_unique<Controller>(
|
||||
("controller" + std::to_string(i)).c_str(), mcConfig, *memSpec, *addressDecoder));
|
||||
|
||||
drams.emplace_back(
|
||||
std::make_unique<Dram>(("dram" + std::to_string(i)).c_str(), simConfig, *memSpec));
|
||||
drams.emplace_back(std::make_unique<Dram>(
|
||||
("dram" + std::to_string(i)).c_str(), simConfig, *memSpec, tlmRecorders[i]));
|
||||
|
||||
if (simConfig.checkTLM2Protocol)
|
||||
{
|
||||
|
||||
@@ -41,7 +41,9 @@
|
||||
#include "Dram.h"
|
||||
|
||||
#include "DRAMSys/common/DebugManager.h"
|
||||
#include "DRAMSys/common/TlmRecorder.h"
|
||||
#include "DRAMSys/config/SimConfig.h"
|
||||
#include <sysc/kernel/sc_module.h>
|
||||
|
||||
#ifdef DRAMPOWER
|
||||
#include "LibDRAMPower.h"
|
||||
@@ -67,13 +69,18 @@ using namespace DRAMPower;
|
||||
namespace DRAMSys
|
||||
{
|
||||
|
||||
Dram::Dram(const sc_module_name& name, const SimConfig& simConfig, const MemSpec& memSpec) :
|
||||
Dram::Dram(const sc_module_name& name,
|
||||
const SimConfig& simConfig,
|
||||
const MemSpec& memSpec,
|
||||
TlmRecorder& tlmRecorder) :
|
||||
sc_module(name),
|
||||
memSpec(memSpec),
|
||||
storeMode(simConfig.storeMode),
|
||||
powerAnalysis(simConfig.powerAnalysis),
|
||||
channelSize(memSpec.getSimMemSizeInBytes() / memSpec.numberOfChannels),
|
||||
useMalloc(simConfig.useMalloc)
|
||||
useMalloc(simConfig.useMalloc),
|
||||
tlmRecorder(tlmRecorder),
|
||||
powerWindowSize(memSpec.tCK * simConfig.windowSize)
|
||||
{
|
||||
if (storeMode == Config::StoreModeType::Store)
|
||||
{
|
||||
@@ -109,6 +116,9 @@ Dram::Dram(const sc_module_name& name, const SimConfig& simConfig, const MemSpec
|
||||
{
|
||||
DRAMPower = std::make_unique<libDRAMPower>(memSpec.toDramPowerMemSpec(), false);
|
||||
}
|
||||
|
||||
if (simConfig.powerAnalysis && simConfig.enableWindowing)
|
||||
SC_THREAD(powerWindow);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -132,6 +142,10 @@ void Dram::reportPower()
|
||||
std::cout << name() << std::string(" Average Power: ") << std::fixed << std::setprecision(2)
|
||||
<< DRAMPower->getPower().average_power * memSpec.devicesPerRank << std::string(" mW")
|
||||
<< std::endl;
|
||||
|
||||
tlmRecorder.recordPower(sc_time_stamp().to_seconds(),
|
||||
this->DRAMPower->getPower().window_average_power *
|
||||
this->memSpec.devicesPerRank);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -267,4 +281,44 @@ void Dram::deserialize(std::istream& stream)
|
||||
stream.read(reinterpret_cast<char*>(memory), channelSize);
|
||||
}
|
||||
|
||||
#ifdef DRAMPOWER
|
||||
// This Thread is only triggered when Power Simulation is enabled.
|
||||
// It estimates the current average power which will be stored in the trace database for
|
||||
// visualization purposes.
|
||||
void Dram::powerWindow()
|
||||
{
|
||||
int64_t clkCycles = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
// At the very beginning (zero clock cycles) the energy is 0, so we wait first
|
||||
sc_module::wait(powerWindowSize);
|
||||
|
||||
clkCycles = std::lround(sc_time_stamp() / this->memSpec.tCK);
|
||||
|
||||
this->DRAMPower->calcWindowEnergy(clkCycles);
|
||||
|
||||
// During operation the energy should never be zero since the device is always consuming
|
||||
assert(!this->DRAMPower->getEnergy().window_energy < 1e-05);
|
||||
|
||||
// Store the time (in seconds) and the current average power (in mW) into the database
|
||||
tlmRecorder.recordPower(sc_time_stamp().to_seconds(),
|
||||
this->DRAMPower->getPower().window_average_power *
|
||||
this->memSpec.devicesPerRank);
|
||||
|
||||
// Here considering that DRAMPower provides the energy in pJ and the power in mW
|
||||
PRINTDEBUGMESSAGE(this->name(),
|
||||
std::string("\tWindow Energy: \t") +
|
||||
std::to_string(this->DRAMPower->getEnergy().window_energy *
|
||||
this->memSpec.devicesPerRank) +
|
||||
std::string("\t[pJ]"));
|
||||
PRINTDEBUGMESSAGE(this->name(),
|
||||
std::string("\tWindow Average Power: \t") +
|
||||
std::to_string(this->DRAMPower->getPower().window_average_power *
|
||||
this->memSpec.devicesPerRank) +
|
||||
std::string("\t[mW]"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace DRAMSys
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
|
||||
#include "DRAMSys/common/Deserialize.h"
|
||||
#include "DRAMSys/common/Serialize.h"
|
||||
#include "DRAMSys/common/TlmRecorder.h"
|
||||
#include "DRAMSys/configuration/memspec/MemSpec.h"
|
||||
#include "DRAMSys/simulation/SimConfig.h"
|
||||
|
||||
@@ -68,8 +69,15 @@ protected:
|
||||
const uint64_t channelSize;
|
||||
const bool useMalloc;
|
||||
|
||||
TlmRecorder& tlmRecorder;
|
||||
sc_core::sc_time powerWindowSize;
|
||||
|
||||
#ifdef DRAMPOWER
|
||||
std::unique_ptr<libDRAMPower> DRAMPower;
|
||||
// This Thread is only triggered when Power Simulation is enabled.
|
||||
// It estimates the current average power which will be stored in the trace database for
|
||||
// visualization purposes.
|
||||
void powerWindow();
|
||||
#endif
|
||||
|
||||
virtual tlm::tlm_sync_enum nb_transport_fw(tlm::tlm_generic_payload& trans,
|
||||
@@ -82,7 +90,10 @@ protected:
|
||||
void executeWrite(const tlm::tlm_generic_payload& trans);
|
||||
|
||||
public:
|
||||
Dram(const sc_core::sc_module_name& name, const SimConfig& simConfig, const MemSpec& memSpec);
|
||||
Dram(const sc_core::sc_module_name& name,
|
||||
const SimConfig& simConfig,
|
||||
const MemSpec& memSpec,
|
||||
TlmRecorder& tlmRecorder);
|
||||
SC_HAS_PROCESS(Dram);
|
||||
|
||||
Dram(const Dram&) = delete;
|
||||
|
||||
Reference in New Issue
Block a user