Arcane  4.2.3.0
Developer documentation
Loading...
Searching...
No Matches
SubDomain.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/* SubDomain.cc (C) 2000-2025 */
9/* */
10/* Subdomain manager. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/StdHeader.h"
15#include "arcane/utils/PlatformUtils.h"
16#include "arcane/utils/Iostream.h"
17#include "arcane/utils/ScopedPtr.h"
18#include "arcane/utils/VersionInfo.h"
19#include "arcane/utils/StringBuilder.h"
20#include "arcane/utils/ITraceMng.h"
21#include "arcane/utils/TraceAccessor.h"
22#include "arcane/utils/MemoryInfo.h"
23#include "arcane/utils/List.h"
24#include "arcane/utils/TraceAccessor2.h"
25#include "arcane/utils/ValueConvert.h"
26#include "arcane/utils/IProcessorAffinityService.h"
27#include "arcane/utils/IProfilingService.h"
28#include "arccore/common/internal/Property.h"
29
30#include "arcane/core/ISubDomain.h"
31#include "arcane/core/IVariableMng.h"
32#include "arcane/core/IModuleMng.h"
33#include "arcane/core/IServiceMng.h"
34#include "arcane/core/IModule.h"
35#include "arcane/core/IModuleMaster.h"
36#include "arcane/core/IEntryPointMng.h"
37#include "arcane/core/IEntryPoint.h"
38#include "arcane/core/IMeshReader.h"
39#include "arcane/core/ITimerMng.h"
40#include "arcane/core/IApplication.h"
41#include "arcane/core/IGhostLayerMng.h"
42#include "arcane/core/ArcaneException.h"
43#include "arcane/core/CaseOptionsMain.h"
44#include "arcane/core/IMesh.h"
45#include "arcane/core/IMeshModifier.h"
46#include "arcane/core/IMeshSubMeshTransition.h"
47#include "arcane/core/Properties.h"
48#include "arcane/core/IParallelMng.h"
49#include "arcane/core/Directory.h"
50#include "arcane/core/ITimeHistoryMng.h"
51#include "arcane/core/ICaseMng.h"
52#include "arcane/core/ICheckpointMng.h"
53#include "arcane/core/IPropertyMng.h"
54#include "arcane/core/ITimeStats.h"
55#include "arcane/core/ITimeLoop.h"
56#include "arcane/core/ITimeLoopMng.h"
57#include "arcane/core/IIOMng.h"
58#include "arcane/core/IMainFactory.h"
59#include "arcane/core/Timer.h"
60#include "arcane/core/XmlNode.h"
61#include "arcane/core/ICaseDocument.h"
62#include "arcane/core/IPhysicalUnitSystem.h"
63#include "arcane/core/IPhysicalUnitSystemService.h"
64#include "arcane/core/ISession.h"
65#include "arcane/core/IMeshStats.h"
66#include "arcane/core/IParallelReplication.h"
67#include "arcane/core/IServiceLoader.h"
68#include "arcane/core/IMeshPartitioner.h"
69#include "arcane/core/ICaseMeshMasterService.h"
70#include "arcane/core/ILoadBalanceMng.h"
71#include "arcane/core/CaseNodeNames.h"
72#include "arcane/core/Observable.h"
73#include "arcane/core/VariableCollection.h"
74#include "arcane/core/SubDomainBuildInfo.h"
75#include "arcane/core/ServiceBuilder.h"
76#include "arcane/core/IMeshUtilities.h"
77#include "arcane/core/IMeshMng.h"
78#include "arcane/core/MeshHandle.h"
79#include "arcane/core/ObserverPool.h"
80#include "arcane/core/parallel/IStat.h"
81
82#include "arcane/core/internal/ConfigurationPropertyReader.h"
83#include "arcane/core/internal/IDataInternal.h"
84#include "arcane/core/internal/ICaseMngInternal.h"
85#include "arcane/core/internal/IParallelMngInternal.h"
86#include "arcane/core/internal/IVariableMngInternal.h"
87
88#include "arcane/impl/ConfigurationReader.h"
89#include "arcane/impl/internal/MeshMng.h"
90#include "arcane/impl/internal/LegacyMeshBuilder.h"
91
92#include "arcane/core/CaseOptionService.h"
93#include "arcane/core/CaseOptionBuildInfo.h"
94
95#include "arcane/accelerator/core/IAcceleratorMng.h"
96#include "arcane/accelerator/core/DeviceInfo.h"
97#include "arcane/accelerator/core/Runner.h"
98#include "arcane/accelerator/core/AcceleratorRuntimeInitialisationInfo.h"
99#include "arcane/accelerator/core/IDeviceInfoList.h"
100
101/*---------------------------------------------------------------------------*/
102/*---------------------------------------------------------------------------*/
103
104namespace Arcane
105{
106
107/*---------------------------------------------------------------------------*/
108/*---------------------------------------------------------------------------*/
109
110class MeshBuilderMaster
111{
112 public:
113
114 MeshBuilderMaster(ICaseMng* cm, const String& default_name)
115 : m_case_options(new Arcane::CaseOptions(cm, "."))
116 , m_mesh_service(CaseOptionBuildInfo(_configList(), "meshes", XmlNode(), default_name, 1, 1), false, false)
117 {
118 m_mesh_service.addAlternativeNodeName("fr", "maillages");
119 }
120
121 private:
122
123 Arcane::ICaseOptionList* _configList() const
124 {
125 return m_case_options->configList();
126 }
127
128 public:
129
130 ICaseOptions* options() const { return m_case_options.get(); }
131
132 public:
133
134 void createMeshes()
135 {
136 m_mesh_service.instance()->createMeshes();
137 }
138
139 private:
140
141 ReferenceCounter<ICaseOptions> m_case_options;
143};
144
145/*---------------------------------------------------------------------------*/
146/*---------------------------------------------------------------------------*/
147
153class SubDomain
154: public ISubDomain
156{
157 ARCANE_DECLARE_PROPERTY_CLASS(SubDomain);
158
159 public:
160
162 class PropertyMngCheckpoint
163 : public TraceAccessor
164 {
165 public:
166
167 explicit PropertyMngCheckpoint(ISubDomain* sd)
168 : TraceAccessor(sd->traceMng())
169 , m_sub_domain(sd)
170 , m_property_values(VariableBuildInfo(sd, "ArcaneProperties", IVariable::PPrivate))
171 {
172 init();
173 }
174
175 public:
176
177 void init()
178 {
179 m_observers.addObserver(this,
180 &PropertyMngCheckpoint::_notifyWrite,
181 m_property_values.variable()->writeObservable());
182 m_observers.addObserver(this,
183 &PropertyMngCheckpoint::_notifyRead,
184 m_property_values.variable()->readObservable());
185 }
186
187 private:
188
189 void _notifyRead()
190 {
191 info(4) << "PropertyMngCheckpoint: READ";
192 m_sub_domain->propertyMng()->readFrom(m_property_values);
193 }
194 void _notifyWrite()
195 {
196 info(4) << "PropertyMngCheckpoint: WRITE";
197 m_sub_domain->propertyMng()->writeTo(m_property_values._internalTrueData()->_internalDeprecatedValue());
198 m_property_values.variable()->syncReferences();
199 }
200
201 private:
202
203 ISubDomain* m_sub_domain;
204 ObserverPool m_observers;
205 VariableArrayByte m_property_values;
206 };
207
208 public:
209
210 SubDomain(ISession*, Ref<IParallelMng>, Ref<IParallelMng>, const String& filename, ByteConstArrayView bytes);
211
212 public:
213
214 void build() override;
215 void initialize() override;
216 void destroy() override;
217
218 public:
219
220 IBase* objectParent() const override { return m_application; }
221 String objectNamespaceURI() const override { return m_namespace_uri; }
222 String objectLocalName() const override { return m_local_name; }
223 VersionInfo objectVersion() const override { return VersionInfo(1, 0, 0); }
224
225 public:
226
227 IMainFactory* mainFactory() override { return m_application->mainFactory(); }
228 ISession* session() const override { return m_session; }
229 IServiceMng* serviceMng() const override { return m_service_mng.get(); }
230 ITimeLoopMng* timeLoopMng() override { return m_time_loop_mng.get(); }
231 IIOMng* ioMng() override { return m_io_mng.get(); }
232 IVariableMng* variableMng() override { return m_variable_mng.get(); }
233 IModuleMng* moduleMng() override { return m_module_mng.get(); }
234 IEntryPointMng* entryPointMng() override { return m_entry_point_mng.get(); }
235 ICaseMng* caseMng() override { return m_case_mng.get(); }
236 ITimerMng* timerMng() const override { return m_timer_mng; }
237 ICheckpointMng* checkpointMng() const override { return m_checkpoint_mng.get(); }
238 IPropertyMng* propertyMng() const override { return m_property_mng.get(); }
239 ITimeStats* timeStats() const override { return m_time_stats; }
240 IRessourceMng* ressourceMng() const override { return m_application->ressourceMng(); }
241 ITraceMng* traceMng() const override { return TraceAccessor::traceMng(); }
242 IMemoryInfo* memoryInfo() const override { return m_memory_info.get(); }
244 ILoadBalanceMng* loadBalanceMng() override { return m_lb_mng.get(); }
245 IMeshMng* meshMng() const override { return m_mesh_mng.get(); }
246 IModuleMaster* moduleMaster() const override { return m_module_master; }
247 const IConfiguration* configuration() const override { return m_configuration.get(); }
248 IConfiguration* configuration() override { return m_configuration.get(); }
249 IAcceleratorMng* acceleratorMng() override { return m_accelerator_mng.get(); }
250
251 Int32 subDomainId() const override { return m_parallel_mng->commRank(); }
252 Int32 nbSubDomain() const override { return m_parallel_mng->commSize(); }
253 void setIsContinue() override { m_is_continue = true; }
254 bool isContinue() const override { return m_is_continue; }
255 void dumpInfo(std::ostream&) override;
256 void doInitModules() override;
257 void doExitModules() override;
258 IMesh* defaultMesh() override { return m_default_mesh_handle.mesh(); }
259 const MeshHandle& defaultMeshHandle() override { return m_default_mesh_handle; }
260 IMesh* mesh() override { return m_default_mesh_handle.mesh(); }
261 IMesh* findMesh(const String& name, bool throw_exception) override;
262 bool isInitialized() const override { return m_is_initialized; }
263 void setIsInitialized() override;
264 const ApplicationInfo& applicationInfo() const override { return m_application->applicationInfo(); }
265 ICaseDocument* caseDocument() override { return m_case_mng->caseDocument(); }
266 IApplication* application() override { return m_application; }
267 void checkId(const String& where, const String& id) override;
268 const String& caseFullFileName() const override { return m_case_full_file_name; }
269 void setCaseFullFileName(const String& file_name) { m_case_full_file_name = file_name; }
270 const String& caseName() const override { return m_case_name; }
271 void fillCaseBytes(ByteArray& bytes) const override { bytes.copy(m_case_bytes); }
272 void setCaseName(const String& case_name) override { m_case_name = case_name; }
273 void setInitialPartitioner(IInitialPartitioner* partitioner) override
274 {
275 m_legacy_mesh_builder->m_initial_partitioner = partitioner;
276 }
277 void readCaseMeshes() override;
278 void allocateMeshes() override;
279 void readOrReloadMeshes() override;
281 void doInitMeshPartition() override;
282 void addMesh(IMesh* mesh) override;
283 ConstArrayView<IMesh*> meshes() const override;
284 const CaseOptionsMain* caseOptionsMain() const override { return m_case_config; }
285 IParallelMng* parallelMng() override { return m_parallel_mng.get(); }
287 IThreadMng* threadMng() override { return m_parallel_mng->threadMng(); }
288 const IDirectory& exportDirectory() const override { return m_export_directory; }
289 void setExportDirectory(const IDirectory& dir) override { m_export_directory = dir; }
290 const IDirectory& storageDirectory() const override { return m_storage_directory; }
291 void setStorageDirectory(const IDirectory& dir) override { m_storage_directory = dir; }
292 const IDirectory& listingDirectory() const override { return m_listing_directory; }
293 void setListingDirectory(const IDirectory& dir) override { m_listing_directory = dir; }
295 const CommonVariables& variablesCommon() const { return commonVariables(); }
296 const CommonVariables& commonVariables() const override;
297 void dumpInternalInfos(XmlNode& root) override;
298 Integer meshDimension() const override;
300 IDirectExecution* directExecution() const override { return m_direct_execution; }
301 void setDirectExecution(IDirectExecution* v) override { m_direct_execution = v; }
302
303 public:
304
305 void _setLegacyMeshCreation(bool v) { m_is_create_default_mesh_v2 = !v; }
306 bool isLegacyMeshCreation() const { return !m_is_create_default_mesh_v2; }
307
308 public:
309 protected:
310
311 const char* _msgClassName() const { return "Init"; }
312
313 private:
314
332 String m_namespace_uri;
333 String m_local_name;
336 ScopedPtrT<MeshMng> m_mesh_mng;
337 MeshHandle m_default_mesh_handle;
347 bool m_is_continue;
348 IDirectExecution* m_direct_execution;
351 bool m_is_create_default_mesh_v2;
352 ScopedPtrT<PropertyMngCheckpoint> m_property_mng_checkpoint;
353 ScopedPtrT<LegacyMeshBuilder> m_legacy_mesh_builder;
355 bool m_has_mesh_service = false;
356 Ref<ICaseMeshMasterService> m_case_mesh_master_service;
357 ObserverPool m_observers;
358 Ref<IAcceleratorMng> m_accelerator_mng;
359
360 private:
361
362 void _doInitialPartition();
363 void _doInitialPartitionForMesh(IMesh* mesh, const String& service_name);
364 void _notifyWriteCheckpoint();
365 void _printCPUAffinity();
366 void _setDefaultAcceleratorDevice(Accelerator::AcceleratorRuntimeInitialisationInfo& config);
367};
368
369/*---------------------------------------------------------------------------*/
370/*---------------------------------------------------------------------------*/
371
372static ISubDomain* global_sub_domain = nullptr;
373
374/* HP: ARCANE_IMPL_EXPORT pending finding a solution
375 * to access traces outside of a service or module */
376extern "C" ARCANE_IMPL_EXPORT ISubDomain* _arcaneGetDefaultSubDomain()
377{
378 return global_sub_domain;
379}
380
381/*---------------------------------------------------------------------------*/
382/*---------------------------------------------------------------------------*/
383
384extern "C++" ISubDomain*
385arcaneCreateSubDomain(ISession* session, const SubDomainBuildInfo& sdbi)
386{
387 Ref<IParallelMng> pm = sdbi.parallelMng();
388 Ref<IParallelMng> all_replica_pm = sdbi.allReplicaParallelMng();
389 String case_file_name = sdbi.caseFileName();
390 ByteConstArrayView bytes = sdbi.caseBytes();
391
392 ITraceMng* tm = pm->traceMng();
393 StringBuilder trace_id;
394 trace_id += String::fromNumber(pm->commRank());
395 if (all_replica_pm != pm) {
396 trace_id += ",r";
397 trace_id += pm->replication()->replicationRank();
398 }
399 trace_id += ",";
400 trace_id += platform::getHostName();
401 tm->setTraceId(trace_id.toString());
402
403 auto* sd = new SubDomain(session, pm, all_replica_pm, case_file_name, bytes);
404 sd->build();
405 //GG: init is done by the caller
406 //mng->initialize();
407 global_sub_domain = sd;
408 return sd;
409}
410
411/*---------------------------------------------------------------------------*/
412/*---------------------------------------------------------------------------*/
413
414SubDomain::
415SubDomain(ISession* session, Ref<IParallelMng> pm, Ref<IParallelMng> all_replica_pm,
416 const String& case_file_name, ByteConstArrayView bytes)
417: TraceAccessor2(pm->traceMng())
418, m_session(session)
419, m_application(session->application())
420, m_parallel_mng(pm)
421, m_all_replica_parallel_mng(all_replica_pm)
422, m_timer_mng(nullptr)
423, m_time_stats(nullptr)
424, m_namespace_uri(arcaneNamespaceURI())
425, m_module_master(nullptr)
426, m_time_history_mng(nullptr)
427, m_is_initialized(false)
428, m_case_full_file_name(case_file_name)
429, m_case_name("unknown")
430, m_case_bytes(bytes)
431, m_case_config(nullptr)
432, m_storage_directory(".")
433, m_is_continue(false)
434, m_direct_execution(nullptr)
435, m_is_create_default_mesh_v2(false)
436{
437 m_local_name = "SubDomain";
438 m_memory_info = new MemoryInfo();
439}
440
441/*---------------------------------------------------------------------------*/
442/*---------------------------------------------------------------------------*/
443
444// This call must be made from a critical section.
446build()
447{
448 IMainFactory* mf = m_application->mainFactory();
449 m_physical_unit_system = m_application->getPhysicalUnitSystemService()->createStandardUnitSystem();
450 m_configuration = m_application->configurationMng()->defaultConfiguration()->clone();
451
452 m_accelerator_mng = mf->createAcceleratorMngRef(traceMng());
456 m_mesh_mng = new MeshMng(m_application, m_variable_mng.get());
457 m_default_mesh_handle = m_mesh_mng->createDefaultMeshHandle("Mesh0");
460 m_module_mng = mf->createModuleMng(this);
462 m_case_mng = mf->createCaseMng(this)->toReference();
463 m_timer_mng = m_parallel_mng->timerMng();
464 m_time_stats = m_parallel_mng->timeStats();
466 m_legacy_mesh_builder = new LegacyMeshBuilder(this, m_default_mesh_handle);
467}
468
469/*---------------------------------------------------------------------------*/
470/*---------------------------------------------------------------------------*/
471
474{
475 namespace ax = Arcane::Accelerator;
476 // Initialization of the parallel module
477 // TODO: to be removed as it is no longer useful
478 m_parallel_mng->initialize();
479
480 {
481 // Initializes the default runner based on the parameters
482 // provided by the user.
483 IApplication* app = application();
485 _setDefaultAcceleratorDevice(config);
486
487 m_accelerator_mng->initialize(config);
488 Runner runner = m_accelerator_mng->runner();
489 const auto& device_info = runner.deviceInfo();
490 info() << "DeviceInfo: name=" << device_info.name();
491 info() << "DeviceInfo: description=" << device_info.description();
492
493 if (isAcceleratorPolicy(runner.executionPolicy())) {
494 m_parallel_mng->_internalApi()->setDefaultRunner(runner);
495 m_all_replica_parallel_mng->_internalApi()->setDefaultRunner(runner);
496 }
497 m_variable_mng->_internalApi()->setAcceleratorMng(m_accelerator_mng);
498 }
499
501
502 IMainFactory* mf = m_application->mainFactory();
503
504 m_time_loop_mng->build();
505
506 m_has_mesh_service = false;
507
508 // Reads the dataset.
509 // This is only to ensure the syntactic validity
510 // of the dataset. Options are not read.
511 // This must be done before mesh creation
512 // because the mesh instance depends on the dataset.
513 ICaseDocument* case_document = nullptr;
514 if (!m_case_bytes.empty()) {
515 case_document = m_case_mng->readCaseDocument(m_case_full_file_name, m_case_bytes);
516 if (!case_document)
517 ARCANE_FATAL("Can not read case options");
518 // Adds to the configuration those present in the dataset.
519 {
521 cr.addValuesFromXmlNode(case_document->configurationElement(), ConfigurationReader::P_CaseDocument);
522 }
523 }
524
525 properties::readFromConfiguration(m_configuration.get(), *this);
526
527 if (case_document) {
528 // Checks if there is a <meshes> tag indicating that the creation and
529 // reading of the mesh will be managed by a service
530 XmlNode meshes_elem = case_document->meshesElement();
531 if (!meshes_elem.null()) {
532 info() << "Using mesh service to create and allocate meshes";
533 m_has_mesh_service = true;
534 }
535 // TODO: in this case, check that we do not have the historical 'mesh' element.
536 }
537 // Creates the default mesh. It must be done before the creation
538 // of services, as the latter may need it.
540 if (!m_is_create_default_mesh_v2)
541 m_legacy_mesh_builder->createDefaultMesh();
542
544 service_loader->loadSubDomainServices(this);
545
546 // The master module must always be created before the others so that
547 // its entry points are called first and last
550
551 service_loader->initializeModuleFactories(this);
552 m_lb_mng = mf->createLoadBalanceMng(this);
553
554 m_property_mng_checkpoint = new PropertyMngCheckpoint(this);
555
556 m_observers.addObserver(this,
557 &SubDomain::_notifyWriteCheckpoint,
558 m_checkpoint_mng->writeObservable());
559}
560
561/*---------------------------------------------------------------------------*/
562/*---------------------------------------------------------------------------*/
563
564void SubDomain::
565_setDefaultAcceleratorDevice(Accelerator::AcceleratorRuntimeInitialisationInfo& config)
566{
567 // Choice of accelerator to use
568 // If multiple accelerators are available, one must be chosen by default.
569 // We assume that all nodes have the same number of accelerators.
570 // In this case, we take the i-th available accelerator as the default,
571 // with \a i chosen as our rank modulo the number of available accelerators on
572 // the node.
573 // NOTE: this works well if we use a single process per accelerator.
574 // If we use more, we should rather take consecutive ranks for
575 // the same accelerator.
576 // TODO: Also look into how to rather use the accelerator closest
577 // to our rank. For this, we would need to use libraries like HWLOC
578 //
579 auto* device_list = Runner::deviceInfoList(config.executionPolicy());
580
581 Int32 modulo_device = 0;
582 if (device_list) {
583 Int32 nb_device = device_list->nbDevice();
584 info() << "DeviceInfo: nb_device=" << nb_device;
585 modulo_device = nb_device;
586 }
587
588 // TODO: do this elsewhere
589 if (auto v = Convert::Type<Int32>::tryParseFromEnvironment("ARCANE_ACCELERATOR_PARALLELMNG_RANK_FOR_DEVICE", true)) {
590 Int32 modulo = v.value();
591 if (modulo == 0)
592 modulo = 1;
593 modulo_device = modulo;
594 info() << "Use commRank() to choose accelerator device with modulo=" << modulo;
595 }
596 if (modulo_device != 0) {
597 Int32 device_rank = m_parallel_mng->commRank() % modulo_device;
598 info() << "Using device number=" << device_rank;
599 config.setDeviceId(Accelerator::DeviceId(device_rank));
600 }
601}
602
603/*---------------------------------------------------------------------------*/
604/*---------------------------------------------------------------------------*/
605
606void SubDomain::
607destroy()
608{
609 m_case_mesh_master_service.reset();
610
611 m_property_mng_checkpoint = nullptr;
612
613 m_on_destroy_observable.notifyAllObservers();
614 m_on_destroy_observable.detachAllObservers();
615
617
618 // Normally we should be able to remove this test because there should no longer
619 // be any references to services or modules. This is the case
620 // with the 'coreclr' implementation but not with 'mono'. So we
621 // leave this test for now.
622 // Starting from version 3.7.8, most potential GC issues are
623 // fixed, so it is not necessary to return directly. Nevertheless
624 // there are still problems with the use of 'ICaseFunction'.
625 // We therefore keep the possibility of changing the behavior if an environment
626 // variable is set.
627 if (m_application->hasGarbageCollector()) {
628 bool do_return = true;
629 String x = platform::getEnvironmentVariable("ARCANE_DOTNET_USE_LEGACY_DESTROY");
630 if (x == "1")
631 do_return = true;
632 if (x == "0")
633 do_return = false;
634 if (do_return)
635 return;
636 }
637
638 m_module_master = nullptr;
639
640 m_module_mng->removeAllModules();
641 m_service_mng = nullptr;
642 m_time_history_mng = nullptr;
643 m_mesh_mng->destroyMeshes();
644
645 m_time_loop_mng = nullptr;
646 m_case_mng.reset();
647 m_entry_point_mng = nullptr;
648 m_module_mng = nullptr;
649 m_io_mng = nullptr;
650
651 m_lb_mng = nullptr;
652 m_property_mng.reset();
653
654 // Since all objects may contain variables, we must be
655 // certain to destroy the variable manager last.
656 m_variable_mng->_internalApi()->removeAllVariables();
657 m_variable_mng = nullptr;
658
659 delete this;
660}
661
662/*---------------------------------------------------------------------------*/
663/*---------------------------------------------------------------------------*/
664
666dumpInfo(std::ostream& o)
667{
668 m_module_mng->dumpList(o);
669}
670
671/*---------------------------------------------------------------------------*/
672/*---------------------------------------------------------------------------*/
673
674/*---------------------------------------------------------------------------*/
675/*---------------------------------------------------------------------------*/
676
685{
686 info() << "SubDomain: Allocating meshes";
688
689 Timer::Action ts_action2(this, "AllocateMesh");
690 Trace::Setter mci(traceMng(), _msgClassName());
691
692 if (m_has_mesh_service) {
693 info() << "** Reading mesh from mesh service";
694 const CaseNodeNames* cnn = caseMng()->caseDocument()->caseNodeNames();
695 String default_service_name = "ArcaneCaseMeshMasterService";
696
697 // NOTE: this object will be destroyed by caseMng()
698 ICaseOptions* opt = new CaseOptions(caseMng(), cnn->meshes);
700 Ref<ICaseMeshMasterService> mbm = sb.createReference(default_service_name);
701 m_case_mesh_master_service = mbm;
702 m_case_mng->_internalImpl()->internalReadOneOption(mbm->_options(), true);
703 mbm->createMeshes();
704 }
705 else {
706 if (m_is_create_default_mesh_v2)
707 m_legacy_mesh_builder->createDefaultMesh();
708
709 m_legacy_mesh_builder->allocateMeshes();
710 }
711}
712
713/*---------------------------------------------------------------------------*/
714/*---------------------------------------------------------------------------*/
715
718{
719 info() << "SubDomain: read or reload meshes";
721 logdate() << "Initialisation du code.";
722
723 Integer nb_mesh = m_mesh_mng->meshes().size();
724 info() << " nb_mesh_created=" << nb_mesh
725 << " is_continue?=" << m_is_continue;
726
727 A_INFO("Test: {1}", A_TR2("nb_mesh_created", nb_mesh), A_TR(m_is_continue));
728
729 //info() << format4("Test: {1}",{A_PR2("nb_mesh_created",nb_mesh),A_PR(m_is_continue)});
730 //info() << format5(A_PR2("nb_mesh_created",nb_mesh),A_PR(m_is_continue));
731
732 // Checks if profiling is enabled during initialization
733 IProfilingService* ps = nullptr;
734 if (auto v = Convert::Type<Int32>::tryParseFromEnvironment("ARCANE_PROFILE_CREATE_MESH", true))
735 if (v.value() != 0)
737
738 // Stop the profiling if it is already running.
739 if (ps && ps->isRunning())
740 ps->stopProfiling();
741 {
742 ProfilingSentryWithInitialize ps_sentry(ps);
743 ps_sentry.setPrintAtEnd(true);
744
745 if (m_is_continue) {
746 for (Integer z = 0; z < nb_mesh; ++z) {
747 IPrimaryMesh* mesh = m_mesh_mng->getPrimaryMesh(z);
748 mesh->reloadMesh();
749 }
750 }
751 else {
752 if (m_has_mesh_service) {
753 m_case_mesh_master_service->allocateMeshes();
754 }
755 else
756 m_legacy_mesh_builder->readMeshes();
757 }
758 }
759
760 //warning() << "CODE CHANGED IN DEV-X10. NEED TEST";
761 //mesh->computeTiedInterfaces(mbi.m_xml_node);
763 // mesh->readAmrActivator(mbi.m_xml_node);
764
765 // Checks mesh consistency
766 for (Integer z = 0; z < nb_mesh; ++z) {
767 IMesh* mesh = m_mesh_mng->getMesh(z);
768 mesh->checkValidMesh();
769 mesh->nodesCoordinates().setUpToDate();
770 }
771}
772
773/*---------------------------------------------------------------------------*/
774/*---------------------------------------------------------------------------*/
775
777addMesh(IMesh* mesh)
778{
779 m_mesh_mng->addMesh(mesh);
780}
781
782/*---------------------------------------------------------------------------*/
783/*---------------------------------------------------------------------------*/
784
786meshes() const
787{
788 return m_mesh_mng->meshes();
789}
790
791/*---------------------------------------------------------------------------*/
792/*---------------------------------------------------------------------------*/
793
796{
798 m_legacy_mesh_builder->initializeMeshVariablesFromCaseFile();
799}
800
801/*---------------------------------------------------------------------------*/
802/*---------------------------------------------------------------------------*/
803
806{
807 if (!m_is_continue) {
808 IInitialPartitioner* init_part = m_legacy_mesh_builder->m_initial_partitioner.get();
809 if (init_part) {
810 info() << "Using custom initial partitioner";
811 init_part->partitionAndDistributeMeshes(m_mesh_mng->meshes());
812 }
813 else {
814 if (m_case_mesh_master_service.get()) {
815 m_case_mesh_master_service->partitionMeshes();
816 m_case_mesh_master_service->applyAdditionalOperationsOnMeshes();
817 }
818 else if (m_legacy_mesh_builder->m_use_internal_mesh_partitioner)
819 _doInitialPartition();
820 }
821 }
822
823 // Display mesh information
824 for (IMesh* mesh : m_mesh_mng->meshes()) {
825 Ref<IMeshStats> mh(IMeshStats::create(traceMng(), mesh));
826 mh->dumpStats();
827 }
828}
829
830/*---------------------------------------------------------------------------*/
831/*---------------------------------------------------------------------------*/
832
838{
839}
840
841/*---------------------------------------------------------------------------*/
842/*---------------------------------------------------------------------------*/
843
844void SubDomain::
845_doInitialPartition()
846{
847 // NOTE: This code is only used by the historical mesh creation mechanism.
848 // When meshes are used for services, the corresponding code is in ArcaneCaseMeshService.
849
850 String test_service = "MeshPartitionerTester";
851
852 for (IMesh* mesh : m_mesh_mng->meshes()) {
853 bool is_mesh_allocated = mesh->isAllocated();
854 info() << "InitialPartitioning mesh=" << mesh->name() << " is_allocated?=" << is_mesh_allocated;
855 if (!is_mesh_allocated)
856 continue;
857 // Since 'parmetis' does not like repartitioning a mesh if one of the sub-domains
858 // is empty (which is the case if only one processor created the cells),
859 // we must first use the basic partitioner which distributes the cells
860 // among the sub-domains, and then 'parmetis' if it is present
861 if (m_legacy_mesh_builder->m_use_partitioner_tester) {
862 Int64 nb_cell = mesh->nbCell();
863 Int64 min_nb_cell = parallelMng()->reduce(Parallel::ReduceMin, nb_cell);
864 info() << "Min nb cell=" << min_nb_cell;
865 if (min_nb_cell == 0)
866 _doInitialPartitionForMesh(mesh, test_service);
867 else
868 info() << "Mesh name=" << mesh->name() << " have cells. Do not use " << test_service;
869 }
870 else
871 info() << "No basic partition first needed";
872 _doInitialPartitionForMesh(mesh, m_legacy_mesh_builder->m_internal_partitioner_name);
873 }
874}
875
876/*---------------------------------------------------------------------------*/
877/*---------------------------------------------------------------------------*/
878
879void SubDomain::
880_doInitialPartitionForMesh(IMesh* mesh, const String& service_name)
881{
882 info() << "DoInitialPartition. mesh=" << mesh->name() << " service=" << service_name;
883
884 String lib_name = service_name;
885 IMeshPartitionerBase* mesh_partitioner_base = nullptr;
886 Ref<IMeshPartitionerBase> mesh_partitioner_base_ref;
887 Ref<IMeshPartitioner> mesh_partitioner_ref;
888
889 ServiceBuilder<IMeshPartitionerBase> sbuilder(this);
890 mesh_partitioner_base_ref = sbuilder.createReference(service_name, mesh, SB_AllowNull);
891 mesh_partitioner_base = mesh_partitioner_base_ref.get();
892
893 if (!mesh_partitioner_base) {
894 // If not found, search with the old interface 'IMeshPartitioner' for
895 // compatibility reasons
896 pwarning() << "No implementation for 'IMeshPartitionerBase' interface found. "
897 << "Searching implementation for legacy 'IMeshPartitioner' interface";
898 ServiceBuilder<IMeshPartitioner> sbuilder_legacy(this);
899 mesh_partitioner_ref = sbuilder_legacy.createReference(service_name, mesh, SB_AllowNull);
900 if (mesh_partitioner_ref.get())
901 mesh_partitioner_base = mesh_partitioner_ref.get();
902 }
903
904 if (!mesh_partitioner_base) {
905 // If not found, retrieve the list of possible values and display them.
906 StringUniqueArray valid_names;
907 sbuilder.getServicesNames(valid_names);
908 String valid_values = String::join(", ", valid_names);
909 String msg = String::format("The specified service for the initial mesh partitionment ({0}) "
910 "is not available (valid_values={1}). This service has to implement "
911 "interface Arcane::IMeshPartitionerBase",
912 lib_name, valid_values);
913 ARCANE_THROW(ParallelFatalErrorException, msg);
914 }
915
916 bool is_dynamic = mesh->isDynamic();
917 mesh->modifier()->setDynamic(true);
918 mesh->utilities()->partitionAndExchangeMeshWithReplication(mesh_partitioner_base, true);
919 mesh->modifier()->setDynamic(is_dynamic);
920}
921
922/*---------------------------------------------------------------------------*/
923/*---------------------------------------------------------------------------*/
924
927{
928 if (!m_is_initialized)
929 ARCANE_FATAL("Uninitialized session");
930
931 logdate() << "Execution of the end of compute entry points";
932
933 // Save history manager data if requested
934 if (caseOptionsMain()->doTimeHistory())
935 m_time_history_mng->dumpHistory(true);
936
937 m_time_loop_mng->execExitEntryPoints();
938
939 m_parallel_mng->printStats();
940
941 traceMng()->flush();
942}
943
944/*---------------------------------------------------------------------------*/
945/*---------------------------------------------------------------------------*/
946
948checkId(const String& where, const String& id)
949{
950 Int64 len = id.length();
951 const char* str = id.localstr();
952 if (len == 0 || !str)
953 throw BadIDException(where, id);
954
955 if (!isalpha(str[0]))
956 throw BadIDException(where, id);
957 for (Int64 i = 1; i < len; ++i)
958 if (!isalpha(str[i]) && !isdigit(str[i]) && str[i] != '_' && str[i] != '.' && str[i] != '-')
959 throw BadIDException(where, id);
960}
961
962/*---------------------------------------------------------------------------*/
963/*---------------------------------------------------------------------------*/
964
967{
968 Trace::Setter mci(traceMng(), _msgClassName());
969
970 info() << "Reading the case `" << m_case_full_file_name << "'";
971
972 ICaseDocument* case_doc = caseDocument();
973 if (!case_doc)
974 ARCANE_FATAL("No input data");
975
976 m_legacy_mesh_builder->readCaseMeshes();
977 m_case_config = m_module_master->caseoptions();
978}
979
980/*---------------------------------------------------------------------------*/
981/*---------------------------------------------------------------------------*/
982
984commonVariables() const
985{
986 if (!m_module_master)
987 throw BadReferenceException("module master in SubDomain::variablesCommon()");
988 return *m_module_master->commonVariables();
989}
990
991/*---------------------------------------------------------------------------*/
992/*---------------------------------------------------------------------------*/
993
996{
997 // Info about the time loop used.
998 {
999 ITimeLoopMng* tlm = timeLoopMng();
1000 ITimeLoop* time_loop = tlm->usedTimeLoop();
1001 XmlElement time_loop_elem(root, "timeloopinfo");
1002 XmlElement title(time_loop_elem, "title", time_loop->title());
1003 XmlElement description(time_loop_elem, "description", time_loop->description());
1004
1005 String ustr_userclass("userclass");
1006 for (StringCollection::Enumerator j(time_loop->userClasses()); ++j;)
1007 XmlElement elem(time_loop_elem, ustr_userclass, *j);
1008 }
1009
1010 VariableRefList var_ref_list;
1011 XmlElement modules(root, "modules");
1012
1013 String ustr_module("module");
1014 String ustr_name("name");
1015 String ustr_activated("activated");
1016 String ustr_true("true");
1017 String ustr_false("false");
1018 String ustr_variable("variable");
1019 String ustr_variable_ref("variable-ref");
1020 String ustr_ref("ref");
1021 String ustr_datatype("datatype");
1022 String ustr_dimension("dimension");
1023 String ustr_kind("kind");
1024 String ustr_caseblock("caseblock");
1025 String ustr_tagname("tagname");
1026
1027 // List of modules with the variables they use.
1028 for (ModuleCollection::Enumerator i(moduleMng()->modules()); ++i;) {
1029 XmlElement module_element(modules, ustr_module);
1030 module_element.setAttrValue(ustr_name, (*i)->name());
1031 bool is_activated = (*i)->used();
1032 module_element.setAttrValue(ustr_activated, is_activated ? ustr_true : ustr_false);
1033 var_ref_list.clear();
1034 variableMng()->variables(var_ref_list, *i);
1035 for (VariableRefList::Enumerator j(var_ref_list); ++j;) {
1036 XmlElement variable_element(module_element, ustr_variable_ref);
1037 variable_element.setAttrValue(ustr_ref, (*j)->name());
1038 }
1039 }
1040
1041 // List of variables.
1042 XmlElement variables(root, "variables");
1043 VariableCollection var_prv_list = variableMng()->variables();
1044 for (VariableCollection::Enumerator j(var_prv_list); ++j;) {
1045 XmlElement elem(variables, ustr_variable);
1046 IVariable* var = *j;
1047 String dim = String::fromNumber(var->dimension());
1048 elem.setAttrValue(ustr_name, var->name());
1049 elem.setAttrValue(ustr_datatype, dataTypeName(var->dataType()));
1050 elem.setAttrValue(ustr_dimension, dim);
1051 elem.setAttrValue(ustr_kind, itemKindName(var->itemKind()));
1052 }
1053
1054 // List of option blocks
1055 const ICaseMng* cm = caseMng();
1056 CaseOptionsCollection blocks = cm->blocks();
1057 XmlElement blocks_elem(root, "caseblocks");
1058 for (CaseOptionsCollection::Enumerator i(blocks); ++i;) {
1059 const ICaseOptions* block = *i;
1060 XmlElement block_elem(blocks_elem, ustr_caseblock);
1061 block_elem.setAttrValue(ustr_tagname, block->rootTagName());
1062 const IModule* block_module = block->caseModule();
1063 if (block_module)
1064 block_elem.setAttrValue(ustr_module, block_module->name());
1065 }
1066}
1067
1068/*---------------------------------------------------------------------------*/
1069/*---------------------------------------------------------------------------*/
1070
1072meshDimension() const
1073{
1074 return m_default_mesh_handle.mesh()->dimension();
1075}
1076
1077/*---------------------------------------------------------------------------*/
1078/*---------------------------------------------------------------------------*/
1079
1081findMesh(const String& name, bool throw_exception)
1082{
1083 return m_mesh_mng->findMesh(name, throw_exception);
1084}
1085
1086/*---------------------------------------------------------------------------*/
1087/*---------------------------------------------------------------------------*/
1088
1089void SubDomain::
1090_notifyWriteCheckpoint()
1091{
1092 info(4) << "SubDomain::_notifyWriteCheckpoint()";
1093 {
1094 Properties time_stats_properties(propertyMng(), "TimeStats");
1095 timeStats()->saveTimeValues(&time_stats_properties);
1096 }
1097 {
1098 Properties p(propertyMng(), "MessagePassingStats");
1099 parallelMng()->stat()->saveValues(traceMng(), &p);
1100 }
1101}
1102
1103/*---------------------------------------------------------------------------*/
1104/*---------------------------------------------------------------------------*/
1105
1108{
1109 m_is_initialized = true;
1110 info(4) << "SubDomain::setIsInitialized()";
1111 {
1112 Properties time_stats_properties(propertyMng(), "TimeStats");
1113 timeStats()->mergeTimeValues(&time_stats_properties);
1114 }
1115 {
1116 Properties p(propertyMng(), "MessagePassingStats");
1117 parallelMng()->stat()->mergeValues(traceMng(), &p);
1118 }
1119}
1120
1121/*---------------------------------------------------------------------------*/
1122/*---------------------------------------------------------------------------*/
1123
1131{
1132 bool do_print_affinity = false;
1133 if (auto v = Convert::Type<Int32>::tryParseFromEnvironment("ARCANE_PRINT_CPUAFFINITY", true))
1134 do_print_affinity = (v.value() > 0);
1135 if (!do_print_affinity)
1136 return;
1137 info() << "PrintCPUAffinity";
1139
1140 // It is possible that some sub-domains do not have an instance
1141 // of 'IProcessorAffinityService'. In this case, only '0' will be displayed.
1142
1143 UniqueArray<Byte> cpuset_bytes;
1144 const Int32 nb_byte = 48;
1145 if (pas) {
1146 String cpuset = pas->cpuSetString();
1147 cpuset_bytes = cpuset.bytes();
1148 }
1149 cpuset_bytes.resize(nb_byte, Byte{ 0 });
1150 cpuset_bytes[nb_byte - 1] = Byte{ 0 };
1151
1152 IParallelMng* pm = parallelMng();
1153 const Int32 nb_rank = pm->commSize();
1154 bool is_master = pm->isMasterIO();
1155
1156 UniqueArray2<Byte> all_cpuset_bytes;
1157 if (is_master)
1158 all_cpuset_bytes.resize(nb_rank, nb_byte);
1159 pm->gather(cpuset_bytes, all_cpuset_bytes.viewAsArray(), pm->masterIORank());
1160 if (is_master)
1161 for (Int32 i = 0; i < nb_rank; ++i) {
1162 info() << "CPUAffinity " << Trace::Width(5) << i << " = " << all_cpuset_bytes[i].data();
1163 }
1164}
1165
1166/*---------------------------------------------------------------------------*/
1167/*---------------------------------------------------------------------------*/
1168
1169/*---------------------------------------------------------------------------*/
1170/*---------------------------------------------------------------------------*/
1171
1172template <typename V> void SubDomain::
1173_applyPropertyVisitor(V& p)
1174{
1175 auto b = p.builder();
1176
1177 p << b.addBool("LegacyMeshCreation")
1178 .addDescription("Using legacy mesh creation")
1179 .addGetter([](auto a) { return a.x.isLegacyMeshCreation(); })
1180 .addSetter([](auto a) { a.x._setLegacyMeshCreation(a.v); });
1181}
1182
1183/*---------------------------------------------------------------------------*/
1184/*---------------------------------------------------------------------------*/
1185
1186ARCANE_REGISTER_PROPERTY_CLASS(SubDomain, ());
1187
1188/*---------------------------------------------------------------------------*/
1189/*---------------------------------------------------------------------------*/
1190
1191} // End namespace Arcane
1192
1193/*---------------------------------------------------------------------------*/
1194/*---------------------------------------------------------------------------*/
#define ARCANE_THROW(exception_class,...)
Macro for throwing an exception with formatting.
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
const DeviceInfo & deviceInfo() const
Information about the device associated with this instance.
Definition Runner.cc:436
eExecutionPolicy executionPolicy() const
Associated execution policy.
Definition Runner.cc:305
Application information.
ArrayView< DataType > viewAsArray()
View of the array as a 1D array.
void resize(Int64 new_size)
Resizes only the first dimension, leaving the second dimension unchanged.
void resize(Int64 s)
Changes the number of elements in the array to s.
Exception for an invalid identifier.
Exception when trying to dereference a null pointer.
XML node names of an Arcane dataset.
Information for building a dataset option.
Base class for a data set options list.
Definition CaseOptions.h:58
void clear()
Removes all elements from the collection.
Common variables of a case.
Configuration file readers.
void addValuesFromXmlNode(const XmlNode &element, Integer priority)
Adds values to the configuration.
Constant view of an array of type T.
static std::optional< Int32 > tryParseFromEnvironment(StringView s, bool throw_if_invalid)
Template class for converting a type.
Application interface.
virtual const AcceleratorRuntimeInitialisationInfo & acceleratorRuntimeInitialisationInfo() const =0
Runtime initialization information for accelerators.
Interface of the base class for main arcane objects.
Definition IBase.h:32
virtual ITraceMng * traceMng() const =0
Trace manager.
Interface of a class managing an XML document of the dataset.
virtual XmlNode configurationElement()=0
Returns the configuration information element.
virtual XmlNode meshesElement()=0
Element containing the list of meshes (new mechanism) (can be null).
virtual CaseNodeNames * caseNodeNames()=0
Returns the instance containing the names of XML nodes by language.
Case manager interface.
Definition ICaseMng.h:57
virtual CaseOptionsCollection blocks() const =0
Collection of option blocks.
virtual ICaseDocument * caseDocument()=0
XML document of the dataset (can be null if no dataset).
Interface for a data set options list.
Interface for a list of data set options.
virtual IModule * caseModule() const =0
Returns the associated module or nullptr if none exists.
virtual String rootTagName() const =0
Name of the element in the data set language.
Interface of the checkpoint information manager.
Interface for a configuration.
Interface of a direct execution service.
Interface of a class managing a directory.
Interface for the entry point manager.
Interface of the input/output manager.
Definition IIOMng.h:37
Interface of an initial partitioner.
virtual void partitionAndDistributeMeshes(ConstArrayView< IMesh * > meshes)=0
Partitions the meshes.
Interface for registering variables for load balancing.
Factory for Arcane classes.
virtual Ref< IPropertyMng > createPropertyMngReference(ISubDomain *)=0
Creates an instance of the property manager.
virtual IServiceMng * createServiceMng(IBase *)=0
Creates an instance of the service manager.
virtual IEntryPointMng * createEntryPointMng(ISubDomain *)=0
Creates an instance of the entry point manager.
virtual ICheckpointMng * createCheckpointMng(ISubDomain *)=0
Creates an instance of the checkpoint manager.
virtual ITimeLoopMng * createTimeLoopMng(ISubDomain *)=0
Creates an instance of the time loop manager.
virtual ITimeHistoryMng * createTimeHistoryMng(ISubDomain *)=0
Creates an instance of the time history manager.
virtual IServiceLoader * createServiceLoader()=0
Creates an instance of the service loader.
virtual ILoadBalanceMng * createLoadBalanceMng(ISubDomain *sd)=0
Creates a description manager for load balancing.
virtual ICaseMng * createCaseMng(ISubDomain *)=0
Creates an instance of the case manager.
virtual IModuleMng * createModuleMng(ISubDomain *)=0
Creates an instance of the module manager.
virtual IVariableMng * createVariableMng(ISubDomain *)=0
Creates an instance of the variable manager.
virtual IModuleMaster * createModuleMaster(ISubDomain *sd)=0
Creates the master module for the sub-domain sd.
virtual Ref< IAcceleratorMng > createAcceleratorMngRef(ITraceMng *tm)=0
Creates a manager for accelerators.
virtual IIOMng * createIOMng(IApplication *)=0
Creates an instance of the I/O manager.
Interface for a memory usage information collector.
Definition IMemoryInfo.h:79
Mesh manager interface.
Definition IMeshMng.h:41
virtual void checkValidMesh()=0
Check for the validity of internal mesh structures (internal).
Interface of the main module.
Module manager interface.
Definition IModuleMng.h:39
Interface of a module.
Definition IModule.h:40
virtual String name() const =0
Module name.
Interface of the parallelism manager for a subdomain.
virtual IStat * stat()=0
Statistics manager.
virtual bool isMasterIO() const =0
true if the instance is a master I/O manager.
virtual Int32 commSize() const =0
Number of instances in the communicator.
virtual void gather(ConstArrayView< char > send_buf, ArrayView< char > recv_buf, Int32 rank)=0
Performs a gather operation onto a processor. This is a collective operation. The array send_buf must...
virtual Integer masterIORank() const =0
Rank of the instance managing I/O (for which isMasterIO() is true).
virtual char reduce(eReduceType rt, char v)=0
Performs a reduction of type rt on the real v and returns the value.
Interface of a unit system.
virtual void reloadMesh()=0
Reloads the mesh from protected variables.
Interface of a CPU core affinity management service.
virtual String cpuSetString()=0
Returns the cpuset for the current thread.
Interface of a profiling service.
virtual bool isRunning() const =0
Indicates if the profiling is running.
virtual void stopProfiling()=0
Stops profiling.
Interface of the property manager.
Interface of a resource manager.
Service manager interface.
Definition IServiceMng.h:32
Interface for a case execution session.
Definition ISession.h:38
Interface of the subdomain manager.
Definition ISubDomain.h:78
virtual IParallelMng * parallelMng()=0
Returns the parallelism manager.
Interface of a thread manager.
Definition IThreadMng.h:32
Class managing a history of values.
Interface for the time loop manager.
virtual ITimeLoop * usedTimeLoop() const =0
Returns the time loop used.
Interface of a time loop.
Definition ITimeLoop.h:33
virtual String title() const =0
Title of the time loop.
virtual String description() const =0
Description of the time loop.
virtual StringCollection userClasses() const =0
List of user classes associated with the time loop.
Interface managing execution time statistics.
Definition ITimeStats.h:44
Interface of a timer manager.
Definition ITimerMng.h:50
virtual void flush()=0
Flushes all streams.
Variable manager interface.
virtual void variables(VariableRefCollection v, IModule *i)=0
Gets all variables of module i.
Interface of a variable.
Definition IVariable.h:40
virtual eDataType dataType() const =0
Data type managed by the variable (Real, Integer, ...).
@ PPrivate
Indicates that the variable is private.
Definition IVariable.h:103
virtual eItemKind itemKind() const =0
Kind of mesh entities on which the variable is based.
virtual Integer dimension() const =0
Dimension of the variable.
virtual String name() const =0
Variable name.
Mesh construction via the "historical" method.
Handle on a mesh.
Definition MeshHandle.h:48
IMesh * mesh() const
Associated mesh.
List of observers.
virtual void saveValues(ITraceMng *tm, Properties *p)=0
Saves the current values into p.
virtual void mergeValues(ITraceMng *tm, Properties *p)=0
Merges the current values with those saved in p.
Class allowing automatic start and stop of a service.
void setPrintAtEnd(bool v)
Indicates if results are printed at the end of profiling.
List of properties.
Definition Properties.h:65
Reference to an instance.
Encapsulation of a pointer with a reference counter.
static const IDeviceInfoList * deviceInfoList(eExecutionPolicy policy)
List of devices for the execution policy policy.
Definition Runner.cc:453
Encapsulation of an automatically destructing pointer.
Definition ScopedPtr.h:44
Utility class for instantiating a service of a given interface.
Ref< InterfaceType > createReference(const String &name, eServiceBuilderProperties properties=SB_None)
Creates an instance implementing the InterfaceType interface.
Span< const Byte > bytes() const
Returns the conversion of the instance into UTF-8 encoding.
Definition String.cc:293
Class to manage the reading/writing of properties in checkpoints/rollbacks.
Definition SubDomain.cc:164
Implementation of a subdomain manager.
Definition SubDomain.cc:156
void readOrReloadMeshes() override
Reads or re-reads the meshes.
Definition SubDomain.cc:717
IParallelMng * allReplicaParallelMng() const override
Returns the parallelism manager for all replicas.
Definition SubDomain.cc:286
String objectLocalName() const override
Local name of the object.
Definition SubDomain.cc:222
IPhysicalUnitSystem * physicalUnitSystem() override
Subdomain unit system.
Definition SubDomain.cc:243
String m_case_name
Case name.
Definition SubDomain.cc:340
IModuleMng * moduleMng() override
Returns the module manager.
Definition SubDomain.cc:233
IThreadMng * threadMng() override
Returns the thread manager.
Definition SubDomain.cc:287
IParallelMng * parallelMng() override
Returns the parallelism manager.
Definition SubDomain.cc:285
Observable m_on_destroy_observable
Observable upon destruction.
Definition SubDomain.cc:346
const String & caseName() const override
Case name.
Definition SubDomain.cc:270
void setListingDirectory(const IDirectory &dir) override
Sets the output path for listing info.
Definition SubDomain.cc:293
Ref< ICaseMng > m_case_mng
Case data manager.
Definition SubDomain.cc:324
IEntryPointMng * entryPointMng() override
Returns the entry point manager.
Definition SubDomain.cc:234
ILoadBalanceMng * loadBalanceMng() override
Returns the load balancing manager.
Definition SubDomain.cc:244
ISession * m_session
Session.
Definition SubDomain.cc:315
IBase * objectParent() const override
Parent of this object.
Definition SubDomain.cc:220
void setIsContinue() override
Sets a flag indicating that a restart is being performed.
Definition SubDomain.cc:253
const String & caseFullFileName() const override
Full file path of the dataset.
Definition SubDomain.cc:268
void doInitModules() override
Calls the module initialization entry points.
Definition SubDomain.cc:837
IConfiguration * configuration() override
Associated configuration.
Definition SubDomain.cc:248
ICaseDocument * caseDocument() override
Case XML document.
Definition SubDomain.cc:265
IServiceMng * serviceMng() const override
Service manager.
Definition SubDomain.cc:229
Ref< IParallelMng > m_all_replica_parallel_mng
Parallelism manager for all replicas.
Definition SubDomain.cc:318
IIOMng * ioMng() override
Returns the I/O manager.
Definition SubDomain.cc:231
void setInitialPartitioner(IInitialPartitioner *partitioner) override
Sets the initial partitioner.
Definition SubDomain.cc:273
const CommonVariables & commonVariables() const override
Information on standard variables.
Definition SubDomain.cc:984
void setStorageDirectory(const IDirectory &dir) override
Sets the output path for exports requiring archiving.
Definition SubDomain.cc:291
void build() override
Constructs the instance members. The instance is not usable until this method has been called....
Definition SubDomain.cc:446
bool m_has_mesh_service
Indicates whether the service mechanism is used to read the mesh.
Definition SubDomain.cc:355
ITimeHistoryMng * timeHistoryMng() override
Returns the history manager.
Definition SubDomain.cc:294
IMemoryInfo * memoryInfo() const override
Memory information manager.
Definition SubDomain.cc:242
bool m_is_initialized
true if initialized
Definition SubDomain.cc:338
String m_case_full_file_name
Case path.
Definition SubDomain.cc:339
const IDirectory & exportDirectory() const override
Base directory for exports.
Definition SubDomain.cc:288
void dumpInfo(std::ostream &) override
Displays information about the instance.
Definition SubDomain.cc:666
void fillCaseBytes(ByteArray &bytes) const override
Fills bytes with the dataset content.
Definition SubDomain.cc:271
IModuleMaster * moduleMaster() const override
Module master interface.
Definition SubDomain.cc:246
ScopedPtrT< ILoadBalanceMng > m_lb_mng
Load balancing characteristics manager.
Definition SubDomain.cc:349
IVariableMng * variableMng() override
Returns the variable manager.
Definition SubDomain.cc:232
ScopedPtrT< IModuleMng > m_module_mng
Module manager.
Definition SubDomain.cc:322
const IDirectory & storageDirectory() const override
Base directory for exports requiring archiving.
Definition SubDomain.cc:290
Int32 subDomainId() const override
Subdomain ID associated with this manager.
Definition SubDomain.cc:251
Ref< IPropertyMng > m_property_mng
Property manager.
Definition SubDomain.cc:327
IMeshMng * meshMng() const override
Returns the mesh manager.
Definition SubDomain.cc:245
void addMesh(IMesh *mesh) override
Adds a mesh to the subdomain.
Definition SubDomain.cc:777
void _printCPUAffinity()
Displays the CPU affinity of all ranks.
CaseOptionsMain * m_case_config
Case config.
Definition SubDomain.cc:342
void dumpInternalInfos(XmlNode &root) override
Dumps internal architecture information. The information is stored in an XML tree with root as the ro...
Definition SubDomain.cc:995
IApplication * m_application
Main manager.
Definition SubDomain.cc:316
void allocateMeshes() override
Mesh allocation.
Definition SubDomain.cc:684
IObservable * onDestroyObservable() override
Notification before subdomain destruction.
Definition SubDomain.cc:299
ByteUniqueArray m_case_bytes
Case data.
Definition SubDomain.cc:341
void doInitMeshPartition() override
Applies the initialization mesh partitioning.
Definition SubDomain.cc:805
ITimerMng * timerMng() const override
Returns the timer manager.
Definition SubDomain.cc:236
VersionInfo objectVersion() const override
Service version number.
Definition SubDomain.cc:223
ICaseMng * caseMng() override
Returns the dataset manager.
Definition SubDomain.cc:235
Ref< IParallelMng > m_parallel_mng
Parallelism manager.
Definition SubDomain.cc:317
ConstArrayView< IMesh * > meshes() const override
List of meshes in the subdomain.
Definition SubDomain.cc:786
ScopedPtrT< IPhysicalUnitSystem > m_physical_unit_system
Physical unit system.
Definition SubDomain.cc:331
const IDirectory & listingDirectory() const override
Base directory for listings (logs, execution info).
Definition SubDomain.cc:292
void setExportDirectory(const IDirectory &dir) override
Sets the output path for exports (protections and restarts).
Definition SubDomain.cc:289
void setIsInitialized() override
Indicates that the subdomain is initialized.
ScopedPtrT< IEntryPointMng > m_entry_point_mng
Entry point manager.
Definition SubDomain.cc:323
const IConfiguration * configuration() const override
Associated configuration.
Definition SubDomain.cc:247
ScopedPtrT< IServiceMng > m_service_mng
Service manager.
Definition SubDomain.cc:330
IModuleMaster * m_module_master
Master module.
Definition SubDomain.cc:334
ScopedPtrT< ITimeHistoryMng > m_time_history_mng
History manager.
Definition SubDomain.cc:335
IDirectExecution * directExecution() const override
Direct execution service (or null).
Definition SubDomain.cc:300
const MeshHandle & defaultMeshHandle() override
Handle for the default mesh.
Definition SubDomain.cc:259
ScopedPtrT< IVariableMng > m_variable_mng
Variable manager.
Definition SubDomain.cc:321
void readCaseMeshes() override
Reads the mesh information from the dataset.
Definition SubDomain.cc:966
ScopedPtrT< ICheckpointMng > m_checkpoint_mng
Checkpoint manager.
Definition SubDomain.cc:326
Integer meshDimension() const override
Mesh dimension (1D, 2D, or 3D).
void initialize() override
Initializes the instance. The instance is not usable until this method has been called.
Definition SubDomain.cc:473
void doExitModules() override
Executes exit modules.
Definition SubDomain.cc:926
Directory m_export_directory
Export directory.
Definition SubDomain.cc:343
const CaseOptionsMain * caseOptionsMain() const override
General dataset options.
Definition SubDomain.cc:284
ITimeStats * m_time_stats
Execution time statistics.
Definition SubDomain.cc:328
ISession * session() const override
Session.
Definition SubDomain.cc:228
String objectNamespaceURI() const override
Namespace of the object.
Definition SubDomain.cc:221
ScopedPtrT< IMemoryInfo > m_memory_info
Memory usage information.
Definition SubDomain.cc:320
void setCaseName(const String &case_name) override
Sets the case name.
Definition SubDomain.cc:272
bool isContinue() const override
True if a restart is being performed, false otherwise.
Definition SubDomain.cc:254
IMainFactory * mainFactory() override
Main factory.
Definition SubDomain.cc:227
ICheckpointMng * checkpointMng() const override
Protection manager.
Definition SubDomain.cc:237
IRessourceMng * ressourceMng() const override
Resource manager.
Definition SubDomain.cc:240
IPropertyMng * propertyMng() const override
Property manager.
Definition SubDomain.cc:238
ScopedPtrT< IConfiguration > m_configuration
Configuration.
Definition SubDomain.cc:350
ITimeLoopMng * timeLoopMng() override
Returns the time loop manager.
Definition SubDomain.cc:230
void checkId(const String &where, const String &id) override
Checks if an identifier is valid.
Definition SubDomain.cc:948
Directory m_listing_directory
Listing directory.
Definition SubDomain.cc:345
IApplication * application() override
Application.
Definition SubDomain.cc:266
ScopedPtrT< ITimeLoopMng > m_time_loop_mng
Time loop manager.
Definition SubDomain.cc:329
Directory m_storage_directory
Archive directory.
Definition SubDomain.cc:344
ITimerMng * m_timer_mng
Timer manager.
Definition SubDomain.cc:325
ITraceMng * traceMng() const override
Trace manager.
Definition SubDomain.cc:241
ITimeStats * timeStats() const override
Execution time statistics.
Definition SubDomain.cc:239
IMesh * defaultMesh() override
Default mesh.
Definition SubDomain.cc:258
void initializeMeshVariablesFromCaseFile() override
Initializes variables whose values are specified in the dataset.
Definition SubDomain.cc:795
void setDirectExecution(IDirectExecution *v) override
Sets the direct execution service.
Definition SubDomain.cc:301
bool isInitialized() const override
Indicates if the session has been initialized.
Definition SubDomain.cc:262
Int32 nbSubDomain() const override
Total number of subdomains.
Definition SubDomain.cc:252
IAcceleratorMng * acceleratorMng() override
Associated accelerator manager.
Definition SubDomain.cc:249
IMesh * findMesh(const String &name, bool throw_exception) override
Searches for the mesh named name.
const ApplicationInfo & applicationInfo() const override
Executable information.
Definition SubDomain.cc:264
ScopedPtrT< IIOMng > m_io_mng
Input/output manager.
Definition SubDomain.cc:319
Positions the name of the currently executing action.
Definition Timer.h:119
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
TraceMessage logdate() const
Flow for a log message preceded by the date.
TraceMessage info() const
Flow for an information message.
ITraceMng * traceMng() const
Trace manager.
TraceMessage pwarning() const
Formatting the stream by length.
2D data vector with value semantics (STL style).
1D data vector with value semantics (STL style).
Parameters necessary for building a variable.
Information about a version.
Definition VersionInfo.h:47
Element of a DOM tree.
Definition XmlNode.h:406
Node of a DOM tree.
Definition XmlNode.h:51
bool null() const
True if the node is null.
Definition XmlNode.h:303
void setAttrValue(const String &name, const String &value)
Sets the attribute name to the value value.
Definition XmlNode.cc:248
API UNDER DEVELOPMENT. DO NOT USE.
VariableRefArrayT< Byte > VariableArrayByte
Array variable of byte type.
bool isAcceleratorPolicy(eExecutionPolicy exec_policy)
Indicates if exec_policy corresponds to an accelerator.
void dumpDateAndMemoryUsage(IParallelMng *pm, ITraceMng *tm)
Writes the date and memory consumed into tm.
Definition Parallel.cc:164
@ ReduceMin
Minimum of values.
void callDotNETGarbageCollector()
Calls the .Net Garbage Collector if available.
String getHostName()
Name of the machine running the process.
IProfilingService * getProfilingService()
Service used to obtain profiling information.
IProcessorAffinityService * getProcessorAffinityService()
Service used for managing processor affinity.
String getEnvironmentVariable(const String &name)
Environment variable named name.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
@ SB_AllowNull
Allows the service to be absent.
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
Array< Byte > ByteArray
Dynamic one-dimensional array of characters.
Definition UtilsTypes.h:115
UniqueArray< Byte > ByteUniqueArray
Dynamic 1D array of characters.
Definition UtilsTypes.h:329
Collection< ICaseOptions * > CaseOptionsCollection
Collection of dataset options.
const char * itemKindName(eItemKind kind)
Entity kind name.
ConstArrayView< Byte > ByteConstArrayView
C equivalent of a 1D array of characters.
Definition UtilsTypes.h:470
unsigned char Byte
Type of a byte.
Definition BaseTypes.h:42
UniqueArray< String > StringUniqueArray
Dynamic 1D array of strings.
Definition UtilsTypes.h:353
List< VariableRef * > VariableRefList
Array of variable references.
const char * dataTypeName(eDataType type)
Data type name.
Definition DataTypes.cc:72
std::int32_t Int32
Signed integer type of 32 bits.