Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
EnumeratorTracer.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2023 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/* EnumeratorTracer.cc (C) 2000-2023 */
9/* */
10/* Enumérateurs sur les mailles matériaux. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/materials/EnumeratorTracer.h"
15
16#include "arcane/utils/IPerformanceCounterService.h"
17#include "arcane/utils/Profiling.h"
18#include "arcane/utils/PlatformUtils.h"
19#include "arcane/utils/ForLoopTraceInfo.h"
20
21#include "arcane/materials/MatItemEnumerator.h"
22
23#include <iostream>
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31namespace Arcane::Materials
32{
33
34/*---------------------------------------------------------------------------*/
35/*---------------------------------------------------------------------------*/
36
37EnumeratorTracer::
38EnumeratorTracer(ITraceMng* tm, Ref<IPerformanceCounterService> perf_service)
39: TraceAccessor(tm)
40, m_perf_counter(perf_service)
41{
42}
43
44/*---------------------------------------------------------------------------*/
45/*---------------------------------------------------------------------------*/
46
47EnumeratorTracer::
48~EnumeratorTracer()
49{
50}
51
52/*---------------------------------------------------------------------------*/
53/*---------------------------------------------------------------------------*/
54
55void EnumeratorTracer::
56_beginLoop(EnumeratorTraceInfo& eti)
57{
58 ++m_nb_call;
59 m_perf_counter->getCounters(eti.counters(), false);
60 eti.setBeginTime(platform::getRealTimeNS());
61}
62
63/*---------------------------------------------------------------------------*/
64/*---------------------------------------------------------------------------*/
65
66void EnumeratorTracer::
67_endLoop(EnumeratorTraceInfo& eti)
68{
69 m_perf_counter->getCounters(eti.counters(), true);
70 const TraceInfo* ti = eti.traceInfo();
71 ForLoopTraceInfo loop_trace_info;
72 if (ti)
73 loop_trace_info = ForLoopTraceInfo(*ti);
74 ForLoopOneExecStat exec_stat;
75 exec_stat.setBeginTime(eti.beginTime());
76 exec_stat.setEndTime(platform::getRealTimeNS());
77 ProfilingRegistry::_threadLocalForLoopInstance()->merge(exec_stat, loop_trace_info);
78}
79
80/*---------------------------------------------------------------------------*/
81/*---------------------------------------------------------------------------*/
82
83void EnumeratorTracer::
84enterEnumerator(const ComponentEnumerator& e, EnumeratorTraceInfo& eti)
85{
86 _beginLoop(eti);
87 const TraceInfo* ti = eti.traceInfo();
88 if (ti && m_is_verbose)
89 info() << "Enum size=" << e.m_size << " where=" << *ti;
90}
91
92/*---------------------------------------------------------------------------*/
93/*---------------------------------------------------------------------------*/
94
95void EnumeratorTracer::
96exitEnumerator(const ComponentEnumerator&, EnumeratorTraceInfo& eti)
97{
98 _endLoop(eti);
99 if (m_is_verbose)
100 info() << "EndLoop: Component counters=" << eti.counters();
101}
102
103/*---------------------------------------------------------------------------*/
104/*---------------------------------------------------------------------------*/
105
106void EnumeratorTracer::
107enterEnumerator(const MatEnumerator&,EnumeratorTraceInfo& eti)
108{
109 _beginLoop(eti);
110}
111
112/*---------------------------------------------------------------------------*/
113/*---------------------------------------------------------------------------*/
114
115void EnumeratorTracer::
116exitEnumerator(const MatEnumerator&,EnumeratorTraceInfo& eti)
117{
118 _endLoop(eti);
119}
120
121/*---------------------------------------------------------------------------*/
122/*---------------------------------------------------------------------------*/
123
124void EnumeratorTracer::
125enterEnumerator(const EnvEnumerator&,EnumeratorTraceInfo& eti)
126{
127 _beginLoop(eti);
128}
129
130/*---------------------------------------------------------------------------*/
131/*---------------------------------------------------------------------------*/
132
133void EnumeratorTracer::
134exitEnumerator(const EnvEnumerator&,EnumeratorTraceInfo& eti)
135{
136 _endLoop(eti);
137}
138
139/*---------------------------------------------------------------------------*/
140/*---------------------------------------------------------------------------*/
141
142void EnumeratorTracer::
143enterEnumerator(const ComponentCellEnumerator& e,EnumeratorTraceInfo& eti)
144{
145 ++m_nb_call_component_cell;
146 m_nb_loop_component_cell += e.m_size;
147 const TraceInfo* ti = eti.traceInfo();
148 if (ti && m_is_verbose)
149 info() << "ComponentCell size=" << e.m_size << " where=" << *ti;
150 _beginLoop(eti);
151}
152
153/*---------------------------------------------------------------------------*/
154/*---------------------------------------------------------------------------*/
155
156void EnumeratorTracer::
157exitEnumerator(const ComponentCellEnumerator&, EnumeratorTraceInfo& eti)
158{
159 _endLoop(eti);
160 if (m_is_verbose)
161 info() << "EndLoop: ComponentCell counters=" << eti.counters();
162}
163
164/*---------------------------------------------------------------------------*/
165/*---------------------------------------------------------------------------*/
166
167void EnumeratorTracer::
168enterEnumerator(const AllEnvCellEnumerator& e,EnumeratorTraceInfo& eti)
169{
170 ++m_nb_call_all_env_cell;
171 m_nb_loop_all_env_cell += e.m_size;
172
173 const TraceInfo* ti = eti.traceInfo();
174 if (ti && m_is_verbose)
175 info() << "ComponentCell size=" << e.m_size << " where=" << *ti;
176 _beginLoop(eti);
177}
178
179/*---------------------------------------------------------------------------*/
180/*---------------------------------------------------------------------------*/
181
182void EnumeratorTracer::
183exitEnumerator(const AllEnvCellEnumerator&,EnumeratorTraceInfo& eti)
184{
185 _endLoop(eti);
186 if (m_is_verbose)
187 info() << "EndLoop: AllEnvCell counters=" << eti.counters();
188}
189
190/*---------------------------------------------------------------------------*/
191/*---------------------------------------------------------------------------*/
192
193void EnumeratorTracer::
194enterEnumerator(const CellComponentCellEnumerator& e,EnumeratorTraceInfo& eti)
195{
196 ++m_nb_call_cell_component_cell;
197 m_nb_loop_cell_component_cell += e.m_size;
198 _beginLoop(eti);
199}
200
201/*---------------------------------------------------------------------------*/
202/*---------------------------------------------------------------------------*/
203
204void EnumeratorTracer::
205exitEnumerator(const CellComponentCellEnumerator&,EnumeratorTraceInfo& eti)
206{
207 _endLoop(eti);
208}
209
210/*---------------------------------------------------------------------------*/
211/*---------------------------------------------------------------------------*/
212
213void EnumeratorTracer::
214enterEnumerator(const ComponentPartSimdCellEnumerator&,EnumeratorTraceInfo& eti)
215{
216 _beginLoop(eti);
217}
218
219/*---------------------------------------------------------------------------*/
220/*---------------------------------------------------------------------------*/
221
222void EnumeratorTracer::
223exitEnumerator(const ComponentPartSimdCellEnumerator&,EnumeratorTraceInfo& eti)
224{
225 _endLoop(eti);
226}
227
228/*---------------------------------------------------------------------------*/
229/*---------------------------------------------------------------------------*/
230
231void EnumeratorTracer::
232enterEnumerator(const ComponentPartCellEnumerator&,EnumeratorTraceInfo& eti)
233{
234 _beginLoop(eti);
235}
236
237/*---------------------------------------------------------------------------*/
238/*---------------------------------------------------------------------------*/
239
240void EnumeratorTracer::
241exitEnumerator(const ComponentPartCellEnumerator&,EnumeratorTraceInfo& eti)
242{
243 _endLoop(eti);
244}
245
246/*---------------------------------------------------------------------------*/
247/*---------------------------------------------------------------------------*/
248
249void EnumeratorTracer::
250dumpStats()
251{
252 info() << "ENUMERATOR_TRACER_DUMP_STATS nb_call=" << m_nb_call;
253 info() << " nb_call_all_env_cell=" << m_nb_call_all_env_cell
254 << " nb_loop_all_env_cell=" << m_nb_loop_all_env_cell
255 << " ratio=" << (Real)m_nb_loop_all_env_cell / (Real)(m_nb_call_all_env_cell+1);
256 info() << " nb_call_component_cell=" << m_nb_call_component_cell
257 << " nb_loop_component_cell=" << m_nb_loop_component_cell
258 << " ratio=" << (Real)m_nb_loop_component_cell / (Real)(m_nb_call_component_cell+1);
259 info() << " nb_call_cell_component_cell=" << m_nb_call_cell_component_cell
260 << " nb_loop_cell_component_cell=" << m_nb_loop_cell_component_cell
261 << " ratio=" << (Real)m_nb_loop_cell_component_cell / (Real)(m_nb_call_cell_component_cell+1);
262}
263
264/*---------------------------------------------------------------------------*/
265/*---------------------------------------------------------------------------*/
266
267} // End namespace Arcane::Materials
268
269/*---------------------------------------------------------------------------*/
270/*---------------------------------------------------------------------------*/
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Active toujours les traces dans les parties Arcane concernant les matériaux.