Commit 351b04c4 authored by Podhorszki, Norbert's avatar Podhorszki, Norbert
Browse files

Added adios2_json_pp pretty print python script, fixed profiling prints to be...

Added adios2_json_pp pretty print python script, fixed profiling prints to be proper json, added WaitOnAsync timer, and print async wait time only in verbose mode
parent 6f5741a6
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -77,6 +77,7 @@ StepStatus BP5Writer::BeginStep(StepMode mode, const float timeoutSeconds)
        TimePoint wait_start = Now();
        if (m_WriteFuture.valid())
        {
            m_Profiler.Start("WaitOnAsync");
            m_WriteFuture.get();
            m_Comm.Barrier();
            AsyncWriteDataCleanup();
@@ -85,13 +86,18 @@ StepStatus BP5Writer::BeginStep(StepMode mode, const float timeoutSeconds)
            {
                WriteMetadataFileIndex(m_LatestMetaDataPos,
                                       m_LatestMetaDataSize);
                if (m_Parameters.verbose > 0)
                {
                    std::cout << "BeginStep, wait on async write was = "
                              << wait.count() << " time since EndStep was = "
                              << m_LastTimeBetweenSteps.count()
                              << " expect next one to be = "
                          << m_ExpectedTimeBetweenSteps.count() << std::endl;
                              << m_ExpectedTimeBetweenSteps.count()
                              << std::endl;
                }
            }
            m_Profiler.Stop("WaitOnAsync");
        }
    }

    if (m_Parameters.BufferVType == (int)BufferVType::MallocVType)
@@ -1452,11 +1458,13 @@ void BP5Writer::DoClose(const int transportIndex)
    Seconds wait(0.0);
    if (m_WriteFuture.valid())
    {
        m_Profiler.Start("WaitOnAsync");
        m_AsyncWriteLock.lock();
        m_flagRush = true;
        m_AsyncWriteLock.unlock();
        m_WriteFuture.get();
        wait += Now() - wait_start;
        m_Profiler.Stop("WaitOnAsync");
    }

    m_FileDataManager.CloseFiles(transportIndex);
@@ -1474,15 +1482,17 @@ void BP5Writer::DoClose(const int transportIndex)
    if (m_Parameters.AsyncWrite)
    {
        // wait until all process' writing thread completes
        m_Profiler.Start("WaitOnAsync");
        wait_start = Now();
        m_Comm.Barrier();
        AsyncWriteDataCleanup();
        wait += Now() - wait_start;
        if (m_Comm.Rank() == 0)
        if (m_Comm.Rank() == 0 && m_Parameters.verbose > 0)
        {
            std::cout << "Close waited " << wait.count()
                      << " seconds on async threads" << std::endl;
        }
        m_Profiler.Stop("WaitOnAsync");
    }

    if (m_Comm.Rank() == 0)
