diff --git a/source/adios2/engine/bp/BPFileWriter.cpp b/source/adios2/engine/bp/BPFileWriter.cpp index b397681b336dc7a81790bd5b6b9758b2b3c3605c..ee8c74883e564ad8d7188ea821ff49d9450251a2 100644 --- a/source/adios2/engine/bp/BPFileWriter.cpp +++ b/source/adios2/engine/bp/BPFileWriter.cpp @@ -86,8 +86,22 @@ void BPFileWriter::Close(const int transportIndex) const std::string log(m_BP1Writer.GetRankProfilingLog( transportTypes, transportProfilers)); - // TODO profiling.log - // m_BP1Writer.m_BP1Aggregator.WriteProfilingLog( ) + // TODO profiling.log from rank0 + + const std::string profilingLog( + m_BP1Writer.AggregateProfilingLog(log)); + + if (m_BP1Writer.m_BP1Aggregator.m_RankMPI == 0) + { + transport::FileStream profilingLogStream(m_MPIComm, + m_DebugMode); + auto bpBaseNames = m_BP1Writer.GetBPBaseNames({m_Name}); + profilingLogStream.Open(bpBaseNames[0] + "/profiling.log", + OpenMode::Write); + profilingLogStream.Write(profilingLog.c_str(), + profilingLog.size()); + profilingLogStream.Close(); + } } } } @@ -123,6 +137,8 @@ void BPFileWriter::InitBPBuffer() { if (m_OpenMode == OpenMode::Append) { + throw std::invalid_argument( + "ADIOS2: OpenMode Append hasn't been implemented, yet"); // TODO: Get last pg timestep and update timestep counter in } else diff --git a/source/adios2/toolkit/format/bp1/BP1Aggregator.cpp b/source/adios2/toolkit/format/bp1/BP1Aggregator.cpp index 255e9ce234b0ff3a961d4db9071513d924717443..b5fd927015c93bef0af7361efbdc39ec107722d6 100644 --- a/source/adios2/toolkit/format/bp1/BP1Aggregator.cpp +++ b/source/adios2/toolkit/format/bp1/BP1Aggregator.cpp @@ -83,7 +83,7 @@ std::string BP1Aggregator::GetGlobalProfilingLog(const std::string &rankLog) profilingLog.reserve(rankLog.size() * m_SizeMPI); profilingLog += "{\n"; - profilingLog += rankLog + "\n"; + profilingLog += rankLog + ",\n"; for (unsigned int i = 1; i < sizeMPI; ++i) { const std::string rankLogStr(rankLogs[i - 1].data(), @@ -124,6 +124,8 @@ std::string BP1Aggregator::GetGlobalProfilingLog(const std::string &rankLog) 1, m_MPIComm, &requestRankLog); } + MPI_Barrier(m_MPIComm); // Barrier here? + return profilingLog; } diff --git a/source/adios2/toolkit/format/bp1/BP1Writer.cpp b/source/adios2/toolkit/format/bp1/BP1Writer.cpp index daaf29b8c04df085c56195d531544d4d7afb338a..2762b0208ff0782b37e35a337ca764cb4523879a 100644 --- a/source/adios2/toolkit/format/bp1/BP1Writer.cpp +++ b/source/adios2/toolkit/format/bp1/BP1Writer.cpp @@ -157,6 +157,9 @@ void BP1Writer::Close() noexcept } FlattenMetadata(); + + m_Profiler.Bytes.at("buffering") += m_HeapBuffer.m_DataAbsolutePosition; + m_IsClosed = true; } @@ -195,7 +198,6 @@ std::string BP1Writer::GetRankProfilingLog( for (const auto &transportTimerPair : transportsProfilers[t]->Timers) { lf_WriterTimer(rankLog, transportTimerPair.second); - rankLog += ", "; } // replace last comma with space rankLog.pop_back(); @@ -216,6 +218,12 @@ std::string BP1Writer::GetRankProfilingLog( return rankLog; } +std::string +BP1Writer::AggregateProfilingLog(const std::string &rankProfilingLog) noexcept +{ + return m_BP1Aggregator.GetGlobalProfilingLog(rankProfilingLog); +} + // PRIVATE FUNCTIONS void BP1Writer::WriteDimensionsRecord(const Dims localDimensions, const Dims globalDimensions, diff --git a/source/adios2/toolkit/format/bp1/BP1Writer.h b/source/adios2/toolkit/format/bp1/BP1Writer.h index d193753c1bc6c3e1ff8388a19ca8397a204073fe..4601215bf474c856e84cf6d995a78a9563e43bac 100644 --- a/source/adios2/toolkit/format/bp1/BP1Writer.h +++ b/source/adios2/toolkit/format/bp1/BP1Writer.h @@ -98,6 +98,9 @@ public: const std::vector<std::string> &transportsTypes, const std::vector<profiling::IOChrono *> &transportsProfilers) noexcept; + std::string + AggregateProfilingLog(const std::string &rankProfilingLog) noexcept; + private: /** BP format version */ const uint8_t m_Version = 3;