Execution management class. More...
#include <arcane/impl/ArcaneMain.h>
Classes | |
| class | Impl |
Public Member Functions | |
| ArcaneMain (const ApplicationInfo &infos, IMainFactory *factory) | |
| ArcaneMain (const ApplicationInfo &app_info, IMainFactory *factory, const ApplicationBuildInfo &app_build_info, const DotNetRuntimeInitialisationInfo &dotnet_init_info, const AcceleratorRuntimeInitialisationInfo &accelerator_init_info) | |
| void | build () override |
| Constructs the class members. The instance is not usable until this method has been called. This method must be called before initialize(). | |
| void | initialize () override |
| Initializes the instance. The instance is not usable until this method has been called. | |
| bool | parseArgs (StringList args) override |
| Parses arguments. | |
| int | execute () override |
| Starts execution. This method only returns when the program exits. | |
| void | doAbort () override |
| Performs an abort. | |
| void | setErrorCode (int errcode) override |
| Sets the return code. | |
| int | errorCode () const override |
| Execution error code. | |
| void | finalize () override |
| Performs the last operations before instance destruction. | |
| const ApplicationInfo & | applicationInfo () const override |
| Executable information. | |
| const ApplicationBuildInfo & | applicationBuildInfo () const override |
| Information to build the IApplication instance. | |
| const DotNetRuntimeInitialisationInfo & | dotnetRuntimeInitialisationInfo () const override |
| .Net runtime initialization information. | |
| const AcceleratorRuntimeInitialisationInfo & | acceleratorRuntimeInitialisationInfo () const override |
| Runtime initialization information for accelerators. | |
| IMainFactory * | mainFactory () const override |
| Main factory. | |
| IApplication * | application () const override |
| Application. | |
| ServiceFactoryInfoCollection | registeredServiceFactoryInfos () override |
| List of registered service factories. | |
| ModuleFactoryInfoCollection | registeredModuleFactoryInfos () override |
| List of registered module factories. | |
| bool | hasGarbageCollector () const override |
| Indicates that certain objects are managed via a garbage collector. | |
| void | setDirectExecuteFunctor (IDirectSubDomainExecuteFunctor *f) override |
| IDirectSubDomainExecuteFunctor * | _directExecuteFunctor () const |
| Public Member Functions inherited from Arcane::IArcaneMain | |
| virtual | ~IArcaneMain () |
| Releases resources. | |
Static Public Member Functions | |
| static int | arcaneMain (const ApplicationInfo &app_info, IMainFactory *factory=nullptr) |
| Entry point of the executable in Arcane. | |
| static int | run () |
| Entry point of the executable in Arcane. | |
| static void | arcaneInitialize () |
| Initializes Arcane. | |
| static void | arcaneFinalize () |
| Terminates Arcane usage. | |
| static void | setHasGarbageCollector () |
| Indicates that certain objects are managed by a garbage collector. | |
| static void | setHasDotNETRuntime () |
| Indicates that we are running in the .NET runtime. | |
| static void | setDefaultMainFactory (IMainFactory *mf) |
| Sets the default factory. | |
| static ApplicationInfo & | defaultApplicationInfo () |
| Default application info. | |
| static DotNetRuntimeInitialisationInfo & | defaultDotNetRuntimeInitialisationInfo () |
| Information for .Net runtime initialization. | |
| static AcceleratorRuntimeInitialisationInfo & | defaultAcceleratorRuntimeInitialisationInfo () |
| Information for accelerator initialization. | |
| static ApplicationBuildInfo & | defaultApplicationBuildInfo () |
| Information for accelerator initialization. | |
| static int | callFunctorWithCatchedException (IFunctor *functor, IArcaneMain *amain, bool *clean_abort, bool is_print=true) |
| Calls the functor functor while catching possible exceptions. | |
| static void | setExecuteOverrideFunctor (ArcaneMainExecutionOverrideFunctor *functor) |
| static bool | hasDotNetWrapper () |
| Indicates if a '.Net' assembly is being executed from a C++ main. | |
| static Real | initializationTimeForAccelerator () |
| Returns the time (in seconds) for the initialization of accelerator runtimes for this process. | |
| static void | addServiceFactoryInfo (IServiceFactoryInfo *factory) |
| Adds a service factory. | |
| static void | addModuleFactoryInfo (IModuleFactoryInfo *factory) |
| Adds a module factory. | |
| static void | addApplicationBuildInfoVisitor (IApplicationBuildInfoVisitor *visitor) |
| Adds a visitor to fill ApplicationBuildInfo. | |
| static void | redirectSignals () |
| static bool | isMasterIO () |
| static void | setUseTestLogger (bool v) |
| Static Public Member Functions inherited from Arcane::IArcaneMain | |
| static IArcaneMain * | arcaneMain () |
| static void | setArcaneMain (IArcaneMain *arcane_main) |
Protected Member Functions | |
| IApplication * | _application () |
| ApplicationBuildInfo & | _applicationBuildInfo () |
Static Protected Member Functions | |
| static int | _internalRun (IDirectSubDomainExecuteFunctor *func) |
Private Member Functions | |
| void | _dumpHelp () |
| void | _parseApplicationBuildInfoArgs () |
Static Private Member Functions | |
| static int | _arcaneMain (const ApplicationInfo &, IMainFactory *) |
| Executable entry point. | |
| static void | _launchMissingInitException () |
| static void | _checkHasInit () |
| static int | _runDotNet () |
| static void | _checkAutoDetectMPI () |
| static int | _checkAutoDetectAccelerator (bool &has_accelerator) |
| Detects and loads accelerator runtime management. | |
| static void | _setArcaneLibraryPath () |
| static int | _initRuntimes () |
| static int | _checkTestLoggerResult () |
Private Attributes | |
| Impl * | m_p |
| IMainFactory * | m_main_factory = nullptr |
| IApplication * | m_application = nullptr |
| int | m_error_code = 0 |
| IDirectSubDomainExecuteFunctor * | m_direct_sub_domain_execute_functor = nullptr |
Static Private Attributes | |
| static bool | m_has_garbage_collector = false |
| static bool | m_is_master_io = true |
| static bool | m_is_use_test_logger = false |
| static IMainFactory * | m_default_main_factory = nullptr |
| static ArcaneMainExecutionOverrideFunctor * | m_exec_override_functor = nullptr |
| static std::atomic< Int32 > | m_nb_arcane_init |
| Number of times arcaneInitialize() has been called. | |
| static std::atomic< Int32 > | m_is_init_done |
| 1 if init finished, 0 otherwise | |
Friends | |
| class | ArcaneMainExecInfo |
| class | ArcaneLauncher |
| class | ArcaneMainAutoDetectRuntimeHelper |
Execution management class.
This class is internal to Arcane and should not be used directly. To initialize and execute the code, use the ArcaneLauncher class.
Definition at line 87 of file ArcaneMain.h.
| Arcane::ArcaneMain::ArcaneMain | ( | const ApplicationInfo & | infos, |
| IMainFactory * | factory ) |
Definition at line 1117 of file ArcaneMain.cc.
| Arcane::ArcaneMain::ArcaneMain | ( | const ApplicationInfo & | app_info, |
| IMainFactory * | factory, | ||
| const ApplicationBuildInfo & | app_build_info, | ||
| const DotNetRuntimeInitialisationInfo & | dotnet_init_info, | ||
| const AcceleratorRuntimeInitialisationInfo & | accelerator_init_info ) |
Definition at line 1127 of file ArcaneMain.cc.
|
override |
Definition at line 1140 of file ArcaneMain.cc.
|
inlineprotected |
Definition at line 341 of file ArcaneMain.h.
|
protected |
Definition at line 837 of file ArcaneMain.cc.
|
staticprivate |
Executable entry point.
Definition at line 499 of file ArcaneMain.cc.
References Arcane::ArcaneMainExecInfo::initialize().
Referenced by arcaneMain().
|
staticprivate |
Detects and loads accelerator runtime management.
In return, has_accelerator is true if an accelerator runtime was loaded.
| 0 | if everything is OK |
Definition at line 1090 of file ArcaneMain.cc.
References Arcane::Accelerator::Impl::RuntimeLoader::loadRuntime().
|
staticprivate |
Definition at line 1048 of file ArcaneMain.cc.
|
staticprivate |
Definition at line 617 of file ArcaneMain.cc.
|
staticprivate |
Definition at line 914 of file ArcaneMain.cc.
|
inline |
Definition at line 337 of file ArcaneMain.h.
|
private |
Definition at line 1352 of file ArcaneMain.cc.
|
staticprivate |
Definition at line 927 of file ArcaneMain.cc.
|
staticprotected |
Definition at line 904 of file ArcaneMain.cc.
|
staticprivate |
Definition at line 607 of file ArcaneMain.cc.
|
private |
Definition at line 1178 of file ArcaneMain.cc.
|
staticprivate |
Definition at line 976 of file ArcaneMain.cc.
|
staticprivate |
Definition at line 682 of file ArcaneMain.cc.
|
overridevirtual |
Runtime initialization information for accelerators.
Implements Arcane::IArcaneMain.
Definition at line 855 of file ArcaneMain.cc.
|
static |
Adds a visitor to fill ApplicationBuildInfo.
The pointer passed as an argument must remain valid until the call to arcaneMain(); The registered visitors are called just before the application is created.
Definition at line 783 of file ArcaneMain.cc.
Referenced by Arcane::arcaneAutoDetectMessagePassingServiceMPI().
|
static |
Adds a module factory.
This method must be called before arcaneMain()
Definition at line 774 of file ArcaneMain.cc.
|
static |
Adds a service factory.
This method must be called before arcaneMain()
Definition at line 765 of file ArcaneMain.cc.
|
inlineoverridevirtual |
Implements Arcane::IArcaneMain.
Definition at line 332 of file ArcaneMain.h.
Referenced by Arcane::ArcaneMainBatch::doAbort(), and parseArgs().
|
overridevirtual |
Information to build the IApplication instance.
Implements Arcane::IArcaneMain.
Definition at line 828 of file ArcaneMain.cc.
Referenced by Arcane::ArcaneMainBatch::execute().
|
overridevirtual |
Executable information.
Implements Arcane::IArcaneMain.
Definition at line 1169 of file ArcaneMain.cc.
|
static |
Terminates Arcane usage.
This method must be called at the end of the execution. Once called, Arcane objects must no longer be used.
The call to run() manages the initialization and the call to this method. Therefore, it is generally not necessary to call this method directly.
Removes our reference on ItemGroupImpl::shared_null.
Definition at line 730 of file ArcaneMain.cc.
References Arcane::ItemGroupImpl::_destroySharedNull(), Arcane::ItemTypeMng::_destroySingleton(), Arcane::IDynamicLibraryLoader::getDefault(), Arcane::FlexLMMng::instance(), m_is_init_done, m_nb_arcane_init, Arcane::platform::platformTerminate(), and Arcane::FlexLMMng::releaseAllLicenses().
Referenced by run().
|
static |
Initializes Arcane.
This method must be called before any use of an Arcane object. It can be called multiple times, in which case the method arcaneFinalize() must be called an equivalent number of times.
The call to run() triggers the initialization. Therefore, it is generally not necessary to call this method.
Definition at line 697 of file ArcaneMain.cc.
References Arcane::ItemGroupImpl::_buildSharedNull(), Arcane::ItemTypeMng::_singleton(), m_is_init_done, m_nb_arcane_init, Arcane::platform::platformInitialize(), Arcane::Convert::Impl::ConvertPolicy::setUseFromChars(), and Arcane::Exception::staticInit().
Referenced by run().
|
static |
Entry point of the executable in Arcane.
This method performs the following calls:
| app_info | information about the executable. |
| factory | builds architecture managers. If null, uses the factory specified by setDefaultMainFactory() otherwise a default factory is used. |
The call to this method must be preceded by Initialize();
| 0 | if the execution proceeded without error |
| 1 | in case of unknown error. |
| 2 | in case of standard exception (std::exception) |
| 3 | in case of architecture exception (IArcaneException) |
| 4 | in case of fatal error in Arcane. |
Definition at line 873 of file ArcaneMain.cc.
References _arcaneMain().
|
overridevirtual |
Constructs the class members. The instance is not usable until this method has been called. This method must be called before initialize().
Implements Arcane::IArcaneMain.
Reimplemented in Arcane::ArcaneMainBatch.
Definition at line 1157 of file ArcaneMain.cc.
Referenced by Arcane::ArcaneMainBatch::build().
|
static |
Calls the functor functor while catching possible exceptions.
The return value clean_abort is true if the code stops cleanly, meaning that all processes and threads execute the same code in parallel. This is the case, for example, if all processes detect the same error and launch, for example, a ParallelFatalErrorException. In this case, is_print indicates whether this process or thread displays the error messages. If is_print is true, the error message is displayed, otherwise it is not.
If \ a clean_abort is false, it means that one of the processes or thread stops without the others knowing, which generally results in MPI_Abort in parallel.
Definition at line 522 of file ArcaneMain.cc.
References Arcane::IArcaneMain::application(), Arcane::ITraceMng::error(), Arcane::Exception::isCollective(), Arcane::IParallelSuperMng::isMasterIO(), Arcane::IParallelSuperMng::isParallel(), Arcane::IApplication::parallelSuperMng(), and Arcane::IBase::traceMng().
|
static |
Information for accelerator initialization.
To be taken into account, this information must be modified before calling run() or rundDirect().
Definition at line 810 of file ArcaneMain.cc.
Referenced by Arcane::ArcaneLauncher::acceleratorRuntimeInitialisationInfo(), and Arcane::ArcaneMainExecInfo::initialize().
|
static |
Information for accelerator initialization.
To be taken into account, this information must be modified before calling run() or rundDirect().
Definition at line 819 of file ArcaneMain.cc.
Referenced by Arcane::ArcaneLauncher::applicationBuildInfo().
|
static |
Default application info.
This method allows retrieving the instance of ApplicationInfo which will be used when calling arcaneMain() without arguments.
Therefore, this method should generally be called before calling run().
Definition at line 792 of file ArcaneMain.cc.
Referenced by Arcane::ArcaneLauncher::applicationInfo(), and run().
|
static |
Information for .Net runtime initialization.
To be taken into account, this information must be modified before calling run().
Definition at line 801 of file ArcaneMain.cc.
Referenced by Arcane::ArcaneLauncher::dotNetRuntimeInitialisationInfo(), Arcane::ArcaneMainExecInfo::initialize(), and run().
|
overridevirtual |
Performs an abort.
Implements Arcane::IArcaneMain.
Reimplemented in Arcane::ArcaneMainBatch.
Definition at line 1236 of file ArcaneMain.cc.
|
overridevirtual |
.Net runtime initialization information.
Implements Arcane::IArcaneMain.
Definition at line 846 of file ArcaneMain.cc.
|
inlineoverridevirtual |
Execution error code.
Implements Arcane::IArcaneMain.
Definition at line 322 of file ArcaneMain.h.
Referenced by Arcane::ArcaneMainBatch::finalize().
|
overridevirtual |
Starts execution. This method only returns when the program exits.
Implements Arcane::IArcaneMain.
Reimplemented in Arcane::ArcaneMainBatch.
Definition at line 1227 of file ArcaneMain.cc.
|
inlineoverridevirtual |
Performs the last operations before instance destruction.
Implements Arcane::IArcaneMain.
Reimplemented in Arcane::ArcaneMainBatch.
Definition at line 323 of file ArcaneMain.h.
|
static |
Indicates if a '.Net' assembly is being executed from a C++ main.
Definition at line 668 of file ArcaneMain.cc.
|
inlineoverridevirtual |
Indicates that certain objects are managed via a garbage collector.
Implements Arcane::IArcaneMain.
Definition at line 335 of file ArcaneMain.h.
|
static |
Returns the time (in seconds) for the initialization of accelerator runtimes for this process.
Returns 0.0 if no accelerator runtime has been initialized.
Definition at line 864 of file ArcaneMain.cc.
Referenced by Arcane::Application::initialize().
|
overridevirtual |
Initializes the instance. The instance is not usable until this method has been called.
Implements Arcane::IArcaneMain.
Reimplemented in Arcane::ArcaneMainBatch.
Definition at line 1197 of file ArcaneMain.cc.
Referenced by Arcane::ArcaneMainBatch::initialize().
|
inlinestatic |
Definition at line 311 of file ArcaneMain.h.
|
inlineoverridevirtual |
|
overridevirtual |
Parses arguments.
Recognized arguments must be removed from the list.
| true | if execution must stop, |
| false | if it continues normally |
Implements Arcane::IArcaneMain.
Reimplemented in Arcane::ArcaneMainBatch.
Definition at line 1263 of file ArcaneMain.cc.
References application(), Arcane::CollectionBase::clear(), Arcane::CollectionBase::count(), Arcane::InternalInfosDumper::dumpArcaneDatabase(), Arcane::InternalInfosDumper::dumpInternalAllInfos(), and Arcane::String::null().
Referenced by Arcane::ArcaneMainBatch::parseArgs().
|
static |
Definition at line 230 of file ArcaneMain.cc.
|
overridevirtual |
List of registered module factories.
Implements Arcane::IArcaneMain.
Definition at line 1218 of file ArcaneMain.cc.
|
overridevirtual |
List of registered service factories.
Implements Arcane::IArcaneMain.
Definition at line 1209 of file ArcaneMain.cc.
|
static |
Entry point of the executable in Arcane.
This method calls arcaneMain(const ApplicationInfo&,IMainFactory*) using the values of defaultApplicationInfo() and the factory specified during calls to setDefaultMainFactory().
Definition at line 937 of file ArcaneMain.cc.
References arcaneFinalize(), arcaneInitialize(), Arcane::IArcaneMain::arcaneMain(), defaultApplicationInfo(), defaultDotNetRuntimeInitialisationInfo(), Arcane::platform::getEnvironmentVariable(), and Arcane::platform::hasDotNETRuntime().
Referenced by Arcane::ArcaneLauncher::run().
|
static |
Sets the default factory.
This method sets the default factory used if none is specified in the call to arcaneMain().
This method must be called before arcaneMain().
Definition at line 253 of file ArcaneMain.cc.
Referenced by Arcane::ArcaneLauncher::setDefaultMainFactory().
|
inlineoverridevirtual |
Implements Arcane::IArcaneMain.
Definition at line 336 of file ArcaneMain.h.
|
overridevirtual |
Sets the return code.
Implements Arcane::IArcaneMain.
Definition at line 1245 of file ArcaneMain.cc.
References Arcane::String::localstr().
|
static |
brief Execution functor.
This optional method allows setting a functor that will be called instead of execute(). This functor is called once the application is initialized.
Since the call to this functor replaces normal execution, only one IApplication instance is available. There is no subdomain, session, or mesh available.
Definition at line 659 of file ArcaneMain.cc.
|
static |
Indicates that we are running in the .NET runtime.
This property can only be set at the start of the calculation, before calling arcaneInitialize().
Definition at line 646 of file ArcaneMain.cc.
References m_nb_arcane_init, and Arcane::platform::setHasDotNETRuntime().
|
static |
Indicates that certain objects are managed by a garbage collector.
This property can only be set at the start of the calculation, before calling arcaneInitialize().
Definition at line 633 of file ArcaneMain.cc.
References m_nb_arcane_init.
|
static |
Definition at line 244 of file ArcaneMain.cc.
|
friend |
Definition at line 91 of file ArcaneMain.h.
|
friend |
Definition at line 92 of file ArcaneMain.h.
|
friend |
Definition at line 90 of file ArcaneMain.h.
|
private |
Definition at line 349 of file ArcaneMain.h.
|
staticprivate |
Definition at line 355 of file ArcaneMain.h.
|
private |
Definition at line 351 of file ArcaneMain.h.
|
private |
Definition at line 350 of file ArcaneMain.h.
|
staticprivate |
Definition at line 356 of file ArcaneMain.h.
|
staticprivate |
Definition at line 352 of file ArcaneMain.h.
|
staticprivate |
1 if init finished, 0 otherwise
Definition at line 366 of file ArcaneMain.h.
Referenced by arcaneFinalize(), and arcaneInitialize().
|
staticprivate |
Definition at line 353 of file ArcaneMain.h.
|
staticprivate |
Definition at line 354 of file ArcaneMain.h.
|
private |
Definition at line 348 of file ArcaneMain.h.
|
staticprivate |
Number of times arcaneInitialize() has been called.
Definition at line 364 of file ArcaneMain.h.
Referenced by arcaneFinalize(), arcaneInitialize(), setHasDotNETRuntime(), and setHasGarbageCollector().
|
private |
Definition at line 347 of file ArcaneMain.h.