From ca36faa40342ad7d520e3d734055ef0e4a519ccd Mon Sep 17 00:00:00 2001 From: "Lukas Steiner (2)" Date: Thu, 8 Aug 2019 09:45:22 +0200 Subject: [PATCH] Changed printDebugMessage into macro to turn it off completely for speedup. --- DRAMSys/library/src/common/DebugManager.h | 8 +++++ DRAMSys/library/src/common/TlmRecorder.cpp | 29 +++++++------------ DRAMSys/library/src/common/TlmRecorder.h | 2 -- .../library/src/controller/ControllerNew.cpp | 21 +++++--------- .../library/src/controller/ControllerNew.h | 4 --- .../src/controller/ControllerRecordable.cpp | 2 +- .../src/controller/checker/CheckerDDR3.cpp | 2 +- .../src/controller/checker/CheckerIF.h | 5 ---- .../src/controller/scheduler/SchedulerIF.h | 5 ---- DRAMSys/library/src/simulation/Arbiter.cpp | 9 ++---- DRAMSys/library/src/simulation/Arbiter.h | 2 -- DRAMSys/library/src/simulation/DRAMSys.cpp | 2 +- DRAMSys/library/src/simulation/Dram.cpp | 7 +---- DRAMSys/library/src/simulation/Dram.h | 2 -- .../library/src/simulation/DramRecordable.cpp | 7 ++--- .../library/src/simulation/MemoryManager.cpp | 4 +-- .../library/src/simulation/TracePlayer.cpp | 8 +---- DRAMSys/library/src/simulation/TracePlayer.h | 1 - 18 files changed, 39 insertions(+), 81 deletions(-) diff --git a/DRAMSys/library/src/common/DebugManager.h b/DRAMSys/library/src/common/DebugManager.h index dd35b796..0d61f33a 100644 --- a/DRAMSys/library/src/common/DebugManager.h +++ b/DRAMSys/library/src/common/DebugManager.h @@ -37,6 +37,14 @@ #ifndef DEBUGMANAGER_H #define DEBUGMANAGER_H +//#define DEBUGGING + +#ifdef DEBUGGING +#define PRINTDEBUGMESSAGE(sender, message) DebugManager::getInstance().printDebugMessage(sender, message) +#else +#define PRINTDEBUGMESSAGE(sender, message) +#endif + #include #include #include diff --git a/DRAMSys/library/src/common/TlmRecorder.cpp b/DRAMSys/library/src/common/TlmRecorder.cpp index e470cf27..6a208bb4 100644 --- a/DRAMSys/library/src/common/TlmRecorder.cpp +++ b/DRAMSys/library/src/common/TlmRecorder.cpp @@ -66,7 +66,7 @@ TlmRecorder::TlmRecorder(sc_module_name name, string uri, string dbname) : createTables(TlmRecorder::sqlScriptURI); prepareSqlStatements(); - printDebugMessage("Starting new database transaction"); + PRINTDEBUGMESSAGE(this->name(), "Starting new database transaction"); } TlmRecorder::~TlmRecorder() @@ -153,13 +153,12 @@ void TlmRecorder::introduceTransactionSystem(tlm::tlm_generic_payload &trans) currentTransactionsInSystem[&trans].timeOfGeneration = GenerationExtension::getExtension(&trans).TimeOfGeneration(); - printDebugMessage("New transaction #" + to_string(id) + " generation time " + + PRINTDEBUGMESSAGE(name(), "New transaction #" + to_string(id) + " generation time " + currentTransactionsInSystem[&trans].timeOfGeneration.to_string()); if (id % transactionCommitRate == 0) { - printDebugMessage( - "Committing transactions " + to_string(id - transactionCommitRate + 1) + " - " - + to_string(id)); + PRINTDEBUGMESSAGE(name(), "Committing transactions " + + to_string(id - transactionCommitRate + 1) + " - " + to_string(id)); commitRecordedDataToDB(); } } @@ -168,8 +167,8 @@ void TlmRecorder::removeTransactionFromSystem(tlm::tlm_generic_payload &trans) { assert(currentTransactionsInSystem.count(&trans) != 0); - printDebugMessage("Removing transaction #" + to_string( - currentTransactionsInSystem[&trans].id)); + PRINTDEBUGMESSAGE(name(), "Removing transaction #" + + to_string(currentTransactionsInSystem[&trans].id)); Transaction &recordingData = currentTransactionsInSystem[&trans]; recordedData.push_back(recordingData); @@ -415,7 +414,7 @@ void TlmRecorder::executeSqlStatement(sqlite3_stmt *statement) void TlmRecorder::executeSqlCommand(string command) { - printDebugMessage("Creating database by running provided sql script"); + PRINTDEBUGMESSAGE(name(), "Creating database by running provided sql script"); char *errMsg = 0; int rc = sqlite3_exec(db, command.c_str(), NULL, 0, &errMsg); @@ -424,22 +423,16 @@ void TlmRecorder::executeSqlCommand(string command) sqlite3_free(errMsg); } - printDebugMessage("Database created successfully"); -} - -void TlmRecorder::printDebugMessage(std::string message) -{ - DebugManager::getInstance().printDebugMessage(this->name(), message); + PRINTDEBUGMESSAGE(name(), "Database created successfully"); } void TlmRecorder::closeConnection() { commitRecordedDataToDB(); insertGeneralInfo(); - printDebugMessage( - "Number of transactions written to DB: " + std::to_string( - totalNumTransactions - 1)); - printDebugMessage("tlmPhaseRecorder:\tEnd Recording"); + PRINTDEBUGMESSAGE(name(), "Number of transactions written to DB: " + + std::to_string(totalNumTransactions - 1)); + PRINTDEBUGMESSAGE(name(), "tlmPhaseRecorder:\tEnd Recording"); sqlite3_close(db); db = NULL; } diff --git a/DRAMSys/library/src/common/TlmRecorder.h b/DRAMSys/library/src/common/TlmRecorder.h index bfd4ae9f..ea016dff 100644 --- a/DRAMSys/library/src/common/TlmRecorder.h +++ b/DRAMSys/library/src/common/TlmRecorder.h @@ -130,8 +130,6 @@ private: unsigned int transactionID); void insertDebugMessageInDB(string message, const sc_time &time); - void printDebugMessage(std::string message); - static const int transactionCommitRate = 1000; vector recordedData; map currentTransactionsInSystem; diff --git a/DRAMSys/library/src/controller/ControllerNew.cpp b/DRAMSys/library/src/controller/ControllerNew.cpp index 2a4562f4..8113e83d 100644 --- a/DRAMSys/library/src/controller/ControllerNew.cpp +++ b/DRAMSys/library/src/controller/ControllerNew.cpp @@ -45,7 +45,7 @@ #include "checker/CheckerDDR3.h" ControllerNew::ControllerNew(sc_module_name name) : - GenericController(name), debugManager(&DebugManager::getInstance()) + GenericController(name) { SC_METHOD(controllerMethod); sensitive << triggerEvent << triggerEventQueue; @@ -126,7 +126,7 @@ tlm_sync_enum ControllerNew::nb_transport_fw(tlm_generic_payload &trans, else SC_REPORT_FATAL(0, "nb_transport_fw in controller was triggered with unknown phase"); - printDebugMessage("[fw] " + phaseNameToString(phase) + " notification in " + + PRINTDEBUGMESSAGE(name(), "[fw] " + phaseNameToString(phase) + " notification in " + notificationDelay.to_string()); triggerEventQueueAfterDelay(notificationDelay); @@ -136,7 +136,7 @@ tlm_sync_enum ControllerNew::nb_transport_fw(tlm_generic_payload &trans, tlm_sync_enum ControllerNew::nb_transport_bw(tlm_generic_payload &trans, tlm_phase &phase, sc_time &delay) { - printDebugMessage("[bw] " + phaseNameToString(phase) + " notification in " + + PRINTDEBUGMESSAGE(name(), "[bw] " + phaseNameToString(phase) + " notification in " + delay.to_string()); triggerEventQueueAfterDelay(delay); if (phase == END_RD || phase == END_WR) @@ -153,11 +153,6 @@ unsigned int ControllerNew::transport_dbg(tlm_generic_payload &) return 0; } -void ControllerNew::printDebugMessage(std::string message) -{ - debugManager->printDebugMessage(name(), message); -} - void ControllerNew::triggerEventAfterDelay(sc_time delay) { if (delay != SC_ZERO_TIME) @@ -187,7 +182,7 @@ void ControllerNew::controllerMethod() if (numberOfPayloads < Configuration::getInstance().MaxNrOfTransactions) acquirePayload(); else - printDebugMessage("Total number of payloads exceeded, backpressure!"); + PRINTDEBUGMESSAGE(name(), "Total number of payloads exceeded, backpressure!"); } // (3) Send result to arbiter @@ -238,7 +233,7 @@ void ControllerNew::controllerMethod() void ControllerNew::releasePayload() { uint64_t id = DramExtension::getPayloadID(payloadToRelease); - printDebugMessage("Payload " + std::to_string(id) + " left system."); + PRINTDEBUGMESSAGE(name(), "Payload " + std::to_string(id) + " left system."); payloadToRelease->release(); numberOfPayloads--; @@ -252,7 +247,7 @@ void ControllerNew::releasePayload() void ControllerNew::acquirePayload() { uint64_t id = DramExtension::getPayloadID(payloadToAcquire); - printDebugMessage("Payload " + std::to_string(id) + " entered system."); + PRINTDEBUGMESSAGE(name(), "Payload " + std::to_string(id) + " entered system."); if (numberOfPayloads == 0) endBandwithIdleCollector(); @@ -297,7 +292,7 @@ void ControllerNew::startBandwidthIdleCollector() { if (!isIdle) { - printDebugMessage("IDLE start"); + PRINTDEBUGMESSAGE(name(), "IDLE start"); idleStart = sc_time_stamp(); isIdle = true; } @@ -307,7 +302,7 @@ void ControllerNew::endBandwithIdleCollector() { if (isIdle) { - printDebugMessage("IDLE end"); + PRINTDEBUGMESSAGE(name(), "IDLE end"); idleTime += sc_time_stamp() - idleStart; isIdle = false; } diff --git a/DRAMSys/library/src/controller/ControllerNew.h b/DRAMSys/library/src/controller/ControllerNew.h index 71f9b532..6bf2cf8d 100644 --- a/DRAMSys/library/src/controller/ControllerNew.h +++ b/DRAMSys/library/src/controller/ControllerNew.h @@ -71,8 +71,6 @@ protected: virtual void sendToFrontend(tlm_generic_payload *, tlm_phase); virtual void sendToDram(Command, tlm_generic_payload *); - void printDebugMessage(std::string); - private: unsigned numberOfPayloads = 0; tlm_generic_payload *payloadToAcquire = nullptr; @@ -81,8 +79,6 @@ private: sc_time timeToRelease = SC_ZERO_TIME; std::queue> responseQueue; - DebugManager *debugManager; - std::map bankMachines; CmdMuxIF *commandMux; SchedulerIF *scheduler; diff --git a/DRAMSys/library/src/controller/ControllerRecordable.cpp b/DRAMSys/library/src/controller/ControllerRecordable.cpp index 8457f5e7..218d221a 100644 --- a/DRAMSys/library/src/controller/ControllerRecordable.cpp +++ b/DRAMSys/library/src/controller/ControllerRecordable.cpp @@ -82,7 +82,7 @@ void ControllerRecordable::recordPhase(tlm_generic_payload &trans, tlm_phase pha unsigned int col = DramExtension::getExtension(trans).getColumn().ID(); uint64_t id = DramExtension::getExtension(trans).getPayloadID(); - printDebugMessage("Recording " + phaseNameToString(phase) + " thread " + + PRINTDEBUGMESSAGE(name(), "Recording " + phaseNameToString(phase) + " thread " + to_string(thr) + " channel " + to_string(ch) + " bank group " + to_string( bg) + " bank " + to_string(bank) + " row " + to_string(row) + " column " + to_string(col) + " id " + to_string(id) + " at " + recTime.to_string()); diff --git a/DRAMSys/library/src/controller/checker/CheckerDDR3.cpp b/DRAMSys/library/src/controller/checker/CheckerDDR3.cpp index affd8195..f60103a0 100644 --- a/DRAMSys/library/src/controller/checker/CheckerDDR3.cpp +++ b/DRAMSys/library/src/controller/checker/CheckerDDR3.cpp @@ -171,7 +171,7 @@ sc_time CheckerDDR3::timeToSatisfyFAW() void CheckerDDR3::insert(const ScheduledCommand &scheduledCommand) { Command command = scheduledCommand.getCommand(); - printDebugMessage("Changing state on bank " + + PRINTDEBUGMESSAGE("CheckerDDR3", "Changing state on bank " + to_string(scheduledCommand.getBank().ID()) + " command is " + commandToString(command)); diff --git a/DRAMSys/library/src/controller/checker/CheckerIF.h b/DRAMSys/library/src/controller/checker/CheckerIF.h index 1d0c6b70..9a7c4e0a 100644 --- a/DRAMSys/library/src/controller/checker/CheckerIF.h +++ b/DRAMSys/library/src/controller/checker/CheckerIF.h @@ -55,11 +55,6 @@ protected: std::map lastScheduledByCommand; ScheduledCommand lastScheduled; - void printDebugMessage(std::string message) - { - DebugManager::getInstance().printDebugMessage("Checker", message); - } - // PowerDown TODO: Implement this method? //sc_time getTimeConstraintToEnterPowerDown(Command lastCmd, Command pdnCmd) const; }; diff --git a/DRAMSys/library/src/controller/scheduler/SchedulerIF.h b/DRAMSys/library/src/controller/scheduler/SchedulerIF.h index d608db9b..e07f3d03 100644 --- a/DRAMSys/library/src/controller/scheduler/SchedulerIF.h +++ b/DRAMSys/library/src/controller/scheduler/SchedulerIF.h @@ -51,11 +51,6 @@ public: virtual ~SchedulerIF() {} virtual void storeRequest(tlm_generic_payload *) = 0; virtual tlm_generic_payload *getNextRequest(Bank, BankMachine *) = 0; -protected: - void printDebugMessage(std::string message) - { - DebugManager::getInstance().printDebugMessage("Scheduler", message); - } }; #endif // SCHEDULERIF_H diff --git a/DRAMSys/library/src/simulation/Arbiter.cpp b/DRAMSys/library/src/simulation/Arbiter.cpp index 3b7e8217..a5543332 100644 --- a/DRAMSys/library/src/simulation/Arbiter.cpp +++ b/DRAMSys/library/src/simulation/Arbiter.cpp @@ -87,7 +87,7 @@ tlm_sync_enum Arbiter::nb_transport_fw(int id, tlm_generic_payload &payload, payload.release(); } - printDebugMessage("[fw] " + phaseNameToString(phase) + " notification in " + + PRINTDEBUGMESSAGE(name(), "[fw] " + phaseNameToString(phase) + " notification in " + notDelay.to_string()); payloadEventQueue.notify(payload, phase, notDelay); return TLM_ACCEPTED; @@ -102,7 +102,7 @@ tlm_sync_enum Arbiter::nb_transport_bw(int channelId, tlm_generic_payload &paylo if ((unsigned int)channelId != DramExtension::getExtension(payload).getChannel().ID()) SC_REPORT_FATAL("Arbiter", "Payload extension was corrupted"); - printDebugMessage("[bw] " + phaseNameToString(phase) + " notification in " + + PRINTDEBUGMESSAGE(name(), "[bw] " + phaseNameToString(phase) + " notification in " + bwDelay.to_string()); payloadEventQueue.notify(payload, phase, bwDelay); return TLM_ACCEPTED; @@ -246,8 +246,3 @@ bool Arbiter::addressIsValid(DecodedAddress &decodedAddress) } return true; } - -void Arbiter::printDebugMessage(std::string message) -{ - DebugManager::getInstance().printDebugMessage(this->name(), message); -} diff --git a/DRAMSys/library/src/simulation/Arbiter.h b/DRAMSys/library/src/simulation/Arbiter.h index cb2bc27a..1be19fe8 100644 --- a/DRAMSys/library/src/simulation/Arbiter.h +++ b/DRAMSys/library/src/simulation/Arbiter.h @@ -99,8 +99,6 @@ private: std::vector nextPayloadID; bool addressIsValid(DecodedAddress &decodedAddress); - - void printDebugMessage(std::string message); }; #endif // ARBITER_H diff --git a/DRAMSys/library/src/simulation/DRAMSys.cpp b/DRAMSys/library/src/simulation/DRAMSys.cpp index db9796d4..51c7a978 100644 --- a/DRAMSys/library/src/simulation/DRAMSys.cpp +++ b/DRAMSys/library/src/simulation/DRAMSys.cpp @@ -360,6 +360,6 @@ DRAMSys::~DRAMSys() void DRAMSys::report(string message) { - DebugManager::getInstance().printDebugMessage(this->name(), message); + PRINTDEBUGMESSAGE(name(), message); cout << message << endl; } diff --git a/DRAMSys/library/src/simulation/Dram.cpp b/DRAMSys/library/src/simulation/Dram.cpp index 76a3717f..a8f08083 100644 --- a/DRAMSys/library/src/simulation/Dram.cpp +++ b/DRAMSys/library/src/simulation/Dram.cpp @@ -345,7 +345,7 @@ tlm_sync_enum Dram::nb_transport_fw(tlm_generic_payload &payload, unsigned int Dram::transport_dbg(tlm_generic_payload &trans) { - printDebugMessage("transport_dgb"); + PRINTDEBUGMESSAGE(name(), "transport_dgb"); // TODO: This part is not tested yet, neither with traceplayers nor with GEM5 coupling if (StoreMode == StorageMode::NoStorage) @@ -401,8 +401,3 @@ void Dram::sendToController(tlm_generic_payload &payload, const tlm_phase &phase sc_time TDelay = delay; tSocket->nb_transport_bw(payload, TPhase, TDelay); } - -void Dram::printDebugMessage(string message) -{ - DebugManager::getInstance().printDebugMessage(name(), message); -} diff --git a/DRAMSys/library/src/simulation/Dram.h b/DRAMSys/library/src/simulation/Dram.h index 6b551f4d..4ae01c33 100644 --- a/DRAMSys/library/src/simulation/Dram.h +++ b/DRAMSys/library/src/simulation/Dram.h @@ -74,8 +74,6 @@ protected: void sendToController(tlm_generic_payload &payload, const tlm_phase &phase, const sc_time &delay); - void printDebugMessage(string message); - public: tlm_utils::simple_target_socket tSocket; diff --git a/DRAMSys/library/src/simulation/DramRecordable.cpp b/DRAMSys/library/src/simulation/DramRecordable.cpp index 0ed6f553..c54e255d 100644 --- a/DRAMSys/library/src/simulation/DramRecordable.cpp +++ b/DRAMSys/library/src/simulation/DramRecordable.cpp @@ -85,8 +85,7 @@ tlm_sync_enum DramRecordable::nb_transport_fw(tlm_generic_payload &pay unsigned int row = DramExtension::getExtension(payload).getRow().ID(); unsigned int col = DramExtension::getExtension(payload).getColumn().ID(); - // TODO: printDebugMessage not inherited - this->printDebugMessage("Recording " + phaseNameToString(phase) + " thread " + + PRINTDEBUGMESSAGE(this->name(), "Recording " + phaseNameToString(phase) + " thread " + to_string(thr) + " channel " + to_string(ch) + " bank group " + to_string( bg) + " bank " + to_string(bank) + " row " + to_string(row) + " column " + to_string(col) + " at " + recTime.to_string()); @@ -119,10 +118,10 @@ void DramRecordable::powerWindow() recordPower(); // Here considering that DRAMPower provides the energy in pJ and the power in mW - this->printDebugMessage(string("\tWindow Energy: \t") + to_string( + PRINTDEBUGMESSAGE(this->name(), string("\tWindow Energy: \t") + to_string( this->DRAMPower->getEnergy().window_energy * Configuration::getInstance().NumberOfDevicesOnDIMM) + string("\t[pJ]")); - this->printDebugMessage(string("\tWindow Average Power: \t") + to_string( + PRINTDEBUGMESSAGE(this->name(), string("\tWindow Average Power: \t") + to_string( this->DRAMPower->getPower().window_average_power * Configuration::getInstance().NumberOfDevicesOnDIMM) + string("\t[mW]")); diff --git a/DRAMSys/library/src/simulation/MemoryManager.cpp b/DRAMSys/library/src/simulation/MemoryManager.cpp index 6f456272..08792b1e 100644 --- a/DRAMSys/library/src/simulation/MemoryManager.cpp +++ b/DRAMSys/library/src/simulation/MemoryManager.cpp @@ -53,8 +53,8 @@ MemoryManager::~MemoryManager() } //Comment in if you are suspecting a memory leak in the manager - //DebugManager::getInstance().printDebugMessage("MemoryManager","Number of allocated payloads: " + to_string(numberOfAllocations)); - //DebugManager::getInstance().printDebugMessage("MemoryManager","Number of freed payloads: " + to_string(numberOfFrees)); + //PRINTDEBUGMESSAGE("MemoryManager","Number of allocated payloads: " + to_string(numberOfAllocations)); + //PRINTDEBUGMESSAGE("MemoryManager","Number of freed payloads: " + to_string(numberOfFrees)); } gp *MemoryManager::allocate() diff --git a/DRAMSys/library/src/simulation/TracePlayer.cpp b/DRAMSys/library/src/simulation/TracePlayer.cpp index 889124b3..ad727568 100644 --- a/DRAMSys/library/src/simulation/TracePlayer.cpp +++ b/DRAMSys/library/src/simulation/TracePlayer.cpp @@ -66,11 +66,6 @@ void TracePlayer::terminate() listener->tracePlayerTerminates(); } -void TracePlayer::printDebugMessage(std::string message) -{ - DebugManager::getInstance().printDebugMessage(this->name(), message); -} - tlm_sync_enum TracePlayer::nb_transport_bw(tlm_generic_payload &payload, tlm_phase &phase, sc_time &bwDelay) { @@ -86,8 +81,7 @@ void TracePlayer::peqCallback(tlm_generic_payload &payload, sendToTarget(payload, phase, SC_ZERO_TIME); transactionsSent++; - DebugManager::getInstance().printDebugMessage(name(), - "Performing request #" + std::to_string(transactionsSent)); + PRINTDEBUGMESSAGE(name(), "Performing request #" + std::to_string(transactionsSent)); } else if (phase == END_REQ) { nextPayload(); } else if (phase == BEGIN_RESP) { diff --git a/DRAMSys/library/src/simulation/TracePlayer.h b/DRAMSys/library/src/simulation/TracePlayer.h index a62ff00a..9adbcb51 100644 --- a/DRAMSys/library/src/simulation/TracePlayer.h +++ b/DRAMSys/library/src/simulation/TracePlayer.h @@ -69,7 +69,6 @@ protected: tlm_utils::peq_with_cb_and_phase payloadEventQueue; void finish(); void terminate(); - void printDebugMessage(std::string message); void setNumberOfTransactions(unsigned int n); unsigned int numberOfTransactions;