Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
ArcaneMain.h
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/* ArcaneMain.h (C) 2000-2023 */
9/* */
10/* Classe gérant l'exécution. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_IMPL_ARCANEMAIN_H
13#define ARCANE_IMPL_ARCANEMAIN_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/List.h"
18#include "arcane/utils/IFunctor.h"
19#include "arcane/IArcaneMain.h"
20
21#include <atomic>
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26namespace Arcane
27{
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32class ApplicationInfo;
33class IMainFactory;
34class IApplication;
35class ICodeService;
36class ServiceFactoryInfo;
37class ArcaneMainExecInfo;
38class DotNetRuntimeInitialisationInfo;
39
40
41/*---------------------------------------------------------------------------*/
42/*---------------------------------------------------------------------------*/
43
44class ARCANE_IMPL_EXPORT ArcaneMainExecutionOverrideFunctor
45{
46 friend class ArcaneMain;
47 friend class ArcaneMainExecInfo;
48 public:
50 : m_functor(functor), m_application(nullptr){}
51 IFunctor* functor() { return m_functor; }
52 IApplication* application() { return m_application; }
53 private:
54 IFunctor* m_functor;
55 IApplication* m_application;
56};
57
58/*---------------------------------------------------------------------------*/
59/*---------------------------------------------------------------------------*/
60
61class ARCANE_IMPL_EXPORT IApplicationBuildInfoVisitor
62{
63 public:
65 public:
66 virtual void visit(ApplicationBuildInfo& app_build_info) =0;
67};
68
69/*---------------------------------------------------------------------------*/
70/*---------------------------------------------------------------------------*/
78class ARCANE_IMPL_EXPORT ArcaneMain
79: public IArcaneMain
80{
81 friend class ArcaneMainExecInfo;
82 friend class ArcaneLauncher;
84 class Impl;
85
86 public:
87 // TODO: a supprimer.
88 ArcaneMain(const ApplicationInfo& infos,IMainFactory* factory);
89 public:
94 ~ArcaneMain() override;
95
96 public:
97
127 static int arcaneMain(const ApplicationInfo& app_info,IMainFactory* factory=nullptr);
128
136 static int run();
137
148 static void arcaneInitialize();
149
162 static void arcaneFinalize();
163
170 static void setHasGarbageCollector();
171
178 static void setHasDotNETRuntime();
179
188 static void setDefaultMainFactory(IMainFactory* mf);
189
199 static ApplicationInfo& defaultApplicationInfo();
200
207 static DotNetRuntimeInitialisationInfo& defaultDotNetRuntimeInitialisationInfo();
208
215 static AcceleratorRuntimeInitialisationInfo& defaultAcceleratorRuntimeInitialisationInfo();
216
223 static ApplicationBuildInfo& defaultApplicationBuildInfo();
224
242 static int callFunctorWithCatchedException(IFunctor* functor,IArcaneMain* amain,
243 bool* clean_abort,
244 bool is_print=true);
245
258 static void setExecuteOverrideFunctor(ArcaneMainExecutionOverrideFunctor* functor);
259
261 static bool hasDotNetWrapper();
262
269 static Real initializationTimeForAccelerator();
270
271 public:
272
278 static void addServiceFactoryInfo(IServiceFactoryInfo* factory);
279
285 static void addModuleFactoryInfo(IModuleFactoryInfo* factory);
286
287 public:
288
295 static void addApplicationBuildInfoVisitor(IApplicationBuildInfoVisitor* visitor);
296
297 public:
298
299 static void redirectSignals();
300 static bool isMasterIO() { return m_is_master_io; }
301 static void setUseTestLogger(bool v);
302
303 public:
304
305 void build() override;
306 void initialize() override;
307 bool parseArgs(StringList args) override;
308 int execute() override;
309 void doAbort() override;
310 void setErrorCode(int errcode) override;
311 int errorCode() const override { return m_error_code; }
312 void finalize() override {}
313
314 public:
315
316 const ApplicationInfo& applicationInfo() const override;
317 const ApplicationBuildInfo& applicationBuildInfo() const override;
318 const DotNetRuntimeInitialisationInfo& dotnetRuntimeInitialisationInfo() const override;
319 const AcceleratorRuntimeInitialisationInfo& acceleratorRuntimeInitialisationInfo() const override;
320 IMainFactory* mainFactory() const override { return m_main_factory; }
321 IApplication* application() const override { return m_application; }
322 ServiceFactoryInfoCollection registeredServiceFactoryInfos() override;
323 ModuleFactoryInfoCollection registeredModuleFactoryInfos() override;
324 bool hasGarbageCollector() const override { return m_has_garbage_collector; }
325 void setDirectExecuteFunctor(IDirectSubDomainExecuteFunctor* f) override { m_direct_sub_domain_execute_functor = f; }
326 IDirectSubDomainExecuteFunctor* _directExecuteFunctor() const { return m_direct_sub_domain_execute_functor; }
327
328 protected:
329
330 IApplication* _application() { return m_application; }
331 ApplicationBuildInfo& _applicationBuildInfo();
332 static int _internalRun(IDirectSubDomainExecuteFunctor* func);
333
334 private:
335
336 Impl* m_p;
337 IMainFactory* m_main_factory = nullptr;
338 IApplication* m_application = nullptr;
339 int m_error_code = 0;
340 IDirectSubDomainExecuteFunctor* m_direct_sub_domain_execute_functor = nullptr;
341 static bool m_has_garbage_collector;
342 static bool m_is_master_io;
343 static bool m_is_use_test_logger;
344 static IMainFactory* m_default_main_factory;
345 static ArcaneMainExecutionOverrideFunctor* m_exec_override_functor;
346
347 private:
348
349 static int _arcaneMain(const ApplicationInfo&,IMainFactory*);
350 void _dumpHelp();
351 void _parseApplicationBuildInfoArgs();
353 static std::atomic<Int32> m_nb_arcane_init;
355 static std::atomic<Int32> m_is_init_done;
356 static void _launchMissingInitException();
357 static void _checkHasInit();
358 static void _checkCreateDynamicLibraryLoader();
359 static int _runDotNet();
360 static void _checkAutoDetectMPI();
361 static int _checkAutoDetectAccelerator(bool& has_accelerator);
362 static void _setArcaneLibraryPath();
363 static int _initRuntimes();
364 static int _checkTestLoggerResult();
365};
366
367/*---------------------------------------------------------------------------*/
368/*---------------------------------------------------------------------------*/
369
370} // End namespace Arcane
371
372/*---------------------------------------------------------------------------*/
373/*---------------------------------------------------------------------------*/
374
375#endif
Informations pour construire une instance de IApplication.
Informations sur une application.
Classe de gestion de l'exécution.
Classe pour gérer les appels aux mécanismes d'auto-détection des runtimes (MPI,Accélérateurs).
Classe de gestion de l'exécution.
Definition ArcaneMain.h:80
static std::atomic< Int32 > m_nb_arcane_init
Nombre de fois que arcaneInitialize() a été appelé
Definition ArcaneMain.h:353
bool hasGarbageCollector() const override
Indique que certains objets sont gérés via un ramasse miette.
Definition ArcaneMain.h:324
void finalize() override
Effectue les dernières opérations avant destruction de l'instance.
Definition ArcaneMain.h:312
IApplication * application() const override
Application.
Definition ArcaneMain.h:321
static std::atomic< Int32 > m_is_init_done
1 si init terminé, 0 sinon
Definition ArcaneMain.h:355
int errorCode() const override
Code d'erreur de l'exécution.
Definition ArcaneMain.h:311
IMainFactory * mainFactory() const override
Fabrique principale.
Definition ArcaneMain.h:320
Informations pour l'initialisation du runtime '.Net'.
Interface de l'application.
Interface de la classe de gestion du code.
Definition IArcaneMain.h:54
Interface d'un fonctor pour exécuter du code directement après la création d'un sous-domaine sans pas...
Manufacture des classes d'Arcane.
Informations sur la fabrique d'un module.
Informations sur la fabrique d'un service.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-