Write GeneralInfo table at the beginning

and do not include information in it that is only known at the end of
the simulation. These can trivially be calculated by the trace itself
and would be redundant information regardless.

The TraceAnalyzer gets the number of transactions and the length of
the trace by additional SQL queries.

This enables us to inspect traces of simulations that were aborted
without finishing cleanlywithout finishing cleanly.
This commit is contained in:
2023-08-09 11:55:10 +02:00
parent b292305efa
commit d392d0ab98
4 changed files with 46 additions and 34 deletions

View File

@@ -290,11 +290,6 @@ ID TraceDB::getTransactionIDFromPhaseID(ID phaseID)
GeneralInfo TraceDB::getGeneralInfoFromDB()
{
QVariant parameter;
parameter = getParameterFromTable("NumberOfTransactions", "GeneralInfo");
uint64_t numberOfTransactions = parameter.isValid() ? parameter.toULongLong() : 0;
parameter = getParameterFromTable("TraceEnd", "GeneralInfo");
traceTime traceEnd = parameter.isValid() ? static_cast<traceTime>(parameter.toULongLong()) : 0;
parameter = getParameterFromTable("NumberOfRanks", "GeneralInfo");
unsigned numberOfRanks = parameter.isValid() ? parameter.toUInt() : 1;
parameter = getParameterFromTable("NumberOfBankgroups", "GeneralInfo");
unsigned numberOfBankGroups = parameter.isValid() ? parameter.toUInt() : numberOfRanks;
@@ -328,6 +323,8 @@ GeneralInfo TraceDB::getGeneralInfoFromDB()
bool pseudoChannelMode = parameter.isValid() && parameter.toBool();
uint64_t numberOfPhases = getNumberOfPhases();
uint64_t numberOfTransactions = getNumberOfTransactions();
auto traceEnd = static_cast<traceTime>(getTraceLength());
QString description = (traces + "\n");
description += mcconfig + "\n";
@@ -417,6 +414,26 @@ QVariant TraceDB::getParameterFromTable(const std::string& parameter, const std:
}
}
uint64_t TraceDB::getTraceLength()
{
QSqlQuery query(database);
query.prepare("SELECT MAX(PhaseEnd) FROM Phases");
executeQuery(query);
query.next();
return query.value(0).toULongLong();
}
uint64_t TraceDB::getNumberOfTransactions()
{
QSqlQuery query(database);
query.prepare("SELECT COUNT(ID) FROM Transactions");
executeQuery(query);
query.next();
return query.value(0).toULongLong();
}
uint64_t TraceDB::getNumberOfPhases()
{
QSqlQuery query(database);
@@ -480,7 +497,7 @@ DependencyInfos TraceDB::getDependencyInfos(DependencyInfos::Type infoType)
selectTimeDependencyPercentages = QSqlQuery(database);
if (!selectTimeDependencyPercentages.prepare(queryTexts.selectTimeDependencyPercentages))
qDebug() << database.lastError().text();
executeQuery(selectTimeDependencyPercentages);
return parseDependencyInfos(selectTimeDependencyPercentages, infoType);
}
@@ -714,4 +731,3 @@ void TraceDB::executeScriptFile(const QString& fileName)
}
}
}

View File

@@ -145,6 +145,8 @@ private:
void executeScriptFile(const QString& fileName);
void dropAndCreateTables();
uint64_t getTraceLength();
uint64_t getNumberOfTransactions();
uint64_t getNumberOfPhases();
GeneralInfo getGeneralInfoFromDB();
CommandLengths getCommandLengthsFromDB();
@@ -174,6 +176,3 @@ public:
}
};
#endif // TRACEDB_H

View File

