Skip to content
Snippets Groups Projects
Commit 1eafa415 authored by William F Godoy's avatar William F Godoy
Browse files

Fixing aggregation formatting in .bp/profiling.log

Now meets the python dictionary format
parent 06e9ddc5
No related branches found
No related tags found
1 merge request!50Fixing aggregation formatting in .bp/profiling.log
......@@ -43,8 +43,10 @@ void BP1Aggregator::WriteProfilingLog(const std::string fileName,
// first receive sizes
for (unsigned int i = 1; i < sizeMPI; ++i)
{
MPI_Irecv(&rankLogsSizes[i - 1], 1, MPI_INT, i, 0, m_MPIComm,
&requests[i]);
}
for (unsigned int i = 1; i < sizeMPI; ++i)
{
......@@ -62,23 +64,37 @@ void BP1Aggregator::WriteProfilingLog(const std::string fileName,
// receive rankLog from other ranks
for (unsigned int i = 1; i < sizeMPI; ++i)
{
MPI_Irecv(rankLogs[i - 1].data(), rankLogsSizes[i - 1], MPI_CHAR, i,
1, m_MPIComm, &requests[i]);
}
for (unsigned int i = 1; i < sizeMPI; ++i)
{
MPI_Wait(&requests[i], &statuses[i]);
}
// write file
std::string logFile("log = { \n");
std::string logFile("{\n");
logFile += rankLog + "\n";
for (unsigned int i = 1; i < sizeMPI; ++i)
{
const std::string rankLogStr(rankLogs[i - 1].data(),
rankLogs[i - 1].size());
logFile += rankLogStr + "\n";
if (i == sizeMPI - 1) // last one, eliminate trailing comma
{
const std::string rankLogStr(rankLogs[i - 1].data(),
rankLogs[i - 1].size() - 1);
logFile += rankLogStr + "\n";
}
else
{
const std::string rankLogStr(rankLogs[i - 1].data(),
rankLogs[i - 1].size());
logFile += rankLogStr + "\n";
}
}
logFile += " }\n";
logFile += "}\n";
// write to file
std::ofstream logStream(fileName);
logStream.write(logFile.c_str(), logFile.size());
logStream.close();
......
......@@ -161,7 +161,7 @@ std::string BP1Writer::GetRankProfilingLog(
auto lf_WriterTimer = [](std::string &rankLog,
const profiling::Timer &timer) {
rankLog += "'" + timer.m_Process + "_" + timer.GetUnits() + "': " +
std::to_string(timer.m_ProcessTime) + ", ";
std::to_string(timer.m_ProcessTime);
};
// prepare string dictionary per rank
......@@ -170,20 +170,36 @@ std::string BP1Writer::GetRankProfilingLog(
auto &profiler = metadataSet.Log;
rankLog += "'bytes': " + std::to_string(profiler.TotalBytes[0]) + ", ";
lf_WriterTimer(rankLog, profiler.Timers[0]);
rankLog += ", ";
for (unsigned int t = 0; t < transports.size(); ++t)
{
auto &timers = transports[t]->m_Profiler.Timers;
rankLog += "'transport_" + std::to_string(t) + "': { ";
rankLog += "'lib': " + transports[t]->m_Type + ", ";
rankLog += "'lib': '" + transports[t]->m_Type + "', ";
for (unsigned int i = 0; i < 3; ++i)
lf_WriterTimer(rankLog, timers[i]);
{
lf_WriterTimer(rankLog, transports[t]->m_Profiler.Timers[i]);
if (i < 2)
{
rankLog += ", ";
}
else
{
rankLog += " ";
}
}
rankLog += "}, ";
if (t == transports.size() - 1) // last element
{
rankLog += "}";
}
else
{
rankLog += "},";
}
}
rankLog += "}, ";
rankLog += " },";
return rankLog;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment