diff --git a/src/libdramsys/DRAMSys/common/TlmRecorderController.cpp b/src/libdramsys/DRAMSys/common/TlmRecorderController.cpp index 5bdcd34f..e9e00b3f 100644 --- a/src/libdramsys/DRAMSys/common/TlmRecorderController.cpp +++ b/src/libdramsys/DRAMSys/common/TlmRecorderController.cpp @@ -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, 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(windowNumberOfBytesServed) / (windowSizeTime.to_seconds()); - tlmRecorder->recordBandwidth(sc_core::sc_time_stamp().to_seconds(), windowBandwidth); + tlmRecorder.recordBandwidth(sc_core::sc_time_stamp().to_seconds(), windowBandwidth); } } diff --git a/src/libdramsys/DRAMSys/common/TlmRecorderController.h b/src/libdramsys/DRAMSys/common/TlmRecorderController.h index 5c63f52b..0df7c62e 100644 --- a/src/libdramsys/DRAMSys/common/TlmRecorderController.h +++ b/src/libdramsys/DRAMSys/common/TlmRecorderController.h @@ -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, bool enableBandwidth); ~TlmRecorderController() = default; @@ -41,7 +41,7 @@ public: private: const MemSpec& memSpec; - std::shared_ptr tlmRecorder; + TlmRecorder& tlmRecorder; const bool enableWindowing; const bool pseudoChannelMode; const unsigned int ranksPerChannel; diff --git a/src/libdramsys/DRAMSys/common/TlmRecorderDram.cpp b/src/libdramsys/DRAMSys/common/TlmRecorderDram.cpp index e4f0c6f8..68c2807e 100644 --- a/src/libdramsys/DRAMSys/common/TlmRecorderDram.cpp +++ b/src/libdramsys/DRAMSys/common/TlmRecorderDram.cpp @@ -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, 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(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); } } diff --git a/src/libdramsys/DRAMSys/common/TlmRecorderDram.h b/src/libdramsys/DRAMSys/common/TlmRecorderDram.h index 8ac3d5b0..e6d5704f 100644 --- a/src/libdramsys/DRAMSys/common/TlmRecorderDram.h +++ b/src/libdramsys/DRAMSys/common/TlmRecorderDram.h @@ -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, 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; const bool enableWindowing; const bool pseudoChannelMode; const unsigned int ranksPerChannel; diff --git a/src/libdramsys/DRAMSys/controller/Controller.cpp b/src/libdramsys/DRAMSys/controller/Controller.cpp index e18c7ef1..6e7c1484 100644 --- a/src/libdramsys/DRAMSys/controller/Controller.cpp +++ b/src/libdramsys/DRAMSys/controller/Controller.cpp @@ -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) : 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); } } diff --git a/src/libdramsys/DRAMSys/controller/Controller.h b/src/libdramsys/DRAMSys/controller/Controller.h index 4278ed89..79169c8f 100644 --- a/src/libdramsys/DRAMSys/controller/Controller.h +++ b/src/libdramsys/DRAMSys/controller/Controller.h @@ -74,7 +74,7 @@ public: const MemSpec& memSpec, const SimConfig& simConfig, const AddressDecoder& addressDecoder, - std::shared_ptr 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* const tlmRecorder; std::unique_ptr scheduler; diff --git a/src/libdramsys/DRAMSys/simulation/DRAMSys.cpp b/src/libdramsys/DRAMSys/simulation/DRAMSys.cpp index ba2a93c4..9aaa2949 100644 --- a/src/libdramsys/DRAMSys/simulation/DRAMSys.cpp +++ b/src/libdramsys/DRAMSys/simulation/DRAMSys.cpp @@ -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" + 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{})); + nullptr)); - drams.emplace_back(std::make_unique(("dram" + std::to_string(i)).c_str(), - simConfig, - *memSpec, - std::shared_ptr{})); + drams.emplace_back(std::make_unique( + ("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(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(); } } diff --git a/src/libdramsys/DRAMSys/simulation/DRAMSys.h b/src/libdramsys/DRAMSys/simulation/DRAMSys.h index 410fd0f3..acfe0287 100644 --- a/src/libdramsys/DRAMSys/simulation/DRAMSys.h +++ b/src/libdramsys/DRAMSys/simulation/DRAMSys.h @@ -126,7 +126,7 @@ private: // Transaction Recorders (one per channel). // They generate the output databases. - std::vector> tlmRecorders; + std::vector tlmRecorders; std::vector> tlmRecordersController; std::vector> tlmRecordersDram; diff --git a/src/libdramsys/DRAMSys/simulation/Dram.cpp b/src/libdramsys/DRAMSys/simulation/Dram.cpp index f6ae99e1..22e8e756 100644 --- a/src/libdramsys/DRAMSys/simulation/Dram.cpp +++ b/src/libdramsys/DRAMSys/simulation/Dram.cpp @@ -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) : 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 * diff --git a/src/libdramsys/DRAMSys/simulation/Dram.h b/src/libdramsys/DRAMSys/simulation/Dram.h index 40581fe3..05742a91 100644 --- a/src/libdramsys/DRAMSys/simulation/Dram.h +++ b/src/libdramsys/DRAMSys/simulation/Dram.h @@ -69,7 +69,7 @@ protected: const uint64_t channelSize; const bool useMalloc; - std::shared_ptr 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); SC_HAS_PROCESS(Dram); Dram(const Dram&) = delete;