@@ -73,6 +73,9 @@ TlmRecorder::TlmRecorder(const std::string& name, const Configuration& config, c
executeInitialSqlCommand();
prepareSqlStatements();
insertGeneralInfo();
insertCommandLengths();
PRINTDEBUGMESSAGE(name, "Starting new database transaction");
}
@@ -352,7 +355,7 @@ void TlmRecorder::prepareSqlStatements()
insertGeneralInfoString =
"INSERT INTO GeneralInfo VALUES"
"(:numberOfTransactions, :end, :numberOfRanks, :numberOfBankGroups, :numberOfBanks, :clk, :unitOfTime, "
"(:numberOfRanks, :numberOfBankGroups, :numberOfBanks, :clk, :unitOfTime, "
":mcconfig, :memspec, :traces, :windowSize, :refreshMaxPostponed, :refreshMaxPulledin, :controllerThread, "
":maxBufferDepth, :per2BankOffset, :rowColumnCommandBus, :pseudoChannelMode)";
@@ -388,27 +391,25 @@ void TlmRecorder::insertDebugMessageInDB(const std::string &message, const sc_ti
void TlmRecorder::insertGeneralInfo()
{
sqlite3_bind_int64(insertGeneralInfoStatement, 1, static_cast<int64_t>(totalNumTransactions));
sqlite3_bind_int64(insertGeneralInfoStatement, 2, static_cast<int64_t>(simulationTimeCoveredByRecording.value()));
sqlite3_bind_int(insertGeneralInfoStatement, 3, static_cast<int>(config.memSpec->ranksPerChannel));
sqlite3_bind_int(insertGeneralInfoStatement, 4, static_cast<int>(config.memSpec->bankGroupsPerChannel));
sqlite3_bind_int(insertGeneralInfoStatement, 5, static_cast<int>(config.memSpec->banksPerChannel));
sqlite3_bind_int64(insertGeneralInfoStatement, 6, static_cast<int64_t>(config.memSpec->tCK.value()));
sqlite3_bind_text(insertGeneralInfoStatement, 7, "PS", 2, nullptr);
sqlite3_bind_int(insertGeneralInfoStatement, 1, static_cast<int>(config.memSpec->ranksPerChannel));
sqlite3_bind_int(insertGeneralInfoStatement, 2, static_cast<int>(config.memSpec->bankGroupsPerChannel));
sqlite3_bind_int(insertGeneralInfoStatement, 3, static_cast<int>(config.memSpec->banksPerChannel));
sqlite3_bind_int64(insertGeneralInfoStatement, 4, static_cast<int64_t>(config.memSpec->tCK.value()));
sqlite3_bind_text(insertGeneralInfoStatement, 5, "PS", 2, nullptr);
sqlite3_bind_text(insertGeneralInfoStatement, 8, mcconfig.c_str(), static_cast<int>(mcconfig.length()), nullptr);
sqlite3_bind_text(insertGeneralInfoStatement, 9, memspec.c_str(), static_cast<int>(memspec.length()), nullptr);
sqlite3_bind_text(insertGeneralInfoStatement, 10, traces.c_str(), static_cast<int>(traces.length()), nullptr);
sqlite3_bind_text(insertGeneralInfoStatement, 6, mcconfig.c_str(), static_cast<int>(mcconfig.length()), nullptr);
sqlite3_bind_text(insertGeneralInfoStatement, 7, memspec.c_str(), static_cast<int>(memspec.length()), nullptr);
sqlite3_bind_text(insertGeneralInfoStatement, 8, traces.c_str(), static_cast<int>(traces.length()), nullptr);
if (config.enableWindowing)
sqlite3_bind_int64(insertGeneralInfoStatement, 11, static_cast<int64_t>((config.memSpec->tCK
sqlite3_bind_int64(insertGeneralInfoStatement, 9, static_cast<int64_t>((config.memSpec->tCK
* config.windowSize).value()));
else
sqlite3_bind_int64(insertGeneralInfoStatement, 11, 0);
sqlite3_bind_int(insertGeneralInfoStatement, 12, static_cast<int>(config.refreshMaxPostponed));
sqlite3_bind_int(insertGeneralInfoStatement, 13, static_cast<int>(config.refreshMaxPulledin));
sqlite3_bind_int(insertGeneralInfoStatement, 14, static_cast<int>(UINT_MAX));
sqlite3_bind_int(insertGeneralInfoStatement, 15, static_cast<int>(config.requestBufferSize));
sqlite3_bind_int(insertGeneralInfoStatement, 16, static_cast<int>(config.memSpec->getPer2BankOffset()));
sqlite3_bind_int64(insertGeneralInfoStatement, 9, 0);
sqlite3_bind_int(insertGeneralInfoStatement, 10, static_cast<int>(config.refreshMaxPostponed));
sqlite3_bind_int(insertGeneralInfoStatement, 11, static_cast<int>(config.refreshMaxPulledin));
sqlite3_bind_int(insertGeneralInfoStatement, 12, static_cast<int>(UINT_MAX));
sqlite3_bind_int(insertGeneralInfoStatement, 13, static_cast<int>(config.requestBufferSize));
sqlite3_bind_int(insertGeneralInfoStatement, 14, static_cast<int>(config.memSpec->getPer2BankOffset()));
const MemSpec& memSpec = *config.memSpec;
const auto memoryType = memSpec.memoryType;
@@ -422,8 +423,8 @@ void TlmRecorder::insertGeneralInfo()
return memSpec.pseudoChannelsPerChannel != 1;
}();
sqlite3_bind_int(insertGeneralInfoStatement, 17, static_cast<int>(rowColumnCommandBus));
sqlite3_bind_int(insertGeneralInfoStatement, 18, static_cast<int>(pseudoChannelMode));
sqlite3_bind_int(insertGeneralInfoStatement, 15, static_cast<int>(rowColumnCommandBus));
sqlite3_bind_int(insertGeneralInfoStatement, 16, static_cast<int>(pseudoChannelMode));
executeSqlStatement(insertGeneralInfoStatement);
}
@@ -519,8 +520,6 @@ void TlmRecorder::closeConnection()
storageThread.join();
std::swap(currentDataBuffer, storageDataBuffer);
commitRecordedDataToDB();
insertGeneralInfo();
insertCommandLengths();
PRINTDEBUGMESSAGE(name, "Number of transactions written to DB: "
+ std::to_string(totalNumTransactions));
PRINTDEBUGMESSAGE(name, "tlmPhaseRecorder:\tEnd Recording");

View File

@@ -205,8 +205,6 @@ private:
"); \n"
" \n"
"CREATE TABLE GeneralInfo( \n"
" NumberOfTransactions INTEGER, \n"
" TraceEnd INTEGER, \n"
" NumberOfRanks INTEGER, \n"
" NumberOfBankgroups INTEGER, \n"
" NumberOfBanks INTEGER, \n"