14#include "arcane/std/JsonMessagePassingProfilingService.h"
17#include "arcane/ServiceFactory.h"
18#include "arcane/CommonVariables.h"
19#include "arcane/ITimeLoopMng.h"
20#include "arcane/IParallelMng.h"
21#include "arcane/IEntryPoint.h"
22#include "arcane/parallel/IStat.h"
23#include "arcane/utils/JSONWriter.h"
35 ServiceProperty(
"JsonMessagePassingProfiling",
ST_SubDomain),
41JsonMessagePassingProfilingService::
42JsonMessagePassingProfilingService(
const ServiceBuildInfo& sbi)
44, m_sub_domain(sbi.subDomain())
45, m_json_writer(nullptr)
46, m_impl_name(
"JsonMessagePassingProfiling")
53JsonMessagePassingProfilingService::
54~JsonMessagePassingProfilingService()
63void JsonMessagePassingProfilingService::
68 m_json_writer =
new JSONWriter(JSONWriter::FormatFlags::None);
69 m_json_writer->beginObject();
73 m_observer.addObserver(
this, &JsonMessagePassingProfilingService::_updateFromBeginEntryPointEvt,
74 m_sub_domain->timeLoopMng()->observable(eTimeLoopEventType::BeginEntryPoint));
75 m_observer.addObserver(
this, &JsonMessagePassingProfilingService::_updateFromEndEntryPointEvt,
76 m_sub_domain->timeLoopMng()->observable(eTimeLoopEventType::EndEntryPoint));
77 m_observer.addObserver(
this, &JsonMessagePassingProfilingService::_updateFromBeginIterationEvt,
78 m_sub_domain->timeLoopMng()->observable(eTimeLoopEventType::BeginIteration));
79 m_observer.addObserver(
this, &JsonMessagePassingProfilingService::_updateFromEndIterationEvt,
80 m_sub_domain->timeLoopMng()->observable(eTimeLoopEventType::EndIteration));
86void JsonMessagePassingProfilingService::
90 m_observer.detachAll();
93 _dumpCurrentIterationInJSON();
94 m_json_writer->endObject();
100void JsonMessagePassingProfilingService::
101printInfos(std::ostream& output)
103 output << m_json_writer->getBuffer();
108String JsonMessagePassingProfilingService::
117void JsonMessagePassingProfilingService::
118_dumpCurrentIterationInJSON()
120 if (m_ep_mpstat_col.empty())
125 String::fromNumber(m_sub_domain->commonVariables().globalIteration() - 1));
127 for (
const auto &
ep_mpstat : m_ep_mpstat_col) {
132 {return static_cast<bool>(os.nbMessage());})) {
139 Parallel::dumpJSON(*m_json_writer,
mpstat,
false);
148void JsonMessagePassingProfilingService::
149_updateFromBeginEntryPointEvt()
152 m_sub_domain->parallelMng()->stat()->toArccoreStat()->resetCurrentStat();
158void JsonMessagePassingProfilingService::
159_updateFromEndEntryPointEvt()
162 const String& ep_name(m_sub_domain->timeLoopMng()->currentEntryPoint()->name());
163 auto pos(m_ep_mpstat_col.find(ep_name));
166 if (pos == m_ep_mpstat_col.end())
167 m_ep_mpstat_col.emplace(ep_name, stat_data);
169 pos->second.mergeAllData(stat_data);
175void JsonMessagePassingProfilingService::
176_updateFromBeginIterationEvt()
179 m_ep_mpstat_col.clear();
185void JsonMessagePassingProfilingService::
186_updateFromEndIterationEvt()
190 _dumpCurrentIterationInJSON();
#define ARCANE_SERVICE_INTERFACE(ainterface)
Macro pour déclarer une interface lors de l'enregistrement d'un service.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Statistique sur un message.
Ensemble de données statistiques pour le profiling.
Chaîne de caractères unicode.
#define ARCANE_REGISTER_SERVICE(aclass, a_service_property,...)
Macro pour enregistrer un service.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
@ ST_SubDomain
Le service s'utilise au niveau du sous-domaine.