Arcane  v4.1.4.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
ApplicationBuildInfo.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 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/* ApplicationBuildInfo.cc (C) 2000-2026 */
9/* */
10/* Informations pour construire une instance de IApplication. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/core/ApplicationBuildInfo.h"
15
16#include "arcane/utils/PlatformUtils.h"
17#include "arcane/utils/String.h"
18#include "arcane/utils/List.h"
19#include "arcane/utils/CommandLineArguments.h"
20#include "arcane/utils/TraceClassConfig.h"
21#include "arcane/utils/ApplicationInfo.h"
22
23#include "arcane/core/CaseDatasetSource.h"
24
25#include "arccore/common/internal/FieldProperty.h"
26#include "arccore/common/internal/ArccoreApplicationBuildInfoImpl.h"
27
28#include <functional>
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
33namespace Arcane
34{
35
36/*---------------------------------------------------------------------------*/
37/*---------------------------------------------------------------------------*/
38
39namespace
40{
41void _clamp(Int32& x,Int32 min_value,Int32 max_value)
42{
43 x = std::min(std::max(x,min_value),max_value);
44}
45}
46
47/*---------------------------------------------------------------------------*/
48/*---------------------------------------------------------------------------*/
49
51{
52 template <typename T> using FieldProperty = PropertyImpl::FieldProperty<T>;
53
54 public:
55
56 Impl()
57 : m_nb_shared_memory_sub_domain(0)
58 , m_nb_replication_sub_domain(0)
59 , m_nb_processus_sub_domain(0)
60 , m_config_file_name("")
61 {
62 // Fixe une limite en dur pour éviter d'avoir trop de sous-domaines
63 // en mémoire partagé (le maximum est en général le nombre de coeurs par
64 // noeud)
65 m_nb_shared_memory_sub_domain.setValidator([](Int32& x){ _clamp(x,0,1024); });
66 m_nb_replication_sub_domain.setValidator([](Int32& x){ x = std::max(x,0); });
67 m_nb_processus_sub_domain.setValidator([](Int32& x){ x = std::max(x,0); });
68 }
69
70 public:
71
72
73 public:
74
75 FieldProperty<String> m_message_passing_service;
76 FieldProperty<Int32> m_nb_shared_memory_sub_domain;
77 FieldProperty<Int32> m_nb_replication_sub_domain;
78 FieldProperty<Int32> m_nb_processus_sub_domain;
79 FieldProperty<String> m_config_file_name;
80 FieldProperty<Int32> m_output_level;
81 FieldProperty<Int32> m_verbosity_level;
82 FieldProperty<Int32> m_minimal_verbosity_level;
83 FieldProperty<bool> m_is_master_has_output_file;
84 FieldProperty<String> m_output_directory;
85 FieldProperty<String> m_thread_binding_strategy;
86 ApplicationInfo m_app_info;
87 CaseDatasetSource m_case_dataset_source;
88 String m_default_message_passing_service;
89
90};
91
92/*---------------------------------------------------------------------------*/
93/*---------------------------------------------------------------------------*/
94
95ApplicationBuildInfo::
96ApplicationBuildInfo()
97: m_p(new Impl())
98{
99}
100
101/*---------------------------------------------------------------------------*/
102/*---------------------------------------------------------------------------*/
103
104ApplicationBuildInfo::
105ApplicationBuildInfo(const ApplicationBuildInfo& rhs)
107, m_p(new Impl(*rhs.m_p))
108{
109}
110
111ApplicationBuildInfo& ApplicationBuildInfo::
112operator=(const ApplicationBuildInfo& rhs)
113{
114 ArccoreApplicationBuildInfo::operator=(rhs);
115 if (&rhs != this) {
116 delete m_p;
117 m_p = new Impl(*(rhs.m_p));
118 }
119 return (*this);
120}
121
122/*---------------------------------------------------------------------------*/
123/*---------------------------------------------------------------------------*/
124
125ApplicationBuildInfo::
126~ApplicationBuildInfo()
127{
128 delete m_p;
129}
130
131/*---------------------------------------------------------------------------*/
132/*---------------------------------------------------------------------------*/
133
134void ApplicationBuildInfo::
135setDefaultValues()
136{
137 ArccoreApplicationBuildInfo::setDefaultValues();
138 {
139 String str = m_core->getValue({ "ARCANE_PARALLEL_SERVICE" }, "MessagePassingService", String());
140 if (!str.null()) {
141 String service_name = str + "ParallelSuperMng";
142 PropertyImpl::checkSet(m_p->m_message_passing_service, service_name);
143 }
144 }
145 {
146 String str = m_core->getValue({ "ARCANE_NB_THREAD" }, "S", String());
147 PropertyImpl::checkSet(m_p->m_nb_shared_memory_sub_domain, str);
148 }
149 {
150 String str = m_core->getValue({ "ARCANE_NB_REPLICATION" }, "R", String());
151 PropertyImpl::checkSet(m_p->m_nb_replication_sub_domain, str);
152 }
153 {
154 String str = m_core->getValue({ "ARCANE_NB_SUB_DOMAIN" }, "P", String());
155 PropertyImpl::checkSet(m_p->m_nb_processus_sub_domain, str);
156 }
157 {
158 String str = m_core->getValue({ "ARCANE_OUTPUT_LEVEL" }, "OutputLevel",
159 String::fromNumber(Trace::UNSPECIFIED_VERBOSITY_LEVEL));
160 PropertyImpl::checkSet(m_p->m_output_level, str);
161 }
162 {
163 String str = m_core->getValue({ "ARCANE_VERBOSITY_LEVEL", "ARCANE_VERBOSE_LEVEL" }, "VerbosityLevel",
164 String::fromNumber(Trace::UNSPECIFIED_VERBOSITY_LEVEL));
165 PropertyImpl::checkSet(m_p->m_verbosity_level, str);
166 }
167 {
168 String str = m_core->getValue({}, "MinimalVerbosityLevel",
169 String::fromNumber(Trace::UNSPECIFIED_VERBOSITY_LEVEL));
170 PropertyImpl::checkSet(m_p->m_minimal_verbosity_level, str);
171 }
172 {
173 String str = m_core->getValue({ "ARCANE_MASTER_HAS_OUTPUT_FILE" }, "MasterHasOutputFile", "0");
174 PropertyImpl::checkSet(m_p->m_is_master_has_output_file, str);
175 }
176 {
177 String str = m_core->getValue({ "ARCANE_OUTPUT_DIRECTORY" }, "OutputDirectory",
178 String());
179 PropertyImpl::checkSet(m_p->m_output_directory, str);
180 }
181 {
182 String str = m_core->getValue({}, "CaseDatasetFileName",
183 String());
184 if (!str.null())
185 m_p->m_case_dataset_source.setFileName(str);
186 }
187 {
188 String str = m_core->getValue({ "ARCANE_THREAD_BINDING_STRATEGY" }, "ThreadBindingStrategy",
189 String());
190 PropertyImpl::checkSet(m_p->m_thread_binding_strategy, str);
191 }
192}
193
194/*---------------------------------------------------------------------------*/
195/*---------------------------------------------------------------------------*/
196
197void ArccoreApplicationBuildInfo::
198setDefaultServices()
199{
200 {
201 String str = m_core->getValue({ "ARCANE_TASK_IMPLEMENTATION" }, "TaskService", "TBB");
202 String service_name = str + "TaskImplementation";
203 PropertyImpl::checkSet(m_core->m_task_implementation_services, service_name);
204 }
205 {
206 StringList list1;
207 String thread_str = m_core->getValue({ "ARCANE_THREAD_IMPLEMENTATION" }, "ThreadService", "Std");
208 list1.add(thread_str+"ThreadImplementationService");
209 list1.add("TBBThreadImplementationService");
210 PropertyImpl::checkSet(m_core->m_thread_implementation_services, list1);
211 }
212}
213
214/*---------------------------------------------------------------------------*/
215/*---------------------------------------------------------------------------*/
216
217void ApplicationBuildInfo::
218setDefaultServices()
219{
220 ArccoreApplicationBuildInfo::setDefaultServices();
221 bool has_shm = nbSharedMemorySubDomain()>0;
222 {
223 String def_name = (has_shm) ? "Thread" : "Sequential";
224 String default_service_name = def_name+"ParallelSuperMng";
225 // Positionne la valeur par défaut si ce n'est pas déjà fait.
226 if (m_p->m_default_message_passing_service.null())
227 m_p->m_default_message_passing_service = default_service_name;
228 }
229}
230
231/*---------------------------------------------------------------------------*/
232/*---------------------------------------------------------------------------*/
233
234void ApplicationBuildInfo::
235setMessagePassingService(const String& name)
236{
237 m_p->m_message_passing_service = name;
238}
239
240String ApplicationBuildInfo::
241messagePassingService() const
242{
243 return m_p->m_message_passing_service;
244}
245
246/*---------------------------------------------------------------------------*/
247/*---------------------------------------------------------------------------*/
248
249void ArccoreApplicationBuildInfo::
250setTaskImplementationService(const String& name)
251{
252 StringList s;
253 s.add(name);
254 m_core->m_task_implementation_services = s;
255}
256void ArccoreApplicationBuildInfo::
257setTaskImplementationServices(const StringList& names)
258{
259 m_core->m_task_implementation_services = names;
260}
261StringList ArccoreApplicationBuildInfo::
262taskImplementationServices() const
263{
264 return m_core->m_task_implementation_services;
265}
266
267/*---------------------------------------------------------------------------*/
268/*---------------------------------------------------------------------------*/
269
270void ArccoreApplicationBuildInfo::
271setThreadImplementationService(const String& name)
272{
273 StringList s;
274 s.add(name);
275 m_core->m_thread_implementation_services = s;
276}
277void ArccoreApplicationBuildInfo::
278setThreadImplementationServices(const StringList& names)
279{
280 m_core->m_thread_implementation_services = names;
281}
282StringList ArccoreApplicationBuildInfo::
283threadImplementationServices() const
284{
285 return m_core->m_thread_implementation_services;
286}
287
288/*---------------------------------------------------------------------------*/
289/*---------------------------------------------------------------------------*/
290
291Int32 ArccoreApplicationBuildInfo::
292nbTaskThread() const
293{
294 return m_core->m_nb_task_thread;
295}
296
297/*---------------------------------------------------------------------------*/
298/*---------------------------------------------------------------------------*/
299
300void ArccoreApplicationBuildInfo::
301setNbTaskThread(Int32 v)
302{
303 m_core->m_nb_task_thread = v;
304}
305
306/*---------------------------------------------------------------------------*/
307/*---------------------------------------------------------------------------*/
308
309Int32 ApplicationBuildInfo::
310nbSharedMemorySubDomain() const
311{
312 return m_p->m_nb_shared_memory_sub_domain;
313}
314
315/*---------------------------------------------------------------------------*/
316/*---------------------------------------------------------------------------*/
317
318void ApplicationBuildInfo::
319setNbSharedMemorySubDomain(Int32 v)
320{
321 m_p->m_nb_shared_memory_sub_domain = v;
322}
323
324/*---------------------------------------------------------------------------*/
325/*---------------------------------------------------------------------------*/
326
327Int32 ApplicationBuildInfo::
328nbReplicationSubDomain() const
329{
330 return m_p->m_nb_replication_sub_domain;
331}
332
333/*---------------------------------------------------------------------------*/
334/*---------------------------------------------------------------------------*/
335
336void ApplicationBuildInfo::
337setNbReplicationSubDomain(Int32 v)
338{
339 m_p->m_nb_replication_sub_domain = v;
340}
341
342/*---------------------------------------------------------------------------*/
343/*---------------------------------------------------------------------------*/
344
345Int32 ApplicationBuildInfo::
346nbProcessusSubDomain() const
347{
348 return m_p->m_nb_processus_sub_domain;
349}
350
351/*---------------------------------------------------------------------------*/
352/*---------------------------------------------------------------------------*/
353
354void ApplicationBuildInfo::
355setNbProcessusSubDomain(Int32 v)
356{
357 m_p->m_nb_processus_sub_domain = v;
358}
359
360/*---------------------------------------------------------------------------*/
361/*---------------------------------------------------------------------------*/
362
364configFileName() const
365{
366 return m_p->m_config_file_name;
367}
368
369/*---------------------------------------------------------------------------*/
370/*---------------------------------------------------------------------------*/
371
374{
375 m_p->m_config_file_name = v;
376}
377
378/*---------------------------------------------------------------------------*/
379/*---------------------------------------------------------------------------*/
380
381Int32 ApplicationBuildInfo::
382outputLevel() const
383{
384 return m_p->m_output_level;
385}
386
389{
390 m_p->m_output_level = v;
391}
392
393/*---------------------------------------------------------------------------*/
394/*---------------------------------------------------------------------------*/
395
396Int32 ApplicationBuildInfo::
397verbosityLevel() const
398{
399 return m_p->m_verbosity_level;
400}
401
404{
405 m_p->m_verbosity_level = v;
406}
407
408/*---------------------------------------------------------------------------*/
409/*---------------------------------------------------------------------------*/
410
411Int32 ApplicationBuildInfo::
412minimalVerbosityLevel() const
413{
414 return m_p->m_minimal_verbosity_level;
415}
416
417void ApplicationBuildInfo::
418setMinimalVerbosityLevel(Int32 v)
419{
420 m_p->m_minimal_verbosity_level = v;
421}
422
423/*---------------------------------------------------------------------------*/
424/*---------------------------------------------------------------------------*/
425
426bool ApplicationBuildInfo::
427isMasterHasOutputFile() const
428{
429 return m_p->m_is_master_has_output_file;
430}
431
432void ApplicationBuildInfo::
433setIsMasterHasOutputFile(bool v)
434{
435 m_p->m_is_master_has_output_file = v;
436}
437
438/*---------------------------------------------------------------------------*/
439/*---------------------------------------------------------------------------*/
440
441String ApplicationBuildInfo::
442outputDirectory() const
443{
444 return m_p->m_output_directory;
445}
446
447/*---------------------------------------------------------------------------*/
448/*---------------------------------------------------------------------------*/
449
452{
453 m_p->m_output_directory = v;
454}
455
456/*---------------------------------------------------------------------------*/
457/*---------------------------------------------------------------------------*/
458
461{
462 return m_p->m_thread_binding_strategy;
463}
464
467{
468 m_p->m_thread_binding_strategy = v;
469}
470
471/*---------------------------------------------------------------------------*/
472/*---------------------------------------------------------------------------*/
473
474void ArccoreApplicationBuildInfo::
475addParameter(const String& name,const String& value)
476{
477 m_core->addKeyValue(name, value);
478}
479
480/*---------------------------------------------------------------------------*/
481/*---------------------------------------------------------------------------*/
482
485{
486 // On ne récupère que les arguments du style:
487 // -A,x=b,y=c
488 StringList names;
489 StringList values;
490 command_line_args.fillParameters(names,values);
491 for( Integer i=0, n=names.count(); i<n; ++i ){
492 addParameter(names[i],values[i]);
493 }
494 setDefaultValues();
495}
496
497/*---------------------------------------------------------------------------*/
498/*---------------------------------------------------------------------------*/
499
500ApplicationInfo& ApplicationBuildInfo::
501_internalApplicationInfo()
502{
503 return m_p->m_app_info;
504}
505
506/*---------------------------------------------------------------------------*/
507/*---------------------------------------------------------------------------*/
508
509const ApplicationInfo& ApplicationBuildInfo::
510_internalApplicationInfo() const
511{
512 return m_p->m_app_info;
513}
514
515/*---------------------------------------------------------------------------*/
516/*---------------------------------------------------------------------------*/
517
520{
521 m_p->m_app_info.setApplicationName(v);
522}
524applicationName() const
525{
526 return m_p->m_app_info.applicationName();
527}
528
529/*---------------------------------------------------------------------------*/
530/*---------------------------------------------------------------------------*/
531
533setCodeVersion(const VersionInfo& version_info)
534{
535 m_p->m_app_info.setCodeVersion(version_info);
536}
537
539codeVersion() const
540{
541 return m_p->m_app_info.codeVersion();
542}
543
544/*---------------------------------------------------------------------------*/
545/*---------------------------------------------------------------------------*/
546
548setCodeName(const String& code_name)
549{
550 m_p->m_app_info.setCodeName(code_name);
551}
552
554codeName() const
555{
556 return m_p->m_app_info.codeName();
557}
558
559/*---------------------------------------------------------------------------*/
560/*---------------------------------------------------------------------------*/
561
564{
565 return m_p->m_case_dataset_source;
566}
567
569caseDatasetSource() const
570{
571 return m_p->m_case_dataset_source;
572}
573
574/*---------------------------------------------------------------------------*/
575/*---------------------------------------------------------------------------*/
576
578addDynamicLibrary(const String& lib_name)
579{
580 m_p->m_app_info.addDynamicLibrary(lib_name);
581}
582
583/*---------------------------------------------------------------------------*/
584/*---------------------------------------------------------------------------*/
585
588{
589 m_p->m_default_message_passing_service = name;
590}
591
592/*---------------------------------------------------------------------------*/
593/*---------------------------------------------------------------------------*/
594
595String ApplicationBuildInfo::
596internalDefaultMessagePassingService() const
597{
598 return m_p->m_default_message_passing_service;
599}
600
601/*---------------------------------------------------------------------------*/
602/*---------------------------------------------------------------------------*/
603
604} // End namespace Arcane
605
606/*---------------------------------------------------------------------------*/
607/*---------------------------------------------------------------------------*/
608
Informations pour construire une instance de IApplication.
void setVerbosityLevel(Int32 v)
Positionne le niveau de verbosité des messages des fichiers listings réduits.
void setOutputDirectory(const String &name)
Positionne le répertoire contenant les différentes sorties de la simulation.
VersionInfo codeVersion() const
Numéro de version.
void setOutputLevel(Int32 v)
Positionne le niveau de verbosité des messages sur la sortie standard.
String configFileName() const
Nom du fichier de configuration du code.
void addDynamicLibrary(const String &lib_name)
Ajoute la bibliothèque lib_name à la liste des bibliothèques chargées dynamiquements.
void internalSetDefaultMessagePassingService(const String &name)
Nom du gestionnaire de message par défaut. Ne doit être modifié que par Arcane.
void setCodeName(const String &code_name)
Positionne le nom du code.
String applicationName() const
Nom de l'application.
void setApplicationName(const String &v)
Positionne le nom de l'application.
String codeName() const
Retourne le nom du code.
CaseDatasetSource & caseDatasetSource()
Source du jeu de données.
void setConfigFileName(const String &name)
Positionne le fichier de configuration du code.
void setCodeVersion(const VersionInfo &version_info)
Positionne le numéro de version du code.
String threadBindingStrategy() const
Stratégie pour punaiser les threads des tâches.
Informations sur une application.
void setApplicationName(const String &v)
Positionne le nom de l'application.
Informations pour initialiser une application.
void parseArgumentsAndSetDefaultsValues(const CommandLineArguments &args)
Analyse les arguments de args.
Source d'un jeu de données d'un cas.
Integer count() const
Nombre d'éléments de la collection.
void fillParameters(StringList &param_names, StringList &values) const
Récupère la liste des paramètres et leur valeur.
Chaîne de caractères unicode.
Informations sur une version.
Definition VersionInfo.h:46
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 Integer
Type représentant un entier.
List< String > StringList
Tableau de chaînes de caractères unicode.
Definition UtilsTypes.h:509
std::int32_t Int32
Type entier signé sur 32 bits.