Make DRAMPower optional
This commit is contained in:
@@ -42,8 +42,12 @@ project(DRAMSysLibrary)
|
||||
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ Version")
|
||||
set(DCMAKE_SH="CMAKE_SH-NOTFOUND")
|
||||
|
||||
option(DRAMSYS_WITH_DRAMPOWER "Build with DRAMPower support enabled." ON)
|
||||
|
||||
# Add DRAMPower:
|
||||
if (DRAMSYS_WITH_DRAMPOWER)
|
||||
add_subdirectory(src/common/third_party/DRAMPower)
|
||||
endif()
|
||||
|
||||
# Add Configuration
|
||||
add_subdirectory(src/common/configuration)
|
||||
@@ -252,6 +256,13 @@ endif()
|
||||
|
||||
target_link_libraries(DRAMSysLibrary
|
||||
PUBLIC ${SYSTEMC_LIBRARY}
|
||||
PRIVATE DRAMPower
|
||||
PUBLIC DRAMSysConfiguration
|
||||
)
|
||||
|
||||
if (DRAMSYS_WITH_DRAMPOWER)
|
||||
target_compile_definitions(DRAMSysLibrary PRIVATE DRAMPOWER)
|
||||
|
||||
target_link_libraries(DRAMSysLibrary
|
||||
PRIVATE DRAMPower
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -40,7 +40,10 @@
|
||||
#include "Command.h"
|
||||
|
||||
using namespace tlm;
|
||||
|
||||
#ifdef DRAMPOWER
|
||||
using namespace DRAMPower;
|
||||
#endif
|
||||
|
||||
Command::Command(Command::Type type) : type(type) {}
|
||||
|
||||
@@ -145,6 +148,7 @@ tlm_phase Command::toPhase() const
|
||||
return phaseOfCommand[type];
|
||||
}
|
||||
|
||||
#ifdef DRAMPOWER
|
||||
MemCommand::cmds phaseToDRAMPowerCommand(tlm_phase phase)
|
||||
{
|
||||
// TODO: add correct phases when DRAMPower supports DDR5 same bank refresh
|
||||
@@ -177,6 +181,7 @@ MemCommand::cmds phaseToDRAMPowerCommand(tlm_phase phase)
|
||||
};
|
||||
return phaseOfCommand[phase - BEGIN_NOP];
|
||||
}
|
||||
#endif
|
||||
|
||||
bool phaseNeedsEnd(tlm_phase phase)
|
||||
{
|
||||
|
||||
@@ -43,7 +43,10 @@
|
||||
|
||||
#include <systemc>
|
||||
#include <tlm>
|
||||
|
||||
#ifdef DRAMPOWER
|
||||
#include "../common/third_party/DRAMPower/src/MemCommand.h"
|
||||
#endif
|
||||
|
||||
// DO NOT CHANGE THE ORDER!
|
||||
|
||||
@@ -150,7 +153,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef DRAMPOWER
|
||||
DRAMPower::MemCommand::cmds phaseToDRAMPowerCommand(tlm::tlm_phase);
|
||||
#endif
|
||||
|
||||
bool phaseNeedsEnd(tlm::tlm_phase);
|
||||
tlm::tlm_phase getEndPhase(tlm::tlm_phase);
|
||||
|
||||
|
||||
@@ -39,6 +39,10 @@
|
||||
#include "../simulation/AddressDecoder.h"
|
||||
#include "../common/dramExtensions.h"
|
||||
|
||||
#ifdef DRAMPOWER
|
||||
#include "../../common/third_party/DRAMPower/src/libdrampower/LibDRAMPower.h"
|
||||
#endif
|
||||
|
||||
#include <random>
|
||||
#include <chrono>
|
||||
#include <bitset>
|
||||
@@ -501,6 +505,7 @@ double errorModel::getTemperature()
|
||||
|
||||
if (this->myChannel != -1)
|
||||
{
|
||||
#ifdef DRAMPOWER
|
||||
if (thermalSim && powerAnalysis)
|
||||
{
|
||||
// TODO
|
||||
@@ -512,6 +517,9 @@ double errorModel::getTemperature()
|
||||
} else {
|
||||
temperature = temperatureController.getTemperature(this->myChannel, 0);
|
||||
}
|
||||
#else
|
||||
temperature = temperatureController.getTemperature(this->myChannel, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
return temperature;
|
||||
|
||||
@@ -41,9 +41,10 @@
|
||||
#include <systemc>
|
||||
#include "../configuration/Configuration.h"
|
||||
#include "../simulation/AddressDecoder.h"
|
||||
#include "../common/third_party/DRAMPower/src/libdrampower/LibDRAMPower.h"
|
||||
#include "../simulation/TemperatureController.h"
|
||||
|
||||
class libDRAMPower;
|
||||
|
||||
class errorModel : public sc_core::sc_module
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -55,13 +55,19 @@
|
||||
#include "../../common/DebugManager.h"
|
||||
#include "../../common/dramExtensions.h"
|
||||
#include "../../common/utils.h"
|
||||
#include "../../controller/Command.h"
|
||||
|
||||
#ifdef DRAMPOWER
|
||||
#include "../../common/third_party/DRAMPower/src/MemCommand.h"
|
||||
#include "../../common/third_party/DRAMPower/src/libdrampower/LibDRAMPower.h"
|
||||
#include "../../controller/Command.h"
|
||||
#endif
|
||||
|
||||
using namespace sc_core;
|
||||
using namespace tlm;
|
||||
|
||||
#ifdef DRAMPOWER
|
||||
using namespace DRAMPower;
|
||||
#endif
|
||||
|
||||
Dram::Dram(const sc_module_name& name, const Configuration& config)
|
||||
: sc_module(name), memSpec(*config.memSpec), tSocket("socket"), storeMode(config.storeMode),
|
||||
@@ -100,6 +106,7 @@ Dram::~Dram()
|
||||
|
||||
void Dram::reportPower()
|
||||
{
|
||||
#ifdef DRAMPOWER
|
||||
DRAMPower->calcEnergy();
|
||||
|
||||
// Print the final total energy and the average power for
|
||||
@@ -116,6 +123,7 @@ void Dram::reportPower()
|
||||
<< DRAMPower->getPower().average_power
|
||||
* memSpec.devicesPerRank
|
||||
<< std::string(" mW") << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
tlm_sync_enum Dram::nb_transport_fw(tlm_generic_payload &payload,
|
||||
@@ -127,7 +135,10 @@ tlm_sync_enum Dram::nb_transport_fw(tlm_generic_payload &payload,
|
||||
{
|
||||
int bank = static_cast<int>(DramExtension::getExtension(payload).getBank().ID());
|
||||
int64_t cycle = std::lround((sc_time_stamp() + delay) / memSpec.tCK);
|
||||
|
||||
#ifdef DRAMPOWER
|
||||
DRAMPower->doCommand(phaseToDRAMPowerCommand(phase), bank, cycle);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (storeMode == Configuration::StoreMode::Store)
|
||||
|
||||
@@ -64,7 +64,9 @@ protected:
|
||||
unsigned char *memory;
|
||||
const bool useMalloc;
|
||||
|
||||
#ifdef DRAMPOWER
|
||||
std::unique_ptr<libDRAMPower> DRAMPower;
|
||||
#endif
|
||||
|
||||
virtual tlm::tlm_sync_enum nb_transport_fw(tlm::tlm_generic_payload &payload,
|
||||
tlm::tlm_phase &phase, sc_core::sc_time &delay);
|
||||
|
||||
@@ -37,11 +37,14 @@
|
||||
|
||||
#include <memory>
|
||||
#include "../../configuration/Configuration.h"
|
||||
#include "../../common/third_party/DRAMPower/src/libdrampower/LibDRAMPower.h"
|
||||
#include "../../configuration/memspec/MemSpecDDR3.h"
|
||||
|
||||
using namespace sc_core;
|
||||
#ifdef DRAMPOWER
|
||||
#include "../../common/third_party/DRAMPower/src/libdrampower/LibDRAMPower.h"
|
||||
using namespace DRAMPower;
|
||||
#endif
|
||||
|
||||
using namespace sc_core;
|
||||
|
||||
DramDDR3::DramDDR3(const sc_module_name& name, const Configuration& config,
|
||||
TemperatureController& temperatureController)
|
||||
@@ -56,6 +59,7 @@ DramDDR3::DramDDR3(const sc_module_name& name, const Configuration& config,
|
||||
if (memSpecDDR3 == nullptr)
|
||||
SC_REPORT_FATAL("DramDDR3", "Wrong MemSpec chosen");
|
||||
|
||||
#ifdef DRAMPOWER
|
||||
MemArchitectureSpec memArchSpec;
|
||||
memArchSpec.burstLength = memSpecDDR3->defaultBurstLength;
|
||||
memArchSpec.dataRate = memSpecDDR3->dataRate;
|
||||
@@ -143,5 +147,6 @@ DramDDR3::DramDDR3(const sc_module_name& name, const Configuration& config,
|
||||
powerSpec.memArchSpec = memArchSpec;
|
||||
|
||||
DRAMPower = std::make_unique<libDRAMPower>(powerSpec, false);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,11 +37,14 @@
|
||||
|
||||
#include <memory>
|
||||
#include "../../configuration/Configuration.h"
|
||||
#include "../../common/third_party/DRAMPower/src/libdrampower/LibDRAMPower.h"
|
||||
#include "../../configuration/memspec/MemSpecDDR4.h"
|
||||
|
||||
using namespace sc_core;
|
||||
#ifdef DRAMPOWER
|
||||
#include "../../common/third_party/DRAMPower/src/libdrampower/LibDRAMPower.h"
|
||||
using namespace DRAMPower;
|
||||
#endif
|
||||
|
||||
using namespace sc_core;
|
||||
|
||||
DramDDR4::DramDDR4(const sc_module_name& name, const Configuration& config,
|
||||
TemperatureController& temperatureController)
|
||||
@@ -56,6 +59,7 @@ DramDDR4::DramDDR4(const sc_module_name& name, const Configuration& config,
|
||||
if (memSpecDDR4 == nullptr)
|
||||
SC_REPORT_FATAL("DramDDR4", "Wrong MemSpec chosen");
|
||||
|
||||
#ifdef DRAMPOWER
|
||||
MemArchitectureSpec memArchSpec;
|
||||
memArchSpec.burstLength = memSpecDDR4->defaultBurstLength;
|
||||
memArchSpec.dataRate = memSpecDDR4->dataRate;
|
||||
@@ -143,5 +147,6 @@ DramDDR4::DramDDR4(const sc_module_name& name, const Configuration& config,
|
||||
powerSpec.memArchSpec = memArchSpec;
|
||||
|
||||
DRAMPower = std::make_unique<libDRAMPower>(powerSpec, false);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,11 +35,9 @@
|
||||
|
||||
#include "DramDDR5.h"
|
||||
#include "../../configuration/Configuration.h"
|
||||
#include "../../common/third_party/DRAMPower/src/libdrampower/LibDRAMPower.h"
|
||||
#include "../../configuration/memspec/MemSpecDDR5.h"
|
||||
|
||||
using namespace sc_core;
|
||||
using namespace DRAMPower;
|
||||
|
||||
DramDDR5::DramDDR5(const sc_module_name& name, const Configuration& config,
|
||||
TemperatureController& temperatureController)
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
|
||||
#include "DramGDDR5.h"
|
||||
#include "../../configuration/Configuration.h"
|
||||
#include "../../common/third_party/DRAMPower/src/libdrampower/LibDRAMPower.h"
|
||||
#include "../../configuration/memspec/MemSpecGDDR5.h"
|
||||
|
||||
using namespace sc_core;
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
|
||||
#include "DramGDDR5X.h"
|
||||
#include "../../configuration/Configuration.h"
|
||||
#include "../../common/third_party/DRAMPower/src/libdrampower/LibDRAMPower.h"
|
||||
#include "../../configuration/memspec/MemSpecGDDR5X.h"
|
||||
|
||||
using namespace sc_core;
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
|
||||
#include "DramGDDR6.h"
|
||||
#include "../../configuration/Configuration.h"
|
||||
#include "../../common/third_party/DRAMPower/src/libdrampower/LibDRAMPower.h"
|
||||
#include "../../configuration/memspec/MemSpecGDDR6.h"
|
||||
|
||||
using namespace sc_core;
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
|
||||
#include "DramHBM2.h"
|
||||
#include "../../configuration/Configuration.h"
|
||||
#include "../../common/third_party/DRAMPower/src/libdrampower/LibDRAMPower.h"
|
||||
#include "../../configuration/memspec/MemSpecHBM2.h"
|
||||
|
||||
using namespace sc_core;
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
|
||||
#include "DramHBM3.h"
|
||||
#include "../../configuration/Configuration.h"
|
||||
#include "../../common/third_party/DRAMPower/src/libdrampower/LibDRAMPower.h"
|
||||
#include "../../configuration/memspec/MemSpecHBM3.h"
|
||||
|
||||
using namespace sc_core;
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
|
||||
#include "DramLPDDR4.h"
|
||||
#include "../../configuration/Configuration.h"
|
||||
#include "../../common/third_party/DRAMPower/src/libdrampower/LibDRAMPower.h"
|
||||
#include "../../configuration/memspec/MemSpecLPDDR4.h"
|
||||
|
||||
using namespace sc_core;
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
|
||||
#include "Dram.h"
|
||||
#include "../../configuration/Configuration.h"
|
||||
#include "../../common/third_party/DRAMPower/src/libdrampower/LibDRAMPower.h"
|
||||
#include "../../configuration/memspec/MemSpecLPDDR5.h"
|
||||
|
||||
using namespace sc_core;
|
||||
|
||||
@@ -68,19 +68,23 @@ DramRecordable<BaseDram>::DramRecordable(const sc_module_name& name, const Confi
|
||||
: BaseDram(name, config, temperatureController), tlmRecorder(tlmRecorder),
|
||||
powerWindowSize(config.memSpec->tCK * config.windowSize)
|
||||
{
|
||||
#ifdef DRAMPOWER
|
||||
// Create a thread that is triggered every $powerWindowSize
|
||||
// to generate a Power over Time plot in the Trace analyzer:
|
||||
if (config.powerAnalysis && config.enableWindowing)
|
||||
SC_THREAD(powerWindow);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<class BaseDram>
|
||||
void DramRecordable<BaseDram>::reportPower()
|
||||
{
|
||||
BaseDram::reportPower();
|
||||
#ifdef DRAMPOWER
|
||||
tlmRecorder.recordPower(sc_time_stamp().to_seconds(),
|
||||
this->DRAMPower->getPower().window_average_power
|
||||
* this->memSpec.devicesPerRank);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<class BaseDram>
|
||||
@@ -123,7 +127,7 @@ void DramRecordable<BaseDram>::recordPhase(tlm_generic_payload &trans, const tlm
|
||||
|
||||
}
|
||||
|
||||
|
||||
#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.
|
||||
template<class BaseDram>
|
||||
@@ -158,6 +162,7 @@ void DramRecordable<BaseDram>::powerWindow()
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
template class DramRecordable<DramDDR3>;
|
||||
template class DramRecordable<DramDDR4>;
|
||||
|
||||
@@ -40,9 +40,12 @@
|
||||
#include <tlm>
|
||||
#include "../../common/TlmRecorder.h"
|
||||
#include "../../configuration/Configuration.h"
|
||||
#include "../../common/third_party/DRAMPower/src/libdrampower/LibDRAMPower.h"
|
||||
#include "../TemperatureController.h"
|
||||
|
||||
#ifdef DRAMPOWER
|
||||
#include "../../common/third_party/DRAMPower/src/libdrampower/LibDRAMPower.h"
|
||||
#endif
|
||||
|
||||
template<class BaseDram>
|
||||
class DramRecordable final : public BaseDram
|
||||
{
|
||||
@@ -71,9 +74,11 @@ private:
|
||||
return std::fabs(a - b) < epsilon;
|
||||
}
|
||||
|
||||
#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 powerWindow();
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // DRAMRECORDABLE_H
|
||||
|
||||
@@ -35,11 +35,9 @@
|
||||
|
||||
#include "DramSTTMRAM.h"
|
||||
#include "../../configuration/Configuration.h"
|
||||
#include "../../common/third_party/DRAMPower/src/libdrampower/LibDRAMPower.h"
|
||||
#include "../../configuration/memspec/MemSpecSTTMRAM.h"
|
||||
|
||||
using namespace sc_core;
|
||||
using namespace DRAMPower;
|
||||
|
||||
DramSTTMRAM::DramSTTMRAM(const sc_module_name& name, const Configuration& config,
|
||||
TemperatureController& temperatureController)
|
||||
|
||||
@@ -39,12 +39,16 @@
|
||||
#include "DramWideIO.h"
|
||||
#include "../../configuration/Configuration.h"
|
||||
#include "../../error/errormodel.h"
|
||||
#include "../../common/third_party/DRAMPower/src/libdrampower/LibDRAMPower.h"
|
||||
#include "../../configuration/memspec/MemSpecWideIO.h"
|
||||
|
||||
#ifdef DRAMPOWER
|
||||
#include "../../common/third_party/DRAMPower/src/libdrampower/LibDRAMPower.h"
|
||||
using namespace DRAMPower;
|
||||
#endif
|
||||
|
||||
using namespace sc_core;
|
||||
using namespace tlm;
|
||||
using namespace DRAMPower;
|
||||
|
||||
|
||||
DramWideIO::DramWideIO(const sc_module_name& name, const Configuration& config,
|
||||
TemperatureController& temperatureController)
|
||||
@@ -52,6 +56,7 @@ DramWideIO::DramWideIO(const sc_module_name& name, const Configuration& config,
|
||||
{
|
||||
if (powerAnalysis)
|
||||
{
|
||||
#ifdef DRAMPOWER
|
||||
const auto* memSpecWideIO = dynamic_cast<const MemSpecWideIO *>(config.memSpec.get());
|
||||
if (memSpecWideIO == nullptr)
|
||||
SC_REPORT_FATAL("DramWideIO", "Wrong MemSpec chosen");
|
||||
@@ -144,6 +149,7 @@ DramWideIO::DramWideIO(const sc_module_name& name, const Configuration& config,
|
||||
|
||||
DRAMPower = std::make_unique<libDRAMPower>(powerSpec, false);
|
||||
|
||||
|
||||
// For each bank in a channel a error Model is created:
|
||||
if (storeMode == Configuration::StoreMode::ErrorModel)
|
||||
{
|
||||
@@ -154,6 +160,7 @@ DramWideIO::DramWideIO(const sc_module_name& name, const Configuration& config,
|
||||
temperatureController, DRAMPower.get()));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -174,12 +181,14 @@ tlm_sync_enum DramWideIO::nb_transport_fw(tlm_generic_payload &payload,
|
||||
{
|
||||
assert(phase >= 5 && phase <= 19);
|
||||
|
||||
#ifdef DRAMPOWER
|
||||
if (powerAnalysis)
|
||||
{
|
||||
int bank = static_cast<int>(DramExtension::getExtension(payload).getBank().ID());
|
||||
int64_t cycle = std::lround((sc_time_stamp() + delay) / memSpec.tCK);
|
||||
DRAMPower->doCommand(phaseToDRAMPowerCommand(phase), bank, cycle);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (storeMode == Configuration::StoreMode::Store)
|
||||
{
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
|
||||
#include "DramWideIO2.h"
|
||||
#include "../../configuration/Configuration.h"
|
||||
#include "../../common/third_party/DRAMPower/src/libdrampower/LibDRAMPower.h"
|
||||
#include "../../configuration/memspec/MemSpecWideIO2.h"
|
||||
|
||||
using namespace sc_core;
|
||||
|
||||
Reference in New Issue
Block a user