Switch from shared_ptrs back to references
Dram and Controller hold a const pointer instead of a reference, so that it can be set to null, if database recording is disabled
This commit is contained in:
@@ -13,11 +13,11 @@ namespace DRAMSys
|
||||
TlmRecorderController::TlmRecorderController(const sc_core::sc_module_name& name,
|
||||
const SimConfig& simConfig,
|
||||
const MemSpec& memSpec,
|
||||
std::shared_ptr<TlmRecorder> tlmRecorder,
|
||||
TlmRecorder& tlmRecorder,
|
||||
bool enableBandwidth) :
|
||||
sc_module(name),
|
||||
memSpec(memSpec),
|
||||
tlmRecorder(std::move(tlmRecorder)),
|
||||
tlmRecorder(tlmRecorder),
|
||||
enableWindowing(simConfig.enableWindowing),
|
||||
pseudoChannelMode(memSpec.pseudoChannelMode()),
|
||||
ranksPerChannel(memSpec.ranksPerChannel),
|
||||
@@ -54,7 +54,7 @@ tlm::tlm_sync_enum TlmRecorderController::nb_transport_fw(tlm::tlm_generic_paylo
|
||||
numberOfBytesServed += trans.get_data_length();
|
||||
}
|
||||
|
||||
tlmRecorder->recordPhase(trans, phase, delay);
|
||||
tlmRecorder.recordPhase(trans, phase, delay);
|
||||
return iSocket->nb_transport_fw(trans, phase, delay);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ tlm::tlm_sync_enum TlmRecorderController::nb_transport_bw(tlm::tlm_generic_paylo
|
||||
numberOfBytesServed += trans.get_data_length();
|
||||
}
|
||||
|
||||
tlmRecorder->recordPhase(trans, phase, delay);
|
||||
tlmRecorder.recordPhase(trans, phase, delay);
|
||||
return tSocket->nb_transport_bw(trans, phase, delay);
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ void TlmRecorderController::recordBandwidth()
|
||||
|
||||
double windowBandwidth =
|
||||
static_cast<double>(windowNumberOfBytesServed) / (windowSizeTime.to_seconds());
|
||||
tlmRecorder->recordBandwidth(sc_core::sc_time_stamp().to_seconds(), windowBandwidth);
|
||||
tlmRecorder.recordBandwidth(sc_core::sc_time_stamp().to_seconds(), windowBandwidth);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
TlmRecorderController(const sc_core::sc_module_name& name,
|
||||
const SimConfig& simConfig,
|
||||
const MemSpec& memspec,
|
||||
std::shared_ptr<TlmRecorder> tlmRecorder,
|
||||
TlmRecorder& tlmRecorder,
|
||||
bool enableBandwidth);
|
||||
~TlmRecorderController() = default;
|
||||
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
|
||||
private:
|
||||
const MemSpec& memSpec;
|
||||
std::shared_ptr<TlmRecorder> tlmRecorder;
|
||||
TlmRecorder& tlmRecorder;
|
||||
const bool enableWindowing;
|
||||
const bool pseudoChannelMode;
|
||||
const unsigned int ranksPerChannel;
|
||||
|
||||
@@ -12,10 +12,10 @@ namespace DRAMSys
|
||||
TlmRecorderDram::TlmRecorderDram(const sc_core::sc_module_name& name,
|
||||
const SimConfig& simConfig,
|
||||
const MemSpec& memSpec,
|
||||
std::shared_ptr<TlmRecorder> tlmRecorder,
|
||||
TlmRecorder& tlmRecorder,
|
||||
bool enableBandwidth) :
|
||||
sc_module(name),
|
||||
tlmRecorder(std::move(tlmRecorder)),
|
||||
tlmRecorder(tlmRecorder),
|
||||
enableWindowing(simConfig.enableWindowing),
|
||||
pseudoChannelMode(memSpec.pseudoChannelMode()),
|
||||
ranksPerChannel(memSpec.ranksPerChannel),
|
||||
@@ -57,7 +57,7 @@ tlm::tlm_sync_enum TlmRecorderDram::nb_transport_fw(tlm::tlm_generic_payload& tr
|
||||
}
|
||||
}
|
||||
|
||||
tlmRecorder->recordPhase(trans, phase, delay);
|
||||
tlmRecorder.recordPhase(trans, phase, delay);
|
||||
return iSocket->nb_transport_fw(trans, phase, delay);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ tlm::tlm_sync_enum TlmRecorderDram::nb_transport_bw(tlm::tlm_generic_payload& tr
|
||||
tlm::tlm_phase& phase,
|
||||
sc_core::sc_time& delay)
|
||||
{
|
||||
tlmRecorder->recordPhase(trans, phase, delay);
|
||||
tlmRecorder.recordPhase(trans, phase, delay);
|
||||
return tSocket->nb_transport_bw(trans, phase, delay);
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ void TlmRecorderDram::recordBandwidth()
|
||||
sc_core::sc_time windowActiveTime =
|
||||
activeTimeMultiplier * static_cast<double>(windowNumberOfBeatsServed);
|
||||
double windowAverageBandwidth = windowActiveTime / windowSizeTime;
|
||||
tlmRecorder->recordBandwidth(sc_core::sc_time_stamp().to_seconds(), windowAverageBandwidth);
|
||||
tlmRecorder.recordBandwidth(sc_core::sc_time_stamp().to_seconds(), windowAverageBandwidth);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
TlmRecorderDram(const sc_core::sc_module_name& name,
|
||||
const SimConfig& simConfig,
|
||||
const MemSpec& memspec,
|
||||
std::shared_ptr<TlmRecorder> tlmRecorder,
|
||||
TlmRecorder& tlmRecorder,
|
||||
bool enableBandwidth);
|
||||
~TlmRecorderDram() = default;
|
||||
|
||||
@@ -40,7 +40,7 @@ public:
|
||||
unsigned int transport_dbg(tlm::tlm_generic_payload& trans);
|
||||
|
||||
private:
|
||||
std::shared_ptr<TlmRecorder> tlmRecorder;
|
||||
TlmRecorder& tlmRecorder;
|
||||
const bool enableWindowing;
|
||||
const bool pseudoChannelMode;
|
||||
const unsigned int ranksPerChannel;
|
||||
|
||||
@@ -89,13 +89,13 @@ Controller::Controller(const sc_module_name& name,
|
||||
const MemSpec& memSpec,
|
||||
const SimConfig& simConfig,
|
||||
const AddressDecoder& addressDecoder,
|
||||
std::shared_ptr<TlmRecorder> tlmRecorder) :
|
||||
TlmRecorder* tlmRecorder) :
|
||||
sc_module(name),
|
||||
config(config),
|
||||
memSpec(memSpec),
|
||||
simConfig(simConfig),
|
||||
addressDecoder(addressDecoder),
|
||||
tlmRecorder(std::move(tlmRecorder)),
|
||||
tlmRecorder(tlmRecorder),
|
||||
windowSizeTime(simConfig.windowSize * memSpec.tCK),
|
||||
nextWindowEventTime(windowSizeTime),
|
||||
numberOfBeatsServed(memSpec.ranksPerChannel, 0),
|
||||
@@ -353,7 +353,7 @@ void Controller::recordBufferDepth()
|
||||
slidingAverageBufferDepth[index] = SC_ZERO_TIME;
|
||||
}
|
||||
|
||||
if (simConfig.databaseRecording)
|
||||
if (simConfig.databaseRecording && tlmRecorder != nullptr)
|
||||
tlmRecorder->recordBufferDepth(sc_time_stamp().to_seconds(), windowAverageBufferDepth);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
const MemSpec& memSpec,
|
||||
const SimConfig& simConfig,
|
||||
const AddressDecoder& addressDecoder,
|
||||
std::shared_ptr<TlmRecorder> tlmRecorder);
|
||||
TlmRecorder* tlmRecorder);
|
||||
SC_HAS_PROCESS(Controller);
|
||||
|
||||
[[nodiscard]] bool idle() const { return totalNumberOfPayloads == 0; }
|
||||
@@ -102,7 +102,7 @@ protected:
|
||||
const MemSpec& memSpec;
|
||||
const SimConfig& simConfig;
|
||||
const AddressDecoder& addressDecoder;
|
||||
std::shared_ptr<TlmRecorder> tlmRecorder;
|
||||
TlmRecorder* const tlmRecorder;
|
||||
|
||||
std::unique_ptr<SchedulerIF> scheduler;
|
||||
|
||||
|
||||
@@ -111,10 +111,10 @@ DRAMSys::DRAMSys(const sc_core::sc_module_name& name, const Config::Configuratio
|
||||
*memSpec,
|
||||
simConfig,
|
||||
*addressDecoder,
|
||||
tlmRecorders[i]));
|
||||
&tlmRecorders[i]));
|
||||
|
||||
drams.emplace_back(std::make_unique<Dram>(
|
||||
("dram" + std::to_string(i)).c_str(), simConfig, *memSpec, tlmRecorders[i]));
|
||||
("dram" + std::to_string(i)).c_str(), simConfig, *memSpec, &tlmRecorders[i]));
|
||||
|
||||
if (simConfig.checkTLM2Protocol)
|
||||
controllersTlmCheckers.emplace_back(
|
||||
@@ -148,12 +148,10 @@ DRAMSys::DRAMSys(const sc_core::sc_module_name& name, const Config::Configuratio
|
||||
*memSpec,
|
||||
simConfig,
|
||||
*addressDecoder,
|
||||
std::shared_ptr<TlmRecorder>{}));
|
||||
nullptr));
|
||||
|
||||
drams.emplace_back(std::make_unique<Dram>(("dram" + std::to_string(i)).c_str(),
|
||||
simConfig,
|
||||
*memSpec,
|
||||
std::shared_ptr<TlmRecorder>{}));
|
||||
drams.emplace_back(std::make_unique<Dram>(
|
||||
("dram" + std::to_string(i)).c_str(), simConfig, *memSpec, nullptr));
|
||||
|
||||
if (simConfig.checkTLM2Protocol)
|
||||
{
|
||||
@@ -228,14 +226,14 @@ void DRAMSys::setupTlmRecorders(const std::string& traceName, const Config::Conf
|
||||
mcconfig[Config::McConfig::KEY] = config.mcconfig;
|
||||
memspec[Config::MemSpec::KEY] = config.memspec;
|
||||
|
||||
tlmRecorders.push_back(std::make_shared<TlmRecorder>(recorderName,
|
||||
simConfig,
|
||||
mcConfig,
|
||||
*memSpec,
|
||||
dbName,
|
||||
mcconfig.dump(),
|
||||
memspec.dump(),
|
||||
simConfig.simulationName));
|
||||
tlmRecorders.emplace_back(recorderName,
|
||||
simConfig,
|
||||
mcConfig,
|
||||
*memSpec,
|
||||
dbName,
|
||||
mcconfig.dump(),
|
||||
memspec.dump(),
|
||||
simConfig.simulationName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,7 +263,7 @@ void DRAMSys::end_of_simulation()
|
||||
if (simConfig.databaseRecording)
|
||||
{
|
||||
for (auto& tlmRecorder : tlmRecorders)
|
||||
tlmRecorder->finalize();
|
||||
tlmRecorder.finalize();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ private:
|
||||
|
||||
// Transaction Recorders (one per channel).
|
||||
// They generate the output databases.
|
||||
std::vector<std::shared_ptr<TlmRecorder>> tlmRecorders;
|
||||
std::vector<TlmRecorder> tlmRecorders;
|
||||
|
||||
std::vector<std::unique_ptr<TlmRecorderController>> tlmRecordersController;
|
||||
std::vector<std::unique_ptr<TlmRecorderDram>> tlmRecordersDram;
|
||||
|
||||
@@ -72,14 +72,14 @@ namespace DRAMSys
|
||||
Dram::Dram(const sc_module_name& name,
|
||||
const SimConfig& simConfig,
|
||||
const MemSpec& memSpec,
|
||||
std::shared_ptr<TlmRecorder> tlmRecorder) :
|
||||
TlmRecorder* tlmRecorder) :
|
||||
sc_module(name),
|
||||
memSpec(memSpec),
|
||||
storeMode(simConfig.storeMode),
|
||||
powerAnalysis(simConfig.powerAnalysis),
|
||||
channelSize(memSpec.getSimMemSizeInBytes() / memSpec.numberOfChannels),
|
||||
useMalloc(simConfig.useMalloc),
|
||||
tlmRecorder(std::move(tlmRecorder)),
|
||||
tlmRecorder(tlmRecorder),
|
||||
powerWindowSize(memSpec.tCK * simConfig.windowSize)
|
||||
{
|
||||
if (storeMode == Config::StoreModeType::Store)
|
||||
@@ -143,7 +143,7 @@ void Dram::reportPower()
|
||||
<< DRAMPower->getPower().average_power * memSpec.devicesPerRank << std::string(" mW")
|
||||
<< std::endl;
|
||||
|
||||
if (tlmRecorder)
|
||||
if (tlmRecorder != nullptr)
|
||||
{
|
||||
tlmRecorder->recordPower(sc_time_stamp().to_seconds(),
|
||||
this->DRAMPower->getPower().window_average_power *
|
||||
|
||||
@@ -69,7 +69,7 @@ protected:
|
||||
const uint64_t channelSize;
|
||||
const bool useMalloc;
|
||||
|
||||
std::shared_ptr<TlmRecorder> tlmRecorder;
|
||||
TlmRecorder* const tlmRecorder;
|
||||
sc_core::sc_time powerWindowSize;
|
||||
|
||||
#ifdef DRAMPOWER
|
||||
@@ -93,7 +93,7 @@ public:
|
||||
Dram(const sc_core::sc_module_name& name,
|
||||
const SimConfig& simConfig,
|
||||
const MemSpec& memSpec,
|
||||
std::shared_ptr<TlmRecorder> tlmRecorder);
|
||||
TlmRecorder* tlmRecorder);
|
||||
SC_HAS_PROCESS(Dram);
|
||||
|
||||
Dram(const Dram&) = delete;
|
||||
|
||||
Reference in New Issue
Block a user