diff --git a/DRAMSys/library/src/common/DebugManager.cpp b/DRAMSys/library/src/common/DebugManager.cpp index e58ec8f5..034e3747 100644 --- a/DRAMSys/library/src/common/DebugManager.cpp +++ b/DRAMSys/library/src/common/DebugManager.cpp @@ -35,6 +35,9 @@ */ #include "DebugManager.h" + +#ifdef DEBUGGING + #include "../controller/core/configuration/Configuration.h" using namespace std; @@ -76,3 +79,4 @@ DebugManager::~DebugManager() debugFile.close(); } } +#endif diff --git a/DRAMSys/library/src/common/DebugManager.h b/DRAMSys/library/src/common/DebugManager.h index 86306a46..ca3b1fec 100644 --- a/DRAMSys/library/src/common/DebugManager.h +++ b/DRAMSys/library/src/common/DebugManager.h @@ -39,11 +39,10 @@ //#define DEBUGGING -#ifdef DEBUGGING -#define PRINTDEBUGMESSAGE(sender, message) DebugManager::getInstance().printDebugMessage(sender, message) -#else +#ifndef DEBUGGING #define PRINTDEBUGMESSAGE(sender, message) {} -#endif +#else +#define PRINTDEBUGMESSAGE(sender, message) DebugManager::getInstance().printDebugMessage(sender, message) #include #include @@ -70,5 +69,6 @@ private: ofstream debugFile; }; +#endif #endif // DEBUGMANAGER_H diff --git a/DRAMSys/library/src/controller/core/configuration/TemperatureSimConfig.h b/DRAMSys/library/src/controller/core/configuration/TemperatureSimConfig.h index b9acd733..11c0e32d 100644 --- a/DRAMSys/library/src/controller/core/configuration/TemperatureSimConfig.h +++ b/DRAMSys/library/src/controller/core/configuration/TemperatureSimConfig.h @@ -76,7 +76,7 @@ struct TemperatureSimConfig void parsePowerInfoFile() { - printDebugMessage("Power Info File: " + powerInfoFile); + PRINTDEBUGMESSAGE("TemperatureSimConfig", "Power Info File: " + powerInfoFile) powerInfoFile = pathToResources + "/configs/thermalsim/" @@ -90,7 +90,7 @@ struct TemperatureSimConfig if (powInfoElem == NULL) { // Invalid file std::string errormsg = "Invalid Power Info File " + powerInfoFile; - printDebugMessage(errormsg); + PRINTDEBUGMESSAGE("TemperatureSimConfig", errormsg); SC_REPORT_FATAL("Temperature Sim Config", errormsg.c_str()); } @@ -115,21 +115,15 @@ struct TemperatureSimConfig { int i = 0; for (auto e : powerInitialValues) { - printDebugMessage("powerInitialValues[" + std::to_string( - i++) + "]: " + std::to_string(e)); + PRINTDEBUGMESSAGE("TemperatureSimConfig", "powerInitialValues[" + + std::to_string(i++) + "]: " + std::to_string(e)); } i = 0; for (auto e : powerThresholds) { - printDebugMessage("powerThreshold[" + std::to_string(i++) + "]: " + - std::to_string(e)); + PRINTDEBUGMESSAGE("TemperatureSimConfig", "powerThreshold[" + + std::to_string(i++) + "]: " + std::to_string(e)); } } - - void printDebugMessage(std::string message) - { - DebugManager::getInstance().printDebugMessage("Temperature Sim Config", - message); - } }; #endif // TEMPERATURESIMCONFIG_H diff --git a/DRAMSys/library/src/error/errormodel.cpp b/DRAMSys/library/src/error/errormodel.cpp index e2329750..cb73ee11 100644 --- a/DRAMSys/library/src/error/errormodel.cpp +++ b/DRAMSys/library/src/error/errormodel.cpp @@ -165,12 +165,12 @@ void errorModel::store(tlm::tlm_generic_payload &trans) msg << "bank: " << key.bank << " group: " << key.bankgroup << " bytes: " << key.bytes << " channel: " << key.channel << " column: " << key.column << " rank: " << key.rank << " row: " << key.row; - printDebugMessage(msg.str()); + PRINTDEBUGMESSAGE(name(), msg.str()); // Check if the provided data length is correct: assert((bytesPerColumn * burstLenght) == trans.get_data_length()); - printDebugMessage(("Data length: " + std::to_string(trans.get_data_length()) + + PRINTDEBUGMESSAGE(name(), ("Data length: " + std::to_string(trans.get_data_length()) + " bytesPerColumn: " + std::to_string(bytesPerColumn)).c_str()); // Handle the DRAM burst, @@ -211,7 +211,7 @@ void errorModel::store(tlm::tlm_generic_payload &trans) std::stringstream msg; msg << "key.column is " << key.column << " numberOfColumns is " << numberOfColumns; - printDebugMessage(msg.str()); + PRINTDEBUGMESSAGE(name(), msg.str()); assert(key.column <= numberOfColumns); } } @@ -269,7 +269,7 @@ void errorModel::markBitFlips() if (weakCells[i].flipped == false && weakCells[i].row == row) { std::stringstream msg; msg << "Maked weakCell[" << i << "] as flipped" << std::endl; - printDebugMessage(msg.str()); + PRINTDEBUGMESSAGE(name(), msg.str()); weakCells[i].flipped = true; } @@ -334,7 +334,7 @@ void errorModel::activate(unsigned int row) << " row: " << key.row << " col: " << key.column << " bit: " << weakCells[i].bit; - printDebugMessage(msg.str()); + PRINTDEBUGMESSAGE(name(), msg.str()); numberOfBitErrorEvents++; @@ -387,7 +387,7 @@ void errorModel::activate(unsigned int row) << grid[0] << grid[1] << grid[2] << std::endl << grid[3] << grid[4] << grid[5] << std::endl << grid[6] << grid[7] << grid[8]; - printDebugMessage(msg.str()); + PRINTDEBUGMESSAGE(name(), msg.str()); } else { // Output on the Console: std::stringstream msg; @@ -399,7 +399,7 @@ void errorModel::activate(unsigned int row) << grid[0] << grid[1] << grid[2] << std::endl << grid[3] << grid[4] << grid[5] << std::endl << grid[6] << grid[7] << grid[8]; - printDebugMessage(msg.str()); + PRINTDEBUGMESSAGE(name(), msg.str()); } } } @@ -431,7 +431,7 @@ unsigned int errorModel::getBit(DecodedAddress key, unsigned int byteInColumn, << " tempByte = " << (unsigned int)tempByte << " result = " << result; - printDebugMessage(msg.str()); + PRINTDEBUGMESSAGE(name(), msg.str()); return result; } @@ -569,7 +569,7 @@ void errorModel::parseInputData() << " independent = " << errorMap[temp][retentionTime].independent << " dependent = " << errorMap[temp][retentionTime].dependent; - printDebugMessage(msg.str()); + PRINTDEBUGMESSAGE(name(), msg.str()); } inputFile.close(); } else { @@ -670,7 +670,7 @@ void errorModel::prepareWeakCells() << " bit=" << weakCells[i].bit << " flip=" << weakCells[i].flipped << " dep=" << weakCells[i].dependent; - printDebugMessage(msg.str()); + PRINTDEBUGMESSAGE(name(), msg.str()); } } @@ -735,10 +735,3 @@ void errorModel::setContext(DecodedAddress addr) myBank) + " "; } } - -void errorModel::printDebugMessage(std::string message) -{ - std::stringstream msg; - msg << contextStr << message; - DebugManager::getInstance().printDebugMessage(this->name(), msg.str()); -} diff --git a/DRAMSys/library/src/error/errormodel.h b/DRAMSys/library/src/error/errormodel.h index 1f4e3b71..7dab8f3f 100644 --- a/DRAMSys/library/src/error/errormodel.h +++ b/DRAMSys/library/src/error/errormodel.h @@ -72,8 +72,6 @@ private: // context: std::string contextStr; - void printDebugMessage(std::string message); - // Online Parameters: unsigned int numberOfBitErrorEvents; diff --git a/DRAMSys/library/src/simulation/DRAMSys.cpp b/DRAMSys/library/src/simulation/DRAMSys.cpp index ebaac161..596f0d74 100644 --- a/DRAMSys/library/src/simulation/DRAMSys.cpp +++ b/DRAMSys/library/src/simulation/DRAMSys.cpp @@ -179,11 +179,13 @@ void DRAMSys::logo() void DRAMSys::setupDebugManager(const string &traceName) { +#ifdef DEBUGGING auto &dbg = DebugManager::getInstance(); dbg.writeToConsole = false; dbg.writeToFile = true; if (dbg.writeToFile) dbg.openDebugFile(traceName + ".txt"); +#endif } void DRAMSys::setupTlmRecorders(const string &traceName, diff --git a/DRAMSys/library/src/simulation/IArbiter.h b/DRAMSys/library/src/simulation/IArbiter.h index a9c5ebd4..8826610f 100644 --- a/DRAMSys/library/src/simulation/IArbiter.h +++ b/DRAMSys/library/src/simulation/IArbiter.h @@ -89,11 +89,6 @@ protected: virtual unsigned int transport_dbg(int /*id*/, tlm::tlm_generic_payload &trans) = 0; - void printDebugMessage(std::string message) - { - DebugManager::getInstance().printDebugMessage(this->name(), message); - } - void appendDramExtension(int socketId, tlm_generic_payload &payload) { // Append Generation Extension diff --git a/DRAMSys/library/src/simulation/TemperatureController.cpp b/DRAMSys/library/src/simulation/TemperatureController.cpp index 2e183a77..09489377 100644 --- a/DRAMSys/library/src/simulation/TemperatureController.cpp +++ b/DRAMSys/library/src/simulation/TemperatureController.cpp @@ -52,7 +52,7 @@ double TemperatureController::temperatureConvert(double tKelvin) double TemperatureController::getTemperature(int deviceId, float currentPower) { - printDebugMessage("Temperature requested by device " + std::to_string( + PRINTDEBUGMESSAGE(name(), "Temperature requested by device " + std::to_string( deviceId) + " current power is " + std::to_string(currentPower)); if (dynamicTempSimEnabled == true) { @@ -66,7 +66,7 @@ double TemperatureController::getTemperature(int deviceId, float currentPower) return temperatureConvert(temperatureValues.at(deviceId)); } else { - printDebugMessage("Temperature is " + std::to_string(staticTemperature)); + PRINTDEBUGMESSAGE(name(), "Temperature is " + std::to_string(staticTemperature)); return staticTemperature; } } @@ -139,7 +139,7 @@ double TemperatureController::adjustThermalSimPeriod() period = period / periodAdjustFactor; cyclesSinceLastPeriodAdjust = 0; decreaseSimPeriod = false; - printDebugMessage("Thermal Simulation period reduced to " + std::to_string( + PRINTDEBUGMESSAGE(name(), "Thermal Simulation period reduced to " + std::to_string( period) + ". Target is " + std::to_string(targetPeriod)); } else { if (period != targetPeriod) { @@ -149,8 +149,8 @@ double TemperatureController::adjustThermalSimPeriod() period = period * (periodAdjustFactor / 2); if (period > targetPeriod) period = targetPeriod; - printDebugMessage("Thermal Simulation period increased to " + std::to_string( - period) + ". Target is " + std::to_string(targetPeriod)); + PRINTDEBUGMESSAGE(name(), "Thermal Simulation period increased to " + + std::to_string(period) + ". Target is " + std::to_string(targetPeriod)); } } } @@ -166,17 +166,11 @@ void TemperatureController::temperatureThread() int i = 0; for (auto t : temperatureValues) { - printDebugMessage("Temperature[" + std::to_string(i++) + "] is " + - std::to_string(t)); + PRINTDEBUGMESSAGE(name(), "Temperature[" + std::to_string(i++) + + "] is " + std::to_string(t)); } - printDebugMessage("Thermal simulation period is " + std::to_string(p)); + PRINTDEBUGMESSAGE(name(), "Thermal simulation period is " + std::to_string(p)); wait(sc_time(p, t_unit)); } } - -void TemperatureController::printDebugMessage(std::string message) -{ - DebugManager::getInstance().printDebugMessage(name(), message); -} - diff --git a/DRAMSys/library/src/simulation/TemperatureController.h b/DRAMSys/library/src/simulation/TemperatureController.h index 8d91d56a..fa16c1f0 100644 --- a/DRAMSys/library/src/simulation/TemperatureController.h +++ b/DRAMSys/library/src/simulation/TemperatureController.h @@ -72,8 +72,8 @@ public: std::string ip = Configuration::getInstance().temperatureSim.IceServerIp; unsigned int port = Configuration::getInstance().temperatureSim.IceServerPort; thermalSimulation = new IceWrapper(ip, port); - printDebugMessage("Dynamic temperature simulation. Server @ " + ip + ":" + - std::to_string(port)); + PRINTDEBUGMESSAGE(name(), "Dynamic temperature simulation. Server @ " + + ip + ":" + std::to_string(port)); #else SC_REPORT_FATAL(name(), "DRAMSys was build without support to dynamic temperature simulation. Check the README file for further details."); @@ -107,7 +107,7 @@ public: SC_THREAD(temperatureThread); } else { - printDebugMessage("Static temperature simulation. Temperature set to " + + PRINTDEBUGMESSAGE(name(), "Static temperature simulation. Temperature set to " + std::to_string(staticTemperature)); } } @@ -148,8 +148,6 @@ private: std::string temperatureMapFile; bool genPowerMap; std::string powerMapFile; - - void printDebugMessage(std::string message); }; #endif // TEMPERATURECONTROLLER_H