Fixed nullptr segfault if no database recording
Dram and Controller handle this case now and are initialized with a shared_ptr pointing to null
This commit is contained in:
@@ -353,7 +353,8 @@ void Controller::recordBufferDepth()
|
||||
slidingAverageBufferDepth[index] = SC_ZERO_TIME;
|
||||
}
|
||||
|
||||
tlmRecorder->recordBufferDepth(sc_time_stamp().to_seconds(), windowAverageBufferDepth);
|
||||
if (simConfig.databaseRecording)
|
||||
tlmRecorder->recordBufferDepth(sc_time_stamp().to_seconds(), windowAverageBufferDepth);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,17 +91,17 @@ DRAMSys::DRAMSys(const sc_core::sc_module_name& name, const Config::Configuratio
|
||||
// Setup the debug manager:
|
||||
setupDebugManager(simConfig.simulationName);
|
||||
|
||||
std::string traceName = simConfig.simulationName;
|
||||
// Create and properly initialize TLM recorders.
|
||||
// They need to be ready before creating some modules.
|
||||
setupTlmRecorders(traceName, config);
|
||||
|
||||
// Instantiate all internal DRAMSys modules:
|
||||
if (simConfig.databaseRecording)
|
||||
{
|
||||
std::string traceName = simConfig.simulationName;
|
||||
if (!config.simulationid.empty())
|
||||
traceName = config.simulationid + '_' + traceName;
|
||||
|
||||
// Create and properly initialize TLM recorders.
|
||||
// They need to be ready before creating some modules.
|
||||
setupTlmRecorders(traceName, config);
|
||||
|
||||
// Create controllers and DRAMs
|
||||
for (std::size_t i = 0; i < memSpec->numberOfChannels; i++)
|
||||
{
|
||||
@@ -123,19 +123,19 @@ DRAMSys::DRAMSys(const sc_core::sc_module_name& name, const Config::Configuratio
|
||||
|
||||
// Not recording bandwidth between Arbiter - Controller
|
||||
tlmRecordersController.emplace_back(std::make_unique<TlmRecorderController>(
|
||||
("TlmRecorderWrapper" + std::to_string(i)).c_str(),
|
||||
("TlmRecorderController" + std::to_string(i)).c_str(),
|
||||
simConfig,
|
||||
*memSpec,
|
||||
tlmRecorders[i],
|
||||
false));
|
||||
|
||||
// Recording bandwidth between Controller - DRAM
|
||||
tlmRecordersDram.emplace_back(std::make_unique<TlmRecorderDram>(
|
||||
("TlmRecorderWrapper" + std::to_string(i)).c_str(),
|
||||
simConfig,
|
||||
*memSpec,
|
||||
tlmRecorders[i],
|
||||
true));
|
||||
tlmRecordersDram.emplace_back(
|
||||
std::make_unique<TlmRecorderDram>(("TlmRecorderDram" + std::to_string(i)).c_str(),
|
||||
simConfig,
|
||||
*memSpec,
|
||||
tlmRecorders[i],
|
||||
true));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -148,10 +148,12 @@ DRAMSys::DRAMSys(const sc_core::sc_module_name& name, const Config::Configuratio
|
||||
*memSpec,
|
||||
simConfig,
|
||||
*addressDecoder,
|
||||
tlmRecorders[i]));
|
||||
std::shared_ptr<TlmRecorder>{}));
|
||||
|
||||
drams.emplace_back(std::make_unique<Dram>(
|
||||
("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,
|
||||
std::shared_ptr<TlmRecorder>{}));
|
||||
|
||||
if (simConfig.checkTLM2Protocol)
|
||||
{
|
||||
@@ -256,8 +258,11 @@ void DRAMSys::end_of_simulation()
|
||||
dram->reportPower();
|
||||
}
|
||||
|
||||
for (auto& tlmRecorder : tlmRecorders)
|
||||
tlmRecorder->finalize();
|
||||
if (simConfig.databaseRecording)
|
||||
{
|
||||
for (auto& tlmRecorder : tlmRecorders)
|
||||
tlmRecorder->finalize();
|
||||
}
|
||||
}
|
||||
|
||||
void DRAMSys::logo()
|
||||
|
||||
@@ -143,9 +143,12 @@ void Dram::reportPower()
|
||||
<< 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);
|
||||
if (tlmRecorder)
|
||||
{
|
||||
tlmRecorder->recordPower(sc_time_stamp().to_seconds(),
|
||||
this->DRAMPower->getPower().window_average_power *
|
||||
this->memSpec.devicesPerRank);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -301,10 +304,13 @@ void Dram::powerWindow()
|
||||
// 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);
|
||||
if (tlmRecorder)
|
||||
{
|
||||
// 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(),
|
||||
|
||||
Reference in New Issue
Block a user