Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
TimeMetric.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* TimeMetric.h (C) 2000-2020 */
9/* */
10/* Classes gérant les métriques temporelles. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_TRACE_TIMEMETRIC_H
13#define ARCCORE_TRACE_TIMEMETRIC_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/trace/TraceGlobal.h"
18#include "arccore/trace/ITimeMetricCollector.h"
19#include "arccore/base/String.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23/*
24 * API en cours de définition. Ne pas utiliser en dehors de Arccore/Arcane.
25 */
26namespace Arccore
27{
35{
36 Computation = 0,
37 MessagePassing = 1,
38 InputOutput = 2
39};
40
41/*---------------------------------------------------------------------------*/
42/*---------------------------------------------------------------------------*/
43
44class ARCCORE_TRACE_EXPORT TimeMetricActionBuildInfo
45{
46 public:
47 explicit TimeMetricActionBuildInfo(const String& name)
48 : m_name(name), m_phase(-1){}
49 TimeMetricActionBuildInfo(const String& name,int phase)
50 : m_name(name), m_phase(phase){}
51 public:
52 const String& name() const { return m_name; }
53 int phase() const { return m_phase; }
54 public:
55 String m_name;
56 int m_phase = -1;
57};
58
59/*---------------------------------------------------------------------------*/
60/*---------------------------------------------------------------------------*/
61
62class ARCCORE_TRACE_EXPORT TimeMetricAction
63{
64 public:
66 : m_collector(nullptr), m_phase(-1) {}
68 : m_collector(c), m_name(x.name()), m_phase(x.phase()){}
69 public:
70 ITimeMetricCollector* collector() const { return m_collector; }
71 const String& name() const { return m_name; }
72 int phase() const { return m_phase; }
73 private:
74 ITimeMetricCollector* m_collector;
75 String m_name;
76 int m_phase;
77};
78
79/*---------------------------------------------------------------------------*/
80/*---------------------------------------------------------------------------*/
81// TODO: n'autoriser que la sémantique std::move
82class ARCCORE_TRACE_EXPORT TimeMetricId
83{
84 public:
85 TimeMetricId() : m_id(-1){}
86 explicit TimeMetricId(const TimeMetricAction& action,Int64 id)
87 : m_action(action), m_id(id){}
88 const TimeMetricAction& action() const { return m_action; }
89 Int64 id() const { return m_id; }
90 public:
91 TimeMetricAction m_action;
92 Int64 m_id;
93};
94
95/*---------------------------------------------------------------------------*/
96/*---------------------------------------------------------------------------*/
100class ARCCORE_TRACE_EXPORT TimeMetricSentry
101{
102 public:
103 TimeMetricSentry() : m_collector(nullptr){}
105 : m_collector(rhs.m_collector), m_id(rhs.m_id)
106 {
107 // Met à nul \a rhs pour ne pas qu'il appelle 'endAction'.
108 rhs.m_collector = nullptr;
109 }
110 explicit TimeMetricSentry(const TimeMetricAction& action)
111 : m_collector(action.collector())
112 {
113 if (m_collector)
114 m_id = m_collector->beginAction(action);
115 }
116 ~TimeMetricSentry() noexcept(false)
117 {
118 if (m_collector)
119 m_collector->endAction(m_id);
120 }
121 private:
122 ITimeMetricCollector* m_collector;
123 TimeMetricId m_id;
124};
125
126/*---------------------------------------------------------------------------*/
127/*---------------------------------------------------------------------------*/
131class ARCCORE_TRACE_EXPORT StandardPhaseTimeMetrics
132{
133 public:
134 StandardPhaseTimeMetrics() = default;
136 public:
137 void initialize(ITimeMetricCollector* collector);
138 public:
140 const TimeMetricAction& messagePassingPhase() const { return m_message_passing_phase; }
142 const TimeMetricAction& inputOutputPhase() const { return m_input_output_phase; }
144 const TimeMetricAction& computationPhase() const { return m_computation_phase; }
145 private:
146 TimeMetricAction m_message_passing_phase;
147 TimeMetricAction m_input_output_phase;
148 TimeMetricAction m_computation_phase;
149};
150
151/*---------------------------------------------------------------------------*/
152/*---------------------------------------------------------------------------*/
153
154extern "C++" ARCCORE_TRACE_EXPORT TimeMetricAction
155timeMetricPhaseMessagePassing(ITimeMetricCollector* c);
156extern "C++" ARCCORE_TRACE_EXPORT TimeMetricAction
157timeMetricPhaseInputOutput(ITimeMetricCollector* c);
158extern "C++" ARCCORE_TRACE_EXPORT TimeMetricAction
159timeMetricPhaseComputation(ITimeMetricCollector* c);
160
161/*---------------------------------------------------------------------------*/
162/*---------------------------------------------------------------------------*/
163
164} // End namespace Arccore
165
166/*---------------------------------------------------------------------------*/
167/*---------------------------------------------------------------------------*/
168
169#endif
Interface gérant les statistiques sur l'exécution.
s standards pour les phases temporelles.
Definition TimeMetric.h:132
const TimeMetricAction & inputOutputPhase() const
Action pour indiquer qu'on est dans une phase d'entrée-sortie.
Definition TimeMetric.h:142
const TimeMetricAction & computationPhase() const
Action pour indiquer qu'on est dans une phase de calcul.
Definition TimeMetric.h:144
const TimeMetricAction & messagePassingPhase() const
Action pour indiquer qu'on est dans une phase d'échange de message.
Definition TimeMetric.h:140
Chaîne de caractères unicode.
Sentinelle pour collecter les informations temporelles.
Definition TimeMetric.h:101
Espace de nom de Arccore.
Definition ArcaneTypes.h:24
std::int64_t Int64
Type entier signé sur 64 bits.
TimeMetricPhase
Catégories standards pour les phases temporelles.
Definition TimeMetric.h:35