Moved TlmRecorder from reference to smart pointer
This commit is contained in:
@@ -13,11 +13,11 @@ namespace DRAMSys
|
||||
TlmRecorderArbiter::TlmRecorderArbiter(const sc_core::sc_module_name& name,
|
||||
const SimConfig& simConfig,
|
||||
const MemSpec& memSpec,
|
||||
TlmRecorder& tlmRecorder,
|
||||
std::shared_ptr<TlmRecorder> tlmRecorder,
|
||||
bool enableBandwidth) :
|
||||
sc_module(name),
|
||||
memSpec(memSpec),
|
||||
tlmRecorder(tlmRecorder),
|
||||
tlmRecorder(std::move(tlmRecorder)),
|
||||
enableWindowing(simConfig.enableWindowing),
|
||||
pseudoChannelMode(memSpec.pseudoChannelMode()),
|
||||
ranksPerChannel(memSpec.ranksPerChannel),
|
||||
@@ -52,7 +52,7 @@ tlm::tlm_sync_enum TlmRecorderArbiter::nb_transport_fw(tlm::tlm_generic_payload&
|
||||
numberOfBytesServed += trans.get_data_length();
|
||||
}
|
||||
|
||||
tlmRecorder.recordPhase(trans, phase, delay);
|
||||
tlmRecorder->recordPhase(trans, phase, delay);
|
||||
return iSocket->nb_transport_fw(trans, phase, delay);
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ tlm::tlm_sync_enum TlmRecorderArbiter::nb_transport_bw(tlm::tlm_generic_payload&
|
||||
numberOfBytesServed += trans.get_data_length();
|
||||
}
|
||||
|
||||
tlmRecorder.recordPhase(trans, phase, delay);
|
||||
tlmRecorder->recordPhase(trans, phase, delay);
|
||||
return tSocket->nb_transport_bw(trans, phase, delay);
|
||||
}
|
||||
|
||||
@@ -86,13 +86,7 @@ void TlmRecorderArbiter::recordBandwidth()
|
||||
|
||||
double windowBandwidth =
|
||||
static_cast<double>(windowNumberOfBytesServed) / (windowSizeTime.to_seconds());
|
||||
tlmRecorder.recordBandwidth(sc_core::sc_time_stamp().to_seconds(), windowBandwidth);
|
||||
|
||||
// sc_core::sc_time windowActiveTime =
|
||||
// activeTimeMultiplier * static_cast<double>(windowNumberOfBytesServed);
|
||||
// double windowAverageBandwidth = windowNumberOfBytesServed / maxBandwidth;
|
||||
// tlmRecorder.recordBandwidth(sc_core::sc_time_stamp().to_seconds(),
|
||||
// windowAverageBandwidth);
|
||||
tlmRecorder->recordBandwidth(sc_core::sc_time_stamp().to_seconds(), windowBandwidth);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
TlmRecorderArbiter(const sc_core::sc_module_name& name,
|
||||
const SimConfig& simConfig,
|
||||
const MemSpec& memspec,
|
||||
TlmRecorder& tlmRecorder,
|
||||
std::shared_ptr<TlmRecorder> tlmRecorder,
|
||||
bool enableBandwidth);
|
||||
~TlmRecorderArbiter() = default;
|
||||
|
||||
@@ -39,8 +39,7 @@ public:
|
||||
|
||||
private:
|
||||
const MemSpec& memSpec;
|
||||
// HACK: Refactor with shared pointers?
|
||||
TlmRecorder& tlmRecorder;
|
||||
std::shared_ptr<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,
|
||||
TlmRecorder& tlmRecorder,
|
||||
std::shared_ptr<TlmRecorder> tlmRecorder,
|
||||
bool enableBandwidth) :
|
||||
sc_module(name),
|
||||
tlmRecorder(tlmRecorder),
|
||||
tlmRecorder(std::move(tlmRecorder)),
|
||||
enableWindowing(simConfig.enableWindowing),
|
||||
pseudoChannelMode(memSpec.pseudoChannelMode()),
|
||||
ranksPerChannel(memSpec.ranksPerChannel),
|
||||
@@ -55,7 +55,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);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,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);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,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,
|
||||
TlmRecorder& tlmRecorder,
|
||||
std::shared_ptr<TlmRecorder> tlmRecorder,
|
||||
bool enableBandwidth);
|
||||
~TlmRecorderDram() = default;
|
||||
|
||||
@@ -38,8 +38,7 @@ public:
|
||||
sc_core::sc_time& delay);
|
||||
|
||||
private:
|
||||
// HACK: Refactor with shared pointers?
|
||||
TlmRecorder& tlmRecorder;
|
||||
std::shared_ptr<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,
|
||||
TlmRecorder& tlmRecorder) :
|
||||
std::shared_ptr<TlmRecorder> tlmRecorder) :
|
||||
sc_module(name),
|
||||
config(config),
|
||||
memSpec(memSpec),
|
||||
simConfig(simConfig),
|
||||
addressDecoder(addressDecoder),
|
||||
tlmRecorder(tlmRecorder),
|
||||
tlmRecorder(std::move(tlmRecorder)),
|
||||
windowSizeTime(simConfig.windowSize * memSpec.tCK),
|
||||
nextWindowEventTime(windowSizeTime),
|
||||
numberOfBeatsServed(memSpec.ranksPerChannel, 0),
|
||||
@@ -353,7 +353,7 @@ void Controller::recordBufferDepth()
|
||||
slidingAverageBufferDepth[index] = SC_ZERO_TIME;
|
||||
}
|
||||
|
||||
tlmRecorder.recordBufferDepth(sc_time_stamp().to_seconds(), windowAverageBufferDepth);
|
||||
tlmRecorder->recordBufferDepth(sc_time_stamp().to_seconds(), windowAverageBufferDepth);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
const MemSpec& memSpec,
|
||||
const SimConfig& simConfig,
|
||||
const AddressDecoder& addressDecoder,
|
||||
TlmRecorder& tlmRecorder);
|
||||
std::shared_ptr<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;
|
||||
TlmRecorder& tlmRecorder;
|
||||
std::shared_ptr<TlmRecorder> tlmRecorder;
|
||||
|
||||
std::unique_ptr<SchedulerIF> scheduler;
|
||||
|
||||
|
||||
@@ -223,14 +223,14 @@ void DRAMSys::setupTlmRecorders(const std::string& traceName, const Config::Conf
|
||||
mcconfig[Config::McConfig::KEY] = config.mcconfig;
|
||||
memspec[Config::MemSpec::KEY] = config.memspec;
|
||||
|
||||
tlmRecorders.emplace_back(recorderName,
|
||||
simConfig,
|
||||
mcConfig,
|
||||
*memSpec,
|
||||
dbName,
|
||||
mcconfig.dump(),
|
||||
memspec.dump(),
|
||||
simConfig.simulationName);
|
||||
tlmRecorders.push_back(std::make_shared<TlmRecorder>(recorderName,
|
||||
simConfig,
|
||||
mcConfig,
|
||||
*memSpec,
|
||||
dbName,
|
||||
mcconfig.dump(),
|
||||
memspec.dump(),
|
||||
simConfig.simulationName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,7 +258,7 @@ void DRAMSys::end_of_simulation()
|
||||
}
|
||||
|
||||
for (auto& tlmRecorder : tlmRecorders)
|
||||
tlmRecorder.finalize();
|
||||
tlmRecorder->finalize();
|
||||
}
|
||||
|
||||
void DRAMSys::logo()
|
||||
|
||||
@@ -127,7 +127,7 @@ private:
|
||||
|
||||
// Transaction Recorders (one per channel).
|
||||
// They generate the output databases.
|
||||
std::vector<TlmRecorder> tlmRecorders;
|
||||
std::vector<std::shared_ptr<TlmRecorder>> tlmRecorders;
|
||||
|
||||
std::vector<std::unique_ptr<TlmRecorderArbiter>> tlmWrappersArbiter;
|
||||
std::vector<std::unique_ptr<TlmRecorderDram>> tlmWrappersDram;
|
||||
|
||||
@@ -72,14 +72,14 @@ namespace DRAMSys
|
||||
Dram::Dram(const sc_module_name& name,
|
||||
const SimConfig& simConfig,
|
||||
const MemSpec& memSpec,
|
||||
TlmRecorder& tlmRecorder) :
|
||||
std::shared_ptr<TlmRecorder> tlmRecorder) :
|
||||
sc_module(name),
|
||||
memSpec(memSpec),
|
||||
storeMode(simConfig.storeMode),
|
||||
powerAnalysis(simConfig.powerAnalysis),
|
||||
channelSize(memSpec.getSimMemSizeInBytes() / memSpec.numberOfChannels),
|
||||
useMalloc(simConfig.useMalloc),
|
||||
tlmRecorder(tlmRecorder),
|
||||
tlmRecorder(std::move(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;
|
||||
|
||||
tlmRecorder.recordPower(sc_time_stamp().to_seconds(),
|
||||
tlmRecorder->recordPower(sc_time_stamp().to_seconds(),
|
||||
this->DRAMPower->getPower().window_average_power *
|
||||
this->memSpec.devicesPerRank);
|
||||
#endif
|
||||
@@ -302,7 +302,7 @@ void Dram::powerWindow()
|
||||
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(),
|
||||
tlmRecorder->recordPower(sc_time_stamp().to_seconds(),
|
||||
this->DRAMPower->getPower().window_average_power *
|
||||
this->memSpec.devicesPerRank);
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ protected:
|
||||
const uint64_t channelSize;
|
||||
const bool useMalloc;
|
||||
|
||||
TlmRecorder& tlmRecorder;
|
||||
std::shared_ptr<TlmRecorder> 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,
|
||||
TlmRecorder& tlmRecorder);
|
||||
std::shared_ptr<TlmRecorder> tlmRecorder);
|
||||
SC_HAS_PROCESS(Dram);
|
||||
|
||||
Dram(const Dram&) = delete;
|
||||
|
||||
Reference in New Issue
Block a user