14#include "arcane/std/JsonMessagePassingProfilingService.h"
20#include "arcane/core/CommonVariables.h"
21#include "arcane/core/ITimeLoopMng.h"
22#include "arcane/core/IParallelMng.h"
23#include "arcane/core/IEntryPoint.h"
25#include "arcane/parallel/IStat.h"
26#include "arcane/utils/JSONWriter.h"
44JsonMessagePassingProfilingService::
47, m_sub_domain(sbi.subDomain())
48, m_json_writer(nullptr)
49, m_impl_name(
"JsonMessagePassingProfiling")
56JsonMessagePassingProfilingService::
57~JsonMessagePassingProfilingService()
66void JsonMessagePassingProfilingService::
71 m_json_writer =
new JSONWriter(JSONWriter::FormatFlags::None);
72 m_json_writer->beginObject();
76 m_observer.addObserver(
this, &JsonMessagePassingProfilingService::_updateFromBeginEntryPointEvt,
77 m_sub_domain->timeLoopMng()->observable(eTimeLoopEventType::BeginEntryPoint));
78 m_observer.addObserver(
this, &JsonMessagePassingProfilingService::_updateFromEndEntryPointEvt,
79 m_sub_domain->timeLoopMng()->observable(eTimeLoopEventType::EndEntryPoint));
80 m_observer.addObserver(
this, &JsonMessagePassingProfilingService::_updateFromBeginIterationEvt,
81 m_sub_domain->timeLoopMng()->observable(eTimeLoopEventType::BeginIteration));
82 m_observer.addObserver(
this, &JsonMessagePassingProfilingService::_updateFromEndIterationEvt,
83 m_sub_domain->timeLoopMng()->observable(eTimeLoopEventType::EndIteration));
89void JsonMessagePassingProfilingService::
93 m_observer.detachAll();
96 _dumpCurrentIterationInJSON();
97 m_json_writer->endObject();
103void JsonMessagePassingProfilingService::
104printInfos(std::ostream& output)
106 output << m_json_writer->getBuffer();
111String JsonMessagePassingProfilingService::
120void JsonMessagePassingProfilingService::
121_dumpCurrentIterationInJSON()
123 if (m_ep_mpstat_col.empty())
128 String::fromNumber(m_sub_domain->commonVariables().globalIteration() - 1));
130 for (
const auto& ep_mpstat : m_ep_mpstat_col) {
132 const auto& stats_(ep_mpstat.second.stats());
138 for (
const auto& mpstat : stats_) {
140 if (mpstat.nbMessage())
150void JsonMessagePassingProfilingService::
151_updateFromBeginEntryPointEvt()
154 m_sub_domain->parallelMng()->stat()->toArccoreStat()->resetCurrentStat();
160void JsonMessagePassingProfilingService::
161_updateFromEndEntryPointEvt()
164 const String& ep_name(m_sub_domain->timeLoopMng()->currentEntryPoint()->name());
165 auto pos(m_ep_mpstat_col.find(ep_name));
168 if (pos == m_ep_mpstat_col.end())
169 m_ep_mpstat_col.emplace(ep_name, stat_data);
171 pos->second.mergeAllData(stat_data);
177void JsonMessagePassingProfilingService::
178_updateFromBeginIterationEvt()
181 m_ep_mpstat_col.clear();
187void JsonMessagePassingProfilingService::
188_updateFromEndIterationEvt()
192 _dumpCurrentIterationInJSON();
This file contains the various service factories and macros for registering services.
#define ARCANE_SERVICE_INTERFACE(ainterface)
Macro to declare an interface when registering a service.
Interface of a profiling service dedicated to "message passing".
JSON message passing profiling service.
Statistical data set for profiling.
Structure containing the information to create a service.
Service creation properties.
Unicode character string.
#define ARCANE_REGISTER_SERVICE(aclass, a_service_property,...)
Macro for registering a service.
void dumpJSON(JSONWriter &writer, const Arccore::MessagePassing::OneStat &os, bool cumulative_stat=true)
Free function for dumping a message stat into JSON.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
@ ST_SubDomain
The service is used at the subdomain level.