Arcane  v4.1.3.0
Documentation développeur
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
27#include <functional>
28
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32namespace Arcane
33{
34
35/*---------------------------------------------------------------------------*/
36/*---------------------------------------------------------------------------*/
37
38namespace
39{
40void _clamp(Int32& x,Int32 min_value,Int32 max_value)
41{
42 x = std::min(std::max(x,min_value),max_value);
43}
44}
45
46/*---------------------------------------------------------------------------*/
47/*---------------------------------------------------------------------------*/
48
50{
51 public:
52
53 template <typename T> using FieldProperty = PropertyImpl::FieldProperty<T>;
54
55 CoreImpl()
56 : m_nb_task_thread(-1)
57 {
58 // Fixe une limite pour le nombre de tâches
59 m_nb_task_thread.setValidator([](Int32& x) { _clamp(x, -1, 512); });
60 }
61
62 public:
63
64 String getValue(const UniqueArray<String>& env_values, const String& param_name,
65 const String& default_value)
66 {
67 return m_property_key_values.getValue(env_values, param_name, default_value);
68 }
69 void addKeyValue(const String& name, const String& value)
70 {
71 m_property_key_values.add(name, value);
72 }
73
74 public:
75
76 FieldProperty<StringList> m_task_implementation_services;
77 FieldProperty<StringList> m_thread_implementation_services;
78 FieldProperty<Int32> m_nb_task_thread;
79
80 private:
81
82 PropertyImpl::PropertyKeyValues m_property_key_values;
83};
84
85/*---------------------------------------------------------------------------*/
86/*---------------------------------------------------------------------------*/
87
89{
90 template <typename T> using FieldProperty = PropertyImpl::FieldProperty<T>;
91
92 public:
93
94 Impl()
95 : m_nb_shared_memory_sub_domain(0)
96 , m_nb_replication_sub_domain(0)
97 , m_nb_processus_sub_domain(0)
98 , m_config_file_name("")
99 {
100 // Fixe une limite en dur pour éviter d'avoir trop de sous-domaines
101 // en mémoire partagé (le maximum est en général le nombre de coeurs par
102 // noeud)
103 m_nb_shared_memory_sub_domain.setValidator([](Int32& x){ _clamp(x,0,1024); });
104 m_nb_replication_sub_domain.setValidator([](Int32& x){ x = std::max(x,0); });
105 m_nb_processus_sub_domain.setValidator([](Int32& x){ x = std::max(x,0); });
106 }
107
108 public:
109
110
111 public:
112
113 FieldProperty<String> m_message_passing_service;
114 FieldProperty<Int32> m_nb_shared_memory_sub_domain;
115 FieldProperty<Int32> m_nb_replication_sub_domain;
116 FieldProperty<Int32> m_nb_processus_sub_domain;
117 FieldProperty<String> m_config_file_name;
118 FieldProperty<Int32> m_output_level;
119 FieldProperty<Int32> m_verbosity_level;
120 FieldProperty<Int32> m_minimal_verbosity_level;
121 FieldProperty<bool> m_is_master_has_output_file;
122 FieldProperty<String> m_output_directory;
123 FieldProperty<String> m_thread_binding_strategy;
124 ApplicationInfo m_app_info;
125 CaseDatasetSource m_case_dataset_source;
126 String m_default_message_passing_service;
127
128};
129
130/*---------------------------------------------------------------------------*/
131/*---------------------------------------------------------------------------*/
132
133ApplicationCoreBuildInfo::
134ApplicationCoreBuildInfo()
135: m_core(new CoreImpl())
136{
137}
138
139ApplicationCoreBuildInfo::
140ApplicationCoreBuildInfo(const ApplicationCoreBuildInfo& rhs)
141: m_core(new CoreImpl(*rhs.m_core))
142{
143}
144
145ApplicationCoreBuildInfo& ApplicationCoreBuildInfo::
146operator=(const ApplicationCoreBuildInfo& rhs)
147{
148 if (&rhs != this) {
149 delete m_core;
150 m_core = new CoreImpl(*(rhs.m_core));
151 }
152 return (*this);
153}
154
155ApplicationCoreBuildInfo::
156~ApplicationCoreBuildInfo()
157{
158 delete m_core;
159}
160
161/*---------------------------------------------------------------------------*/
162/*---------------------------------------------------------------------------*/
163
164ApplicationBuildInfo::
165ApplicationBuildInfo()
166: m_p(new Impl())
167{
168}
169
170/*---------------------------------------------------------------------------*/
171/*---------------------------------------------------------------------------*/
172
173ApplicationBuildInfo::
174ApplicationBuildInfo(const ApplicationBuildInfo& rhs)
175: ApplicationCoreBuildInfo(rhs)
176, m_p(new Impl(*rhs.m_p))
177{
178}
179
180ApplicationBuildInfo& ApplicationBuildInfo::
181operator=(const ApplicationBuildInfo& rhs)
182{
183 ApplicationCoreBuildInfo::operator=(rhs);
184 if (&rhs != this) {
185 delete m_p;
186 m_p = new Impl(*(rhs.m_p));
187 }
188 return (*this);
189}
190
191/*---------------------------------------------------------------------------*/
192/*---------------------------------------------------------------------------*/
193
194ApplicationBuildInfo::
195~ApplicationBuildInfo()
196{
197 delete m_p;
198}
199
200/*---------------------------------------------------------------------------*/
201/*---------------------------------------------------------------------------*/
202
203void ApplicationCoreBuildInfo::
204setDefaultValues()
205{
206 {
207 String str = m_core->getValue({ "ARCANE_NB_TASK" }, "T", String());
208 PropertyImpl::checkSet(m_core->m_nb_task_thread, str);
209 }
210}
211
212/*---------------------------------------------------------------------------*/
213/*---------------------------------------------------------------------------*/
214
215void ApplicationBuildInfo::
216setDefaultValues()
217{
218 ApplicationCoreBuildInfo::setDefaultValues();
219 {
220 String str = m_core->getValue({ "ARCANE_NB_THREAD" }, "S", String());
221 PropertyImpl::checkSet(m_p->m_nb_shared_memory_sub_domain, str);
222 }
223 {
224 String str = m_core->getValue({ "ARCANE_NB_REPLICATION" }, "R", String());
225 PropertyImpl::checkSet(m_p->m_nb_replication_sub_domain, str);
226 }
227 {
228 String str = m_core->getValue({ "ARCANE_NB_SUB_DOMAIN" }, "P", String());
229 PropertyImpl::checkSet(m_p->m_nb_processus_sub_domain, str);
230 }
231 {
232 String str = m_core->getValue({ "ARCANE_OUTPUT_LEVEL" }, "OutputLevel",
233 String::fromNumber(Trace::UNSPECIFIED_VERBOSITY_LEVEL));
234 PropertyImpl::checkSet(m_p->m_output_level, str);
235 }
236 {
237 String str = m_core->getValue({ "ARCANE_VERBOSITY_LEVEL", "ARCANE_VERBOSE_LEVEL" }, "VerbosityLevel",
238 String::fromNumber(Trace::UNSPECIFIED_VERBOSITY_LEVEL));
239 PropertyImpl::checkSet(m_p->m_verbosity_level, str);
240 }
241 {
242 String str = m_core->getValue({}, "MinimalVerbosityLevel",
243 String::fromNumber(Trace::UNSPECIFIED_VERBOSITY_LEVEL));
244 PropertyImpl::checkSet(m_p->m_minimal_verbosity_level, str);
245 }
246 {
247 String str = m_core->getValue({ "ARCANE_MASTER_HAS_OUTPUT_FILE" }, "MasterHasOutputFile", "0");
248 PropertyImpl::checkSet(m_p->m_is_master_has_output_file, str);
249 }
250 {
251 String str = m_core->getValue({ "ARCANE_OUTPUT_DIRECTORY" }, "OutputDirectory",
252 String());
253 PropertyImpl::checkSet(m_p->m_output_directory, str);
254 }
255 {
256 String str = m_core->getValue({}, "CaseDatasetFileName",
257 String());
258 if (!str.null())
259 m_p->m_case_dataset_source.setFileName(str);
260 }
261 {
262 String str = m_core->getValue({ "ARCANE_THREAD_BINDING_STRATEGY" }, "ThreadBindingStrategy",
263 String());
264 PropertyImpl::checkSet(m_p->m_thread_binding_strategy, str);
265 }
266}
267
268/*---------------------------------------------------------------------------*/
269/*---------------------------------------------------------------------------*/
270
271void ApplicationCoreBuildInfo::
272setDefaultServices()
273{
274 {
275 String str = m_core->getValue({ "ARCANE_TASK_IMPLEMENTATION" }, "TaskService", "TBB");
276 String service_name = str + "TaskImplementation";
277 PropertyImpl::checkSet(m_core->m_task_implementation_services, service_name);
278 }
279 {
280 StringList list1;
281 String thread_str = m_core->getValue({ "ARCANE_THREAD_IMPLEMENTATION" }, "ThreadService", "Std");
282 list1.add(thread_str+"ThreadImplementationService");
283 list1.add("TBBThreadImplementationService");
284 PropertyImpl::checkSet(m_core->m_thread_implementation_services, list1);
285 }
286}
287
288/*---------------------------------------------------------------------------*/
289/*---------------------------------------------------------------------------*/
290
291void ApplicationBuildInfo::
292setDefaultServices()
293{
294 ApplicationCoreBuildInfo::setDefaultServices();
295 bool has_shm = nbSharedMemorySubDomain()>0;
296 {
297 String def_name = (has_shm) ? "Thread" : "Sequential";
298 String default_service_name = def_name+"ParallelSuperMng";
299 // Positionne la valeur par défaut si ce n'est pas déjà fait.
300 if (m_p->m_default_message_passing_service.null())
301 m_p->m_default_message_passing_service = default_service_name;
302
303 String str = m_core->getValue({ "ARCANE_PARALLEL_SERVICE" }, "MessagePassingService", String());
304 if (!str.null()) {
305 String service_name = str + "ParallelSuperMng";
306 PropertyImpl::checkSet(m_p->m_message_passing_service, service_name);
307 }
308 }
309}
310
311/*---------------------------------------------------------------------------*/
312/*---------------------------------------------------------------------------*/
313
314void ApplicationBuildInfo::
315setMessagePassingService(const String& name)
316{
317 m_p->m_message_passing_service = name;
318}
319
320String ApplicationBuildInfo::
321messagePassingService() const
322{
323 return m_p->m_message_passing_service;
324}
325
326/*---------------------------------------------------------------------------*/
327/*---------------------------------------------------------------------------*/
328
329void ApplicationCoreBuildInfo::
330setTaskImplementationService(const String& name)
331{
332 StringList s;
333 s.add(name);
334 m_core->m_task_implementation_services = s;
335}
336void ApplicationCoreBuildInfo::
337setTaskImplementationServices(const StringList& names)
338{
339 m_core->m_task_implementation_services = names;
340}
341StringList ApplicationCoreBuildInfo::
342taskImplementationServices() const
343{
344 return m_core->m_task_implementation_services;
345}
346
347/*---------------------------------------------------------------------------*/
348/*---------------------------------------------------------------------------*/
349
350void ApplicationCoreBuildInfo::
351setThreadImplementationService(const String& name)
352{
353 StringList s;
354 s.add(name);
355 m_core->m_thread_implementation_services = s;
356}
357void ApplicationCoreBuildInfo::
358setThreadImplementationServices(const StringList& names)
359{
360 m_core->m_thread_implementation_services = names;
361}
362StringList ApplicationCoreBuildInfo::
363threadImplementationServices() const
364{
365 return m_core->m_thread_implementation_services;
366}
367
368/*---------------------------------------------------------------------------*/
369/*---------------------------------------------------------------------------*/
370
371Int32 ApplicationCoreBuildInfo::
372nbTaskThread() const
373{
374 return m_core->m_nb_task_thread;
375}
376
377/*---------------------------------------------------------------------------*/
378/*---------------------------------------------------------------------------*/
379
380void ApplicationCoreBuildInfo::
381setNbTaskThread(Int32 v)
382{
383 m_core->m_nb_task_thread = v;
384}
385
386/*---------------------------------------------------------------------------*/
387/*---------------------------------------------------------------------------*/
388
389Int32 ApplicationBuildInfo::
390nbSharedMemorySubDomain() const
391{
392 return m_p->m_nb_shared_memory_sub_domain;
393}
394
395/*---------------------------------------------------------------------------*/
396/*---------------------------------------------------------------------------*/
397
398void ApplicationBuildInfo::
399setNbSharedMemorySubDomain(Int32 v)
400{
401 m_p->m_nb_shared_memory_sub_domain = v;
402}
403
404/*---------------------------------------------------------------------------*/
405/*---------------------------------------------------------------------------*/
406
407Int32 ApplicationBuildInfo::
408nbReplicationSubDomain() const
409{
410 return m_p->m_nb_replication_sub_domain;
411}
412
413/*---------------------------------------------------------------------------*/
414/*---------------------------------------------------------------------------*/
415
416void ApplicationBuildInfo::
417setNbReplicationSubDomain(Int32 v)
418{
419 m_p->m_nb_replication_sub_domain = v;
420}
421
422/*---------------------------------------------------------------------------*/
423/*---------------------------------------------------------------------------*/
424
425Int32 ApplicationBuildInfo::
426nbProcessusSubDomain() const
427{
428 return m_p->m_nb_processus_sub_domain;
429}
430
431/*---------------------------------------------------------------------------*/
432/*---------------------------------------------------------------------------*/
433
434void ApplicationBuildInfo::
435setNbProcessusSubDomain(Int32 v)
436{
437 m_p->m_nb_processus_sub_domain = v;
438}
439
440/*---------------------------------------------------------------------------*/
441/*---------------------------------------------------------------------------*/
442
444configFileName() const
445{
446 return m_p->m_config_file_name;
447}
448
449/*---------------------------------------------------------------------------*/
450/*---------------------------------------------------------------------------*/
451
454{
455 m_p->m_config_file_name = v;
456}
457
458/*---------------------------------------------------------------------------*/
459/*---------------------------------------------------------------------------*/
460
461Int32 ApplicationBuildInfo::
462outputLevel() const
463{
464 return m_p->m_output_level;
465}
466
469{
470 m_p->m_output_level = v;
471}
472
473/*---------------------------------------------------------------------------*/
474/*---------------------------------------------------------------------------*/
475
476Int32 ApplicationBuildInfo::
477verbosityLevel() const
478{
479 return m_p->m_verbosity_level;
480}
481
484{
485 m_p->m_verbosity_level = v;
486}
487
488/*---------------------------------------------------------------------------*/
489/*---------------------------------------------------------------------------*/
490
491Int32 ApplicationBuildInfo::
492minimalVerbosityLevel() const
493{
494 return m_p->m_minimal_verbosity_level;
495}
496
497void ApplicationBuildInfo::
498setMinimalVerbosityLevel(Int32 v)
499{
500 m_p->m_minimal_verbosity_level = v;
501}
502
503/*---------------------------------------------------------------------------*/
504/*---------------------------------------------------------------------------*/
505
506bool ApplicationBuildInfo::
507isMasterHasOutputFile() const
508{
509 return m_p->m_is_master_has_output_file;
510}
511
512void ApplicationBuildInfo::
513setIsMasterHasOutputFile(bool v)
514{
515 m_p->m_is_master_has_output_file = v;
516}
517
518/*---------------------------------------------------------------------------*/
519/*---------------------------------------------------------------------------*/
520
521String ApplicationBuildInfo::
522outputDirectory() const
523{
524 return m_p->m_output_directory;
525}
526
527/*---------------------------------------------------------------------------*/
528/*---------------------------------------------------------------------------*/
529
532{
533 m_p->m_output_directory = v;
534}
535
536/*---------------------------------------------------------------------------*/
537/*---------------------------------------------------------------------------*/
538
541{
542 return m_p->m_thread_binding_strategy;
543}
544
547{
548 m_p->m_thread_binding_strategy = v;
549}
550
551/*---------------------------------------------------------------------------*/
552/*---------------------------------------------------------------------------*/
553
554void ApplicationCoreBuildInfo::
555addParameter(const String& name,const String& value)
556{
557 m_core->addKeyValue(name, value);
558}
559
560/*---------------------------------------------------------------------------*/
561/*---------------------------------------------------------------------------*/
562
565{
566 // On ne récupère que les arguments du style:
567 // -A,x=b,y=c
568 StringList names;
569 StringList values;
570 command_line_args.fillParameters(names,values);
571 for( Integer i=0, n=names.count(); i<n; ++i ){
572 addParameter(names[i],values[i]);
573 }
574 setDefaultValues();
575}
576
577/*---------------------------------------------------------------------------*/
578/*---------------------------------------------------------------------------*/
579
580ApplicationInfo& ApplicationBuildInfo::
581_internalApplicationInfo()
582{
583 return m_p->m_app_info;
584}
585
586/*---------------------------------------------------------------------------*/
587/*---------------------------------------------------------------------------*/
588
589const ApplicationInfo& ApplicationBuildInfo::
590_internalApplicationInfo() const
591{
592 return m_p->m_app_info;
593}
594
595/*---------------------------------------------------------------------------*/
596/*---------------------------------------------------------------------------*/
597
600{
601 m_p->m_app_info.setApplicationName(v);
602}
604applicationName() const
605{
606 return m_p->m_app_info.applicationName();
607}
608
609/*---------------------------------------------------------------------------*/
610/*---------------------------------------------------------------------------*/
611
613setCodeVersion(const VersionInfo& version_info)
614{
615 m_p->m_app_info.setCodeVersion(version_info);
616}
617
619codeVersion() const
620{
621 return m_p->m_app_info.codeVersion();
622}
623
624/*---------------------------------------------------------------------------*/
625/*---------------------------------------------------------------------------*/
626
628setCodeName(const String& code_name)
629{
630 m_p->m_app_info.setCodeName(code_name);
631}
632
634codeName() const
635{
636 return m_p->m_app_info.codeName();
637}
638
639/*---------------------------------------------------------------------------*/
640/*---------------------------------------------------------------------------*/
641
644{
645 return m_p->m_case_dataset_source;
646}
647
649caseDatasetSource() const
650{
651 return m_p->m_case_dataset_source;
652}
653
654/*---------------------------------------------------------------------------*/
655/*---------------------------------------------------------------------------*/
656
658addDynamicLibrary(const String& lib_name)
659{
660 m_p->m_app_info.addDynamicLibrary(lib_name);
661}
662
663/*---------------------------------------------------------------------------*/
664/*---------------------------------------------------------------------------*/
665
668{
669 m_p->m_default_message_passing_service = name;
670}
671
672/*---------------------------------------------------------------------------*/
673/*---------------------------------------------------------------------------*/
674
675String ApplicationBuildInfo::
676internalDefaultMessagePassingService() const
677{
678 return m_p->m_default_message_passing_service;
679}
680
681/*---------------------------------------------------------------------------*/
682/*---------------------------------------------------------------------------*/
683
684} // End namespace Arcane
685
686/*---------------------------------------------------------------------------*/
687/*---------------------------------------------------------------------------*/
688
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 pour initialiser une application.
void parseArgumentsAndSetDefaultsValues(const CommandLineArguments &args)
Analyse les arguments de args.
Informations sur une application.
void setApplicationName(const String &v)
Positionne le nom de l'application.
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.
Vecteur 1D de données avec sémantique par valeur (style STL).
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.