Changed printDebugMessage into macro to turn it off completely for speedup.

This commit is contained in:
Lukas Steiner (2)
2019-08-08 09:45:22 +02:00
parent c93a11fbf5
commit ca36faa403
18 changed files with 39 additions and 81 deletions

View File

@@ -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 <systemc.h>
#include <string>
#include <set>

View File

@@ -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;
}

View File

@@ -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<Transaction> recordedData;
map<tlm::tlm_generic_payload *, Transaction> currentTransactionsInSystem;

View File

@@ -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;
}

View File

@@ -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<std::pair<sc_time, tlm_generic_payload *>> responseQueue;
DebugManager *debugManager;
std::map<Bank, BankMachine *> bankMachines;
CmdMuxIF *commandMux;
SchedulerIF *scheduler;

View File

@@ -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());

View File

@@ -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));

View File

@@ -55,11 +55,6 @@ protected:
std::map<Command, ScheduledCommand> 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;
};

View File

@@ -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

View File

@@ -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);
}

View File

@@ -99,8 +99,6 @@ private:
std::vector<uint64_t> nextPayloadID;
bool addressIsValid(DecodedAddress &decodedAddress);
void printDebugMessage(std::string message);
};
#endif // ARBITER_H

View File

@@ -360,6 +360,6 @@ DRAMSys::~DRAMSys()
void DRAMSys::report(string message)
{
DebugManager::getInstance().printDebugMessage(this->name(), message);
PRINTDEBUGMESSAGE(name(), message);
cout << message << endl;
}

View File

@@ -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);
}

View File

@@ -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<Dram> tSocket;

View File

@@ -85,8 +85,7 @@ tlm_sync_enum DramRecordable<BaseDram>::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<BaseDram>::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]"));

View File

@@ -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()

View File

@@ -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) {

View File

@@ -69,7 +69,6 @@ protected:
tlm_utils::peq_with_cb_and_phase<TracePlayer> payloadEventQueue;
void finish();
void terminate();
void printDebugMessage(std::string message);
void setNumberOfTransactions(unsigned int n);
unsigned int numberOfTransactions;