14#include "arcane/launcher/ArcaneLauncher.h"
16#include "arcane/launcher/IDirectExecutionContext.h"
17#include "arcane/launcher/DirectSubDomainExecutionContext.h"
18#include "arcane/launcher/GeneralHelp.h"
20#include "arcane/utils/FatalErrorException.h"
21#include "arcane/utils/PlatformUtils.h"
22#include "arcane/utils/JSONReader.h"
23#include "arcane/utils/Exception.h"
24#include "arcane/utils/ParameterList.h"
25#include "arcane/utils/Ref.h"
27#include "arcane/utils/internal/ParallelLoopOptionsProperties.h"
28#include "arcane/utils/internal/ApplicationInfoProperties.h"
29#include "arcane/core/internal/DotNetRuntimeInitialisationInfoProperties.h"
30#include "arcane/accelerator/core/internal/AcceleratorRuntimeInitialisationInfoProperties.h"
32#include "arccore/common/internal/Property.h"
33#include "arccore/common/internal/ParameterListPropertyReader.h"
34#include "arccore/common/internal/JSONPropertyReader.h"
36#include "arcane/impl/ArcaneMain.h"
37#include "arcane/impl/ArcaneSimpleExecutor.h"
39#include "arcane/core/IDirectSubDomainExecuteFunctor.h"
54 bool global_has_init_done =
false;
55 bool _checkInitCalled()
57 if (!global_has_init_done) {
58 std::cerr <<
"ArcaneLauncher::init() has to be called before";
69class DirectExecutionContextImpl
75 : m_simple_exec(simple_exec)
86 return m_simple_exec->createSubDomain(case_file_name);
88 ISubDomain* subDomain()
const {
return nullptr; }
92 ArcaneSimpleExecutor* m_simple_exec;
98void _checkReadConfigFile(
StringView config_file_name)
101 if (config_file_name.empty())
103 std::cout <<
"TRY_READING_CONFIG " << config_file_name <<
"\n";
111 app_info.setRuntimeConfigFileContent(bytes);
117 std::cout <<
"READING CONFIG\n";
118 properties::readFromJSON<ApplicationInfo, ApplicationInfoProperties>(config, app_info);
180class DirectCodeFunctor
191 : m_simple_executor(x)
195 : m_simple_executor(x)
203 m_return_value = (*m_functor)(direct_context);
205 else if (m_old_functor)
206 m_return_value = (*m_old_functor)(&direct_context_impl);
208 int returnValue()
const {
return m_return_value; }
212 ArcaneSimpleExecutor* m_simple_executor =
nullptr;
213 OldFunctorType* m_old_functor =
nullptr;
214 FunctorType* m_functor =
nullptr;
215 int m_return_value = 0;
224 if (_checkInitCalled())
226 int final_return = 0;
229 int r = simple_exec.initialize();
236 simple_exec.runCode(&direct_functor);
237 final_return = direct_functor.returnValue();
248 if (_checkInitCalled())
251 int final_return = 0;
254 int r = simple_exec.initialize();
261 simple_exec.runCode(&direct_functor);
262 final_return = direct_functor.returnValue();
270class ArcaneLauncherDirectExecuteFunctor
284 ARCANE_FATAL(
"Can not execute 'IDirectSubDomainExecuteFunctor' without sub domain");
286 return m_function(direct_context);
305 if (_checkInitCalled())
315 if (config_file.
empty())
317 int r = ArcaneMain::_internalRun(&direct_exec);
341 _listPropertySettings()
343 using namespace Arcane::properties;
344 MyVisitor my_visitor;
345 visitAllRegisteredProperties(&my_visitor);
353 if (global_has_init_done)
354 ARCANE_FATAL(
"ArcaneLauncher::init() has already been called");
355 global_has_init_done =
true;
357 application_info.setCommandLineArguments(args);
358 bool do_list =
false;
360 _listPropertySettings();
363 if (!runtime_config_file_name.
empty())
364 _checkReadConfigFile(runtime_config_file_name);
365 properties::readFromParameterList<ApplicationInfo, ApplicationInfoProperties>(args.
parameters(), application_info);
367 properties::readFromParameterList<DotNetRuntimeInitialisationInfo, DotNetRuntimeInitialisationInfoProperties>(args.
parameters(), dotnet_info);
369 properties::readFromParameterList<AcceleratorRuntimeInitialisationInfo, Accelerator::AcceleratorRuntimeInitialisationInfoProperties>(args.
parameters(), accelerator_info);
371 properties::readFromParameterList<ParallelLoopOptions, ParallelLoopOptionsProperties>(args.
parameters(), loop_options);
376 cerr <<
"** (ArcaneLauncher) Can't continue with the execution.\n";
387 return global_has_init_done;
405 if (!global_has_init_done)
406 ARCANE_FATAL(
"ArcaneLauncher::init() has to be called before");
409 ArcaneMain::_initRuntimes();
429 StandaloneSubDomain s;
430 s._initUniqueInstance(case_file_name);
438_notifyRemoveStandaloneSubDomain()
458 GeneralHelp::printHelp();
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Classes, Types, and macros for managing concurrency.
Information for accelerator initialization.
Information for constructing an instance of IApplication.
String configFileName() const
Name of the code configuration file.
void setConfigFileName(const String &name)
Sets the code configuration file.
const CommandLineArguments & commandLineArguments() const
Command line arguments.
int execute() override
Executes the functor's operation.
void setSubDomain(ISubDomain *sd) override
Positions the associated subdomain. This method must be called before execute().
static StandaloneAcceleratorMng createStandaloneAcceleratorMng()
Creates a standalone implementation to manage accelerators.
static int run()
Entry point of the executable in Arcane.
static String getExeDirectory()
Full name of the directory where the executable is located.
static DotNetRuntimeInitialisationInfo & dotNetRuntimeInitialisationInfo()
Information for '.Net' runtime initialization.
static bool needHelp()
Requests help with the "--help" or "-h" option.
static void init(const CommandLineArguments &args)
Positions information from command-line arguments and initializes the launcher.
static ApplicationBuildInfo & applicationBuildInfo()
Application execution parameter information.
static StandaloneSubDomain createStandaloneSubDomain(const String &case_file_name)
Creates a standalone implementation to manage a subdomain.
static bool isInitialized()
Indicates if init() has already been called.
static bool printHelp()
Display of generic Arcane help.
static ApplicationInfo & applicationInfo()
Application information.
static AcceleratorRuntimeInitialisationInfo & acceleratorRuntimeInitialisationInfo()
Information for accelerator initialization.
static int runDirect(std::function< int(IDirectExecutionContext *)> func)
static void setDefaultMainFactory(IMainFactory *mf)
Positions the default factory for creating the different managers.
static ApplicationBuildInfo & defaultApplicationBuildInfo()
Information for accelerator initialization.
static AcceleratorRuntimeInitialisationInfo & defaultAcceleratorRuntimeInitialisationInfo()
Information for accelerator initialization.
static DotNetRuntimeInitialisationInfo & defaultDotNetRuntimeInitialisationInfo()
Information for .Net runtime initialization.
static int run()
Entry point of the executable in Arcane.
static ApplicationInfo & defaultApplicationInfo()
Default application info.
static void setDefaultMainFactory(IMainFactory *mf)
Sets the default factory.
Class for directly executing code without going through the time loop.
const ParameterList & parameters() const
List of parameters.
bool needHelp() const
Method to determine if the user requested help on the command line.
String getParameter(const String ¶m_name) const
Retrieves the parameter with name param_name.
void executeFunctor() override
Executes the associated method.
ISubDomain * createSequentialSubDomain(const String &case_file_name) override
Create a sequential sub-domain with the dataset file named case_file_name.
ISubDomain * createSequentialSubDomain() override
Create a sequential sub-domain without a dataset.
Direct execution context.
Direct execution context with subdomain creation.
Information for the initialization of the '.Net' runtime.
Base class for an exception.
Implementation of the execution management class.
Interface of a functor to execute code directly after the creation of a subdomain without going throu...
Factory for Arcane classes.
Interface of the subdomain manager.
Management of a JSON document.
void parse(Span< const Byte > bytes)
Reads the file in UTF-8 format.
JSONValue child(StringView name) const
Child value with name name. Returns a null value if not found.
Execution options for a parallel loop in multi-threading.
Standalone implementation of 'IAcceleratorMng.h'.
View of a UTF-8 character string.
Unicode character string.
bool null() const
Returns true if the string is null.
bool empty() const
True if the string is empty (null or "").
static void setDefaultParallelLoopOptions(const ParallelLoopOptions &v)
Sets the default parallel loop execution options.
1D data vector with value semantics (STL style).
Property parameter interface.
virtual String description() const =0
Property description.
virtual String commandLineArgument() const =0
Command line argument name (null if none).
Property visitor interface.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --