14#include "arcane/launcher/ArcaneLauncher.h"
16#include "arcane/launcher/IDirectExecutionContext.h"
17#include "arcane/launcher/DirectSubDomainExecutionContext.h"
18#include "arcane/launcher/GeneralHelp.h"
19#include "arcane/launcher/internal/ParamFile.h"
21#include "arcane/utils/FatalErrorException.h"
22#include "arcane/utils/PlatformUtils.h"
23#include "arcane/utils/JSONReader.h"
24#include "arcane/utils/Exception.h"
25#include "arcane/utils/ParameterList.h"
26#include "arcane/utils/Ref.h"
28#include "arcane/utils/internal/ParallelLoopOptionsProperties.h"
29#include "arcane/utils/internal/ApplicationInfoProperties.h"
30#include "arcane/core/internal/DotNetRuntimeInitialisationInfoProperties.h"
31#include "arcane/accelerator/core/internal/AcceleratorRuntimeInitialisationInfoProperties.h"
33#include "arccore/common/internal/Property.h"
34#include "arccore/common/internal/ParameterListPropertyReader.h"
35#include "arccore/common/internal/JSONPropertyReader.h"
37#include "arcane/impl/ArcaneMain.h"
38#include "arcane/impl/ArcaneSimpleExecutor.h"
40#include "arcane/core/IDirectSubDomainExecuteFunctor.h"
55 bool global_has_init_done =
false;
56 bool _checkInitCalled()
58 if (!global_has_init_done) {
59 std::cerr <<
"ArcaneLauncher::init() has to be called before";
70class DirectExecutionContextImpl
76 : m_simple_exec(simple_exec)
87 return m_simple_exec->createSubDomain(case_file_name);
89 ISubDomain* subDomain()
const {
return nullptr; }
93 ArcaneSimpleExecutor* m_simple_exec;
99void _checkReadConfigFile(
StringView config_file_name)
102 if (config_file_name.empty())
104 std::cout <<
"TRY_READING_CONFIG " << config_file_name <<
"\n";
112 app_info.setRuntimeConfigFileContent(bytes);
118 std::cout <<
"READING CONFIG\n";
119 properties::readFromJSON<ApplicationInfo, ApplicationInfoProperties>(config, app_info);
181class DirectCodeFunctor
192 : m_simple_executor(x)
196 : m_simple_executor(x)
204 m_return_value = (*m_functor)(direct_context);
206 else if (m_old_functor)
207 m_return_value = (*m_old_functor)(&direct_context_impl);
209 int returnValue()
const {
return m_return_value; }
213 ArcaneSimpleExecutor* m_simple_executor =
nullptr;
214 OldFunctorType* m_old_functor =
nullptr;
215 FunctorType* m_functor =
nullptr;
216 int m_return_value = 0;
225 if (_checkInitCalled())
227 int final_return = 0;
230 int r = simple_exec.initialize();
237 simple_exec.runCode(&direct_functor);
238 final_return = direct_functor.returnValue();
249 if (_checkInitCalled())
252 int final_return = 0;
255 int r = simple_exec.initialize();
262 simple_exec.runCode(&direct_functor);
263 final_return = direct_functor.returnValue();
271class ArcaneLauncherDirectExecuteFunctor
285 ARCANE_FATAL(
"Can not execute 'IDirectSubDomainExecuteFunctor' without sub domain");
287 return m_function(direct_context);
306 if (_checkInitCalled())
316 if (config_file.
empty())
318 int r = ArcaneMain::_internalRun(&direct_exec);
342 _listPropertySettings()
344 using namespace Arcane::properties;
345 MyVisitor my_visitor;
346 visitAllRegisteredProperties(&my_visitor);
354 if (global_has_init_done)
355 ARCANE_FATAL(
"ArcaneLauncher::init() has already been called");
356 global_has_init_done =
true;
358 application_info.setCommandLineArguments(args);
359 bool do_list =
false;
361 _listPropertySettings();
364 if (!runtime_config_file_name.
empty())
365 _checkReadConfigFile(runtime_config_file_name);
368 if (!param_file_name.
empty()) {
370 ParamFile::editParams(param_file_name, variation_param_file_name);
374 properties::readFromParameterList<ApplicationInfo, ApplicationInfoProperties>(args.
parameters(), application_info);
376 properties::readFromParameterList<DotNetRuntimeInitialisationInfo, DotNetRuntimeInitialisationInfoProperties>(args.
parameters(), dotnet_info);
378 properties::readFromParameterList<AcceleratorRuntimeInitialisationInfo, Accelerator::AcceleratorRuntimeInitialisationInfoProperties>(args.
parameters(), accelerator_info);
380 properties::readFromParameterList<ParallelLoopOptions, ParallelLoopOptionsProperties>(args.
parameters(), loop_options);
385 cerr <<
"** (ArcaneLauncher) Can't continue with the execution.\n";
396 return global_has_init_done;
414 if (!global_has_init_done)
415 ARCANE_FATAL(
"ArcaneLauncher::init() has to be called before");
418 ArcaneMain::_initRuntimes();
438 StandaloneSubDomain s;
439 s._initUniqueInstance(case_file_name, file_content);
447_notifyRemoveStandaloneSubDomain()
467 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, Span< const std::byte > file_content={})
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, Int16 flags=ParseNoFlags)
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.
View of an array of elements of type T.
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 --