Arcane  v3.14.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
EntryPoint.cc
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/* EntryPoint.cc (C) 2000-2022 */
9/* */
10/* Point d'entrée d'un module. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/EntryPoint.h"
15
16#include "arcane/utils/ITraceMng.h"
17#include "arcane/utils/PlatformUtils.h"
18#include "arcane/utils/StringBuilder.h"
19
20#include "arcane/IModule.h"
21#include "arcane/IEntryPointMng.h"
22#include "arcane/ISubDomain.h"
23#include "arcane/Timer.h"
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28namespace Arcane
29{
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
34const char* const IEntryPoint::WComputeLoop = "ComputeLoop";
35const char* const IEntryPoint::WBuild = "Build";
36const char* const IEntryPoint::WInit = "Init";
37const char* const IEntryPoint::WContinueInit = "ContinueInit";
38const char* const IEntryPoint::WStartInit = "StartInit";
39const char* const IEntryPoint::WRestore = "Restore";
40const char* const IEntryPoint::WOnMeshChanged = "OnMeshChanged";
41const char* const IEntryPoint::WOnMeshRefinement = "OnMeshRefinement";
42const char* const IEntryPoint::WExit = "Exit";
43
44/*---------------------------------------------------------------------------*/
45/*---------------------------------------------------------------------------*/
46
47EntryPoint::
48EntryPoint(const EntryPointBuildInfo& bi)
49: m_sub_domain(bi.module()->subDomain())
50, m_caller(bi.caller())
51, m_elapsed_timer(new Timer(m_sub_domain, bi.name(), Timer::TimerReal))
52, m_name(bi.name())
53, m_module(bi.module())
54, m_where(bi.where())
55, m_property(bi.property())
56, m_nb_call(0)
57, m_is_destroy_caller(bi.isDestroyCaller())
58{
59 // S'enregistre auprès du gestionnaire de points d'entrée.
60 // qui s'occupera de la destruction.
61 m_sub_domain->entryPointMng()->addEntryPoint(this);
62
63 {
64 StringBuilder sb;
65 sb.append(m_module->name());
66 sb.append(".");
67 sb.append(m_name);
68 sb.append(".");
69 sb.append(m_where);
70 m_full_name = sb.toString();
71 }
72}
73
74/*---------------------------------------------------------------------------*/
75/*---------------------------------------------------------------------------*/
76
77EntryPoint* EntryPoint::
78create(const EntryPointBuildInfo& bi)
79{
80 EntryPoint* x = new EntryPoint(bi);
81 return x;
82}
83
84/*---------------------------------------------------------------------------*/
85/*---------------------------------------------------------------------------*/
86
87EntryPoint::
88~EntryPoint()
89{
90 delete m_elapsed_timer;
91 //FIXME ceci ne doit pas etre detruit si on passe par le wrapper C#
92 if (m_is_destroy_caller)
93 delete m_caller;
94}
95
96/*---------------------------------------------------------------------------*/
97/*---------------------------------------------------------------------------*/
98
99#ifdef __GNUG__
100#pragma GCC optimize "O0"
101#endif
102void EntryPoint::
103_getAddressForHyoda(void* next_entry_point_address)
104{
105#ifndef ARCANE_OS_WIN32
106 if (platform::hasDotNETRuntime())
107 return;
108 {
109 char address[48 + 1];
110 snprintf(address, sizeof(address) - 1, "%p", next_entry_point_address);
111 //m_sub_domain->traceMng()->debug()<< "\33[7m" << m_where <<"->"<< m_name << "\33[m" << " @" << address;
112 }
113#endif
114}
115#ifdef __GNUG__
116#pragma GCC reset_options
117#endif
118
119/*---------------------------------------------------------------------------*/
120/*---------------------------------------------------------------------------*/
121void EntryPoint::
122executeEntryPoint()
123{
124 // Les points d'entrée de la boucle de calcul ne
125 // sont pas appelés si le module n'est pas actif.
126 if (m_module->disabled() && m_where == WComputeLoop)
127 return;
128
129 // Dans le cas de GCC, on va piocher dans la module_vtable pour récupérer l'adresse à venir
130 // que l'on va présenter à Hyoda
131 if (!platform::hasDotNETRuntime()) {
132#ifdef __GNUG__
133 _getAddressForHyoda((static_cast<IFunctorWithAddress*>(m_caller))->functorAddress());
134#else
135 _getAddressForHyoda();
136#endif
137 }
138
139 Trace::Setter mclass(m_sub_domain->traceMng(), m_module->name());
140
141 {
142 Timer::Sentry ts_elapsed(m_elapsed_timer);
143 Timer::Action ts_action1(m_sub_domain, m_module->name());
144 Timer::Phase ts_phase(m_sub_domain, TP_Computation);
145 Timer::Action ts_action2(m_sub_domain, m_name);
146 m_caller->executeFunctor();
147 }
148
149 ++m_nb_call;
150}
151
152/*---------------------------------------------------------------------------*/
153/*---------------------------------------------------------------------------*/
154
155Real EntryPoint::
156lastCPUTime() const
157{
158 return m_elapsed_timer->lastActivationTime();
159}
160
161/*---------------------------------------------------------------------------*/
162/*---------------------------------------------------------------------------*/
163
164Real EntryPoint::
165totalCPUTime() const
166{
167 return m_elapsed_timer->totalTime();
168}
169
170/*---------------------------------------------------------------------------*/
171/*---------------------------------------------------------------------------*/
172
173Real EntryPoint::
174lastElapsedTime() const
175{
176 return m_elapsed_timer->lastActivationTime();
177}
178
179/*---------------------------------------------------------------------------*/
180/*---------------------------------------------------------------------------*/
181
182Real EntryPoint::
183totalElapsedTime() const
184{
185 return m_elapsed_timer->totalTime();
186}
187
188/*---------------------------------------------------------------------------*/
189/*---------------------------------------------------------------------------*/
190
191Real EntryPoint::
192totalTime(Timer::eTimerType) const
193{
194 return totalElapsedTime();
195}
196
197/*---------------------------------------------------------------------------*/
198/*---------------------------------------------------------------------------*/
199
200Real EntryPoint::
201lastTime(Timer::eTimerType) const
202{
203 return lastElapsedTime();
204}
205
206/*---------------------------------------------------------------------------*/
207/*---------------------------------------------------------------------------*/
208
209} // End namespace Arcane
210
211/*---------------------------------------------------------------------------*/
212/*---------------------------------------------------------------------------*/
213
Informations pour construire un point d'entrée.
Definition EntryPoint.h:37
static const char *const WComputeLoop
appelé pendant la boucle de calcul
Definition IEntryPoint.h:42
static const char *const WBuild
appelé pour la construction du module
Definition IEntryPoint.h:44
static const char *const WStartInit
appelé pendant l'initialisation d'un nouveau cas
Definition IEntryPoint.h:50
static const char *const WRestore
appelé pour restaurer les variables lors d'un retour arrière
Definition IEntryPoint.h:52
static const char *const WOnMeshRefinement
appelé après un raffinement de maillage
Definition IEntryPoint.h:56
static const char *const WOnMeshChanged
appelé après un changement de maillage
Definition IEntryPoint.h:54
static const char *const WContinueInit
appelé pendant l'initialisation d'une reprise
Definition IEntryPoint.h:48
static const char *const WInit
appelé pendant l'initialisation
Definition IEntryPoint.h:46
Interface d'un fonctor.
Postionne le nom de l'action en cours d'exécution.
Definition Timer.h:110
Positionne la phase de l'action en cours d'exécution.
Definition Timer.h:128
Sentinelle pour le timer. La sentinelle associée à un timer permet de déclancher celui-ci au moment d...
Definition Timer.h:89
eTimerType
Type du timer.
Definition Timer.h:67
Positionne une classe de message.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-