14#include "arcane/std/Otf2MessagePassingProfilingService.h"
16#include "arcane/ServiceFactory.h"
17#include "arcane/CommonVariables.h"
18#include "arcane/IMesh.h"
19#include "arcane/IItemFamily.h"
20#include "arcane/IVariableSynchronizer.h"
21#include "arcane/ITimeLoopMng.h"
22#include "arcane/IParallelMng.h"
23#include "arcane/IEntryPoint.h"
24#include "arcane/utils/ITraceMng.h"
25#include "arcane/parallel/IStat.h"
27#include "arccore/message_passing/IMessagePassingMng.h"
28#include "arccore/message_passing/IDispatchers.h"
29#include "arccore/message_passing/IControlDispatcher.h"
44 ServiceProperty(
"Otf2MessagePassingProfiling",
ST_SubDomain),
50Otf2MessagePassingProfilingService::
51Otf2MessagePassingProfilingService(
const ServiceBuildInfo& sbi)
53, m_sub_domain(sbi.subDomain())
54, m_otf2_wrapper(sbi.subDomain())
55, m_otf2_prof(&m_otf2_wrapper)
56, m_prof_backup(nullptr)
57, m_impl_name(
"Otf2MessagePassingProfiling")
64Otf2MessagePassingProfilingService::
65~Otf2MessagePassingProfilingService() noexcept
72void Otf2MessagePassingProfilingService::
79 m_otf2_wrapper.init(m_sub_domain->application()->applicationName());
83 m_control_dispatcher =
cd;
86 m_prof_backup =
cd->profiler();
89 cd->setProfiler(&m_otf2_prof);
93 m_observer.addObserver(
this, &Otf2MessagePassingProfilingService::_updateFromBeginEntryPointEvt,
94 m_sub_domain->timeLoopMng()->observable(eTimeLoopEventType::BeginEntryPoint));
97 m_observer.addObserver(
this, &Otf2MessagePassingProfilingService::_updateFromEndEntryPointEvt,
98 m_sub_domain->timeLoopMng()->observable(eTimeLoopEventType::EndEntryPoint));
101 auto sync_evt_handler = std::function<void(const Arcane::VariableSynchronizerEventArgs&)>(
102 std::bind(&Otf2MessagePassingProfilingService::_updateFromSynchronizeEvt,
this, std::placeholders::_1));
105 m_sub_domain->defaultMesh()->cellFamily()->allItemsSynchronizer()->onSynchronized().attach(m_observer_pool,
108 m_sub_domain->defaultMesh()->nodeFamily()->allItemsSynchronizer()->onSynchronized().attach(m_observer_pool,
111 m_sub_domain->defaultMesh()->edgeFamily()->allItemsSynchronizer()->onSynchronized().attach(m_observer_pool,
114 m_sub_domain->defaultMesh()->faceFamily()->allItemsSynchronizer()->onSynchronized().attach(m_observer_pool,
120 m_otf2_wrapper.getApplicationNameId(), 0,
NULL);
126void Otf2MessagePassingProfilingService::
130 if (m_control_dispatcher)
131 m_control_dispatcher->setProfiler(m_prof_backup);
135 m_otf2_wrapper.finalize();
138 m_observer.detachAll();
143void Otf2MessagePassingProfilingService::
144printInfos(std::ostream& output)
146 ARCANE_UNUSED(output);
152String Otf2MessagePassingProfilingService::
161void Otf2MessagePassingProfilingService::
162_updateFromBeginEntryPointEvt()
165 const String&
ep_name(m_sub_domain->timeLoopMng()->currentEntryPoint()->fullName());
168 m_otf2_wrapper.getEntryPointId(
ep_name));
174void Otf2MessagePassingProfilingService::
175_updateFromEndEntryPointEvt()
178 const String& ep_name(m_sub_domain->timeLoopMng()->currentEntryPoint()->fullName());
180 OTF2_EvtWriter_Leave(m_otf2_wrapper.getEventWriter(), NULL, Otf2LibWrapper::getTime(),
181 m_otf2_wrapper.getEntryPointId(ep_name));
187void Otf2MessagePassingProfilingService::
188_updateFromSynchronizeEvt(
const VariableSynchronizerEventArgs& arg)
190 if (arg.state() == VariableSynchronizerEventArgs::State::BeginSynchronize)
191 OTF2_EvtWriter_Enter(m_otf2_wrapper.getEventWriter(), NULL, Otf2LibWrapper::getTime(),
192 m_otf2_wrapper.getSynchronizeId());
194 OTF2_EvtWriter_Leave(m_otf2_wrapper.getEventWriter(), NULL, Otf2LibWrapper::getTime(),
195 m_otf2_wrapper.getSynchronizeId());
#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.
Manage control streams for parallel messages.
Interface du gestionnaire des échanges de messages.
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.