+11 −23
Original line number Diff line number Diff line
@@ -47,12 +47,12 @@ std::string BPSerializer::GetRankProfilingJSON(
{
    auto lf_WriterTimer = [](std::string &rankLog,
                             const profiling::Timer &timer) {
        rankLog += "\"" + timer.m_Process + "_" + timer.GetShortUnits() +
                   "\": " + std::to_string(timer.m_ProcessTime) + ", ";
        rankLog += ", \"" + timer.m_Process + "_" + timer.GetShortUnits() +
                   "\": " + std::to_string(timer.m_ProcessTime);
    };

    // prepare string dictionary per rank
    std::string rankLog("{ \"rank\": " + std::to_string(m_RankMPI) + ", ");
    std::string rankLog("{ \"rank\": " + std::to_string(m_RankMPI));

    auto &profiler = m_Profiler;

@@ -61,43 +61,31 @@ std::string BPSerializer::GetRankProfilingJSON(
    // avoid whitespace
    std::replace(timeDate.begin(), timeDate.end(), ' ', '_');

    rankLog += "\"start\": \"" + timeDate + "\", ";
    rankLog += "\"threads\": " + std::to_string(m_Parameters.Threads) + ", ";
    rankLog += ", \"start\": \"" + timeDate + "\"";
    rankLog += ", \"threads\": " + std::to_string(m_Parameters.Threads);
    rankLog +=
        "\"bytes\": " + std::to_string(profiler.m_Bytes.at("buffering")) + ", ";
        ", \"bytes\": " + std::to_string(profiler.m_Bytes.at("buffering"));

    for (const auto &timerPair : profiler.m_Timers)
    {
        const profiling::Timer &timer = timerPair.second;
        rankLog += "\"" + timer.m_Process + "_" + timer.GetShortUnits() +
                   "\": " + std::to_string(timer.m_ProcessTime) + ", ";
        rankLog += ", \"" + timer.m_Process + "_" + timer.GetShortUnits() +
                   "\": " + std::to_string(timer.m_ProcessTime);
    }

    const size_t transportsSize = transportsTypes.size();

    for (unsigned int t = 0; t < transportsSize; ++t)
    {
        rankLog += "\"transport_" + std::to_string(t) + "\": { ";
        rankLog += "\"type\": \"" + transportsTypes[t] + "\", ";
        rankLog += ", \"transport_" + std::to_string(t) + "\": { ";
        rankLog += "\"type\": \"" + transportsTypes[t] + "\"";

        for (const auto &transportTimerPair : transportsProfilers[t]->m_Timers)
        {
            lf_WriterTimer(rankLog, transportTimerPair.second);
        }
        // replace last comma with space
        rankLog.pop_back();
        rankLog.pop_back();
        rankLog += " ";

        if (t == transportsSize - 1) // last element
        {
        rankLog += "}";
    }
        else
        {
            rankLog += "},";
        }
    }
    rankLog += " }"; // end rank entry

    return rankLog;
+8 −25
Original line number Diff line number Diff line
@@ -40,16 +40,11 @@ JSONProfiler::JSONProfiler(helper::Comm const &comm) : m_Comm(comm)
    m_Profiler.m_IsActive = true; // default is true

    AddTimerWatch("buffering");
    // xAddTimerWatch("memcpy");
    AddTimerWatch("endstep");
    AddTimerWatch("PP");
    // AddTimerWatch("meta_merge");
    AddTimerWatch("meta_gather");
    // AddTimerWatch("meta_ds");
    // AddTimerWatch("meta_s");
    // AddTimerWatch("meta_sort_merge");

    AddTimerWatch("AWD");
    AddTimerWatch("WaitOnAsync");

    m_Profiler.m_Bytes.emplace("buffering", 0);

@@ -74,7 +69,7 @@ std::string JSONProfiler::GetRankProfilingJSON(
    };

    // prepare string dictionary per rank
    std::string rankLog("{ \"rank\": " + std::to_string(m_RankMPI) + ", ");
    std::string rankLog("{ \"rank\":" + std::to_string(m_RankMPI));

    auto &profiler = m_Profiler;

@@ -83,10 +78,10 @@ std::string JSONProfiler::GetRankProfilingJSON(
    // avoid whitespace
    std::replace(timeDate.begin(), timeDate.end(), ' ', '_');

    rankLog += "\"start\": \"" + timeDate + "\", ";
    // rankLog += "\"threads\": " + std::to_string(m_Parameters.Threads) + ", ";
    rankLog += ", \"start\":\"" + timeDate + "\"";
    // rankLog += ", \"threads\":" + std::to_string(m_Parameters.Threads);
    rankLog +=
        "\"bytes\": " + std::to_string(profiler.m_Bytes.at("buffering")) + ", ";
        ", \"bytes\":" + std::to_string(profiler.m_Bytes.at("buffering"));

    for (const auto &timerPair : profiler.m_Timers)
    {
@@ -100,27 +95,15 @@ std::string JSONProfiler::GetRankProfilingJSON(

    for (unsigned int t = 0; t < transportsSize; ++t)
    {
        rankLog += "\"transport_" + std::to_string(t) + "\": { ";
        rankLog += "\"type\": \"" + transportsTypes[t] + "\", ";
        rankLog += ", \"transport_" + std::to_string(t) + "\":{";
        rankLog += "\"type\":\"" + transportsTypes[t] + "\"";

        for (const auto &transportTimerPair : transportsProfilers[t]->m_Timers)
        {
            lf_WriterTimer(rankLog, transportTimerPair.second);
        }
        // replace last comma with space
        rankLog.pop_back();
        rankLog.pop_back();
        rankLog += " ";

        if (t == transportsSize - 1) // last element
        {
        rankLog += "}";
    }
        else
        {
            rankLog += "},";
        }
    }
    rankLog += " }"; // end rank entry

    return rankLog;
+7 −3
Original line number Diff line number Diff line
@@ -90,11 +90,15 @@ public:
        }
    }

    void AddToJsonStr(std::string &rankLog) const
    void AddToJsonStr(std::string &rankLog, const bool addComma = true) const
    {
        if (0 == m_nCalls)
            return;

        if (addComma)
        {
            rankLog += ", ";
        }
        rankLog +=
            "\"" + m_Process + "\":{\"mus\":" + std::to_string(m_ProcessTime);
        rankLog += ", \"nCalls\":" + std::to_string(m_nCalls);
@@ -106,7 +110,7 @@ public:
                rankLog += ", \"trace\":[" + m_Details + "]";
            }
        }
        rankLog += "}, ";
        rankLog += "}";
    }

    std::string m_Details;
+4 −0
Original line number Diff line number Diff line
@@ -72,6 +72,10 @@ endif()
if(Python_Interpreter_FOUND)
  add_subdirectory(bp4dbg)
  add_subdirectory(bp5dbg)
  install(PROGRAMS adios2_json_pp.py
    RENAME adios2_json_pp
    DESTINATION ${CMAKE_INSTALL_BINDIR}
    COMPONENT adios2_scripts-runtime)
endif()

install(PROGRAMS adios2_deactivate_bp
Loading