Arcane  4.1.12.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 {
739 ProfilingSentryWithInitialize ps_sentry(ps);
740 ps_sentry.setPrintAtEnd(true);
741
742 if (m_is_continue) {
743 for (Integer z = 0; z < nb_mesh; ++z) {
744 IPrimaryMesh* mesh = m_mesh_mng->getPrimaryMesh(z);
745 mesh->reloadMesh();
746 }
747 }
748 else {
749 if (m_has_mesh_service) {
750 m_case_mesh_master_service->allocateMeshes();
751 }
752 else
753 m_legacy_mesh_builder->readMeshes();
754 }
755 }
756
757 //warning() << "CODE CHANGED IN DEV-X10. NEED TEST";
758 //mesh->computeTiedInterfaces(mbi.m_xml_node);
760 // mesh->readAmrActivator(mbi.m_xml_node);
761
762 // Checks mesh consistency
763 for (Integer z = 0; z < nb_mesh; ++z) {
764 IMesh* mesh = m_mesh_mng->getMesh(z);
765 mesh->checkValidMesh();
766 mesh->nodesCoordinates().setUpToDate();
767 }
768}
769
770/*---------------------------------------------------------------------------*/
771/*---------------------------------------------------------------------------*/
772
774addMesh(IMesh* mesh)
775{
776 m_mesh_mng->addMesh(mesh);
777}
778
779/*---------------------------------------------------------------------------*/
780/*---------------------------------------------------------------------------*/
781
783meshes() const
784{
785 return m_mesh_mng->meshes();
786}
787
788/*---------------------------------------------------------------------------*/
789/*---------------------------------------------------------------------------*/
790
793{
795 m_legacy_mesh_builder->initializeMeshVariablesFromCaseFile();
796}
797
798/*---------------------------------------------------------------------------*/
799/*---------------------------------------------------------------------------*/
800
803{
804 if (!m_is_continue) {
805 IInitialPartitioner* init_part = m_legacy_mesh_builder->m_initial_partitioner.get();
806 if (init_part) {
807 info() << "Using custom initial partitioner";
808 init_part->partitionAndDistributeMeshes(m_mesh_mng->meshes());
809 }
810 else {
811 if (m_case_mesh_master_service.get()) {
812 m_case_mesh_master_service->partitionMeshes();
813 m_case_mesh_master_service->applyAdditionalOperationsOnMeshes();
814 }
815 else if (m_legacy_mesh_builder->m_use_internal_mesh_partitioner)
816 _doInitialPartition();
817 }
818 }
819
820 // Display mesh information
821 for (IMesh* mesh : m_mesh_mng->meshes()) {
823 mh->dumpStats();
824 }
825}
826
827/*---------------------------------------------------------------------------*/
828/*---------------------------------------------------------------------------*/
829
835{
836}
837
838/*---------------------------------------------------------------------------*/
839/*---------------------------------------------------------------------------*/
840
841void SubDomain::
842_doInitialPartition()
843{
844 // NOTE: This code is only used by the historical mesh creation mechanism.
845 // When meshes are used for services, the corresponding code is in ArcaneCaseMeshService.
846
847 String test_service = "MeshPartitionerTester";
848
849 for (IMesh* mesh : m_mesh_mng->meshes()) {
850 bool is_mesh_allocated = mesh->isAllocated();
851 info() << "InitialPartitioning mesh=" << mesh->name() << " is_allocated?=" << is_mesh_allocated;
852 if (!is_mesh_allocated)
853 continue;
854 // Since 'parmetis' does not like repartitioning a mesh if one of the sub-domains
855 // is empty (which is the case if only one processor created the cells),
856 // we must first use the basic partitioner which distributes the cells
857 // among the sub-domains, and then 'parmetis' if it is present
858 if (m_legacy_mesh_builder->m_use_partitioner_tester) {
859 Int64 nb_cell = mesh->nbCell();
860 Int64 min_nb_cell = parallelMng()->reduce(Parallel::ReduceMin, nb_cell);
861 info() << "Min nb cell=" << min_nb_cell;
862 if (min_nb_cell == 0)
863 _doInitialPartitionForMesh(mesh, test_service);
864 else
865 info() << "Mesh name=" << mesh->name() << " have cells. Do not use " << test_service;
866 }
867 else
868 info() << "No basic partition first needed";
869 _doInitialPartitionForMesh(mesh, m_legacy_mesh_builder->m_internal_partitioner_name);
870 }
871}
872
873/*---------------------------------------------------------------------------*/
874/*---------------------------------------------------------------------------*/
875
876void SubDomain::
877_doInitialPartitionForMesh(IMesh* mesh, const String& service_name)
878{
879 info() << "DoInitialPartition. mesh=" << mesh->name() << " service=" << service_name;
880
881 String lib_name = service_name;
882 IMeshPartitionerBase* mesh_partitioner_base = nullptr;
883 Ref<IMeshPartitionerBase> mesh_partitioner_base_ref;
884 Ref<IMeshPartitioner> mesh_partitioner_ref;
885
886 ServiceBuilder<IMeshPartitionerBase> sbuilder(this);
887 mesh_partitioner_base_ref = sbuilder.createReference(service_name, mesh, SB_AllowNull);
888 mesh_partitioner_base = mesh_partitioner_base_ref.get();
889
890 if (!mesh_partitioner_base) {
891 // If not found, search with the old interface 'IMeshPartitioner' for
892 // compatibility reasons
893 pwarning() << "No implementation for 'IMeshPartitionerBase' interface found. "
894 << "Searching implementation for legacy 'IMeshPartitioner' interface";
895 ServiceBuilder<IMeshPartitioner> sbuilder_legacy(this);
896 mesh_partitioner_ref = sbuilder_legacy.createReference(service_name, mesh, SB_AllowNull);
897 if (mesh_partitioner_ref.get())
898 mesh_partitioner_base = mesh_partitioner_ref.get();
899 }
900
901 if (!mesh_partitioner_base) {
902 // If not found, retrieve the list of possible values and display them.
903 StringUniqueArray valid_names;
904 sbuilder.getServicesNames(valid_names);
905 String valid_values = String::join(", ", valid_names);
906 String msg = String::format("The specified service for the initial mesh partitionment ({0}) "
907 "is not available (valid_values={1}). This service has to implement "
908 "interface Arcane::IMeshPartitionerBase",
909 lib_name, valid_values);
910 ARCANE_THROW(ParallelFatalErrorException, msg);
911 }
912
913 bool is_dynamic = mesh->isDynamic();
914 mesh->modifier()->setDynamic(true);
915 mesh->utilities()->partitionAndExchangeMeshWithReplication(mesh_partitioner_base, true);
916 mesh->modifier()->setDynamic(is_dynamic);
917}
918
919/*---------------------------------------------------------------------------*/
920/*---------------------------------------------------------------------------*/
921
924{
925 if (!m_is_initialized)
926 ARCANE_FATAL("Uninitialized session");
927
928 logdate() << "Execution of the end of compute entry points";
929
930 // Save history manager data if requested
931 if (caseOptionsMain()->doTimeHistory())
932 m_time_history_mng->dumpHistory(true);
933
934 m_time_loop_mng->execExitEntryPoints();
935
936 m_parallel_mng->printStats();
937
938 traceMng()->flush();
939}
940
941/*---------------------------------------------------------------------------*/
942/*---------------------------------------------------------------------------*/
943
945checkId(const String& where, const String& id)
946{
947 Int64 len = id.length();
948 const char* str = id.localstr();
949 if (len == 0 || !str)
950 throw BadIDException(where, id);
951
952 if (!isalpha(str[0]))
953 throw BadIDException(where, id);
954 for (Int64 i = 1; i < len; ++i)
955 if (!isalpha(str[i]) && !isdigit(str[i]) && str[i] != '_' && str[i] != '.' && str[i] != '-')
956 throw BadIDException(where, id);
957}
958
959/*---------------------------------------------------------------------------*/
960/*---------------------------------------------------------------------------*/
961
964{
965 Trace::Setter mci(traceMng(), _msgClassName());
966
967 info() << "Reading the case `" << m_case_full_file_name << "'";
968
969 ICaseDocument* case_doc = caseDocument();
970 if (!case_doc)
971 ARCANE_FATAL("No input data");
972
973 m_legacy_mesh_builder->readCaseMeshes();
974 m_case_config = m_module_master->caseoptions();
975}
976
977/*---------------------------------------------------------------------------*/
978/*---------------------------------------------------------------------------*/
979
981commonVariables() const
982{
983 if (!m_module_master)
984 throw BadReferenceException("module master in SubDomain::variablesCommon()");
985 return *m_module_master->commonVariables();
986}
987
988/*---------------------------------------------------------------------------*/
989/*---------------------------------------------------------------------------*/
990
993{
994 // Info about the time loop used.
995 {
996 ITimeLoopMng* tlm = timeLoopMng();
997 ITimeLoop* time_loop = tlm->usedTimeLoop();
998 XmlElement time_loop_elem(root, "timeloopinfo");
999 XmlElement title(time_loop_elem, "title", time_loop->title());
1000 XmlElement description(time_loop_elem, "description", time_loop->description());
1001
1002 String ustr_userclass("userclass");
1003 for (StringCollection::Enumerator j(time_loop->userClasses()); ++j;)
1004 XmlElement elem(time_loop_elem, ustr_userclass, *j);
1005 }
1006
1007 VariableRefList var_ref_list;
1008 XmlElement modules(root, "modules");
1009
1010 String ustr_module("module");
1011 String ustr_name("name");
1012 String ustr_activated("activated");
1013 String ustr_true("true");
1014 String ustr_false("false");
1015 String ustr_variable("variable");
1016 String ustr_variable_ref("variable-ref");
1017 String ustr_ref("ref");
1018 String ustr_datatype("datatype");
1019 String ustr_dimension("dimension");
1020 String ustr_kind("kind");
1021 String ustr_caseblock("caseblock");
1022 String ustr_tagname("tagname");
1023
1024 // List of modules with the variables they use.
1025 for (ModuleCollection::Enumerator i(moduleMng()->modules()); ++i;) {
1026 XmlElement module_element(modules, ustr_module);
1027 module_element.setAttrValue(ustr_name, (*i)->name());
1028 bool is_activated = (*i)->used();
1029 module_element.setAttrValue(ustr_activated, is_activated ? ustr_true : ustr_false);
1030 var_ref_list.clear();
1031 variableMng()->variables(var_ref_list, *i);
1032 for (VariableRefList::Enumerator j(var_ref_list); ++j;) {
1033 XmlElement variable_element(module_element, ustr_variable_ref);
1034 variable_element.setAttrValue(ustr_ref, (*j)->name());
1035 }
1036 }
1037
1038 // List of variables.
1039 XmlElement variables(root, "variables");
1040 VariableCollection var_prv_list = variableMng()->variables();
1041 for (VariableCollection::Enumerator j(var_prv_list); ++j;) {
1042 XmlElement elem(variables, ustr_variable);
1043 IVariable* var = *j;
1044 String dim = String::fromNumber(var->dimension());
1045 elem.setAttrValue(ustr_name, var->name());
1046 elem.setAttrValue(ustr_datatype, dataTypeName(var->dataType()));
1047 elem.setAttrValue(ustr_dimension, dim);
1048 elem.setAttrValue(ustr_kind, itemKindName(var->itemKind()));
1049 }
1050
1051 // List of option blocks
1052 const ICaseMng* cm = caseMng();
1053 CaseOptionsCollection blocks = cm->blocks();
1054 XmlElement blocks_elem(root, "caseblocks");
1055 for (CaseOptionsCollection::Enumerator i(blocks); ++i;) {
1056 const ICaseOptions* block = *i;
1057 XmlElement block_elem(blocks_elem, ustr_caseblock);
1058 block_elem.setAttrValue(ustr_tagname, block->rootTagName());
1059 const IModule* block_module = block->caseModule();
1060 if (block_module)
1061 block_elem.setAttrValue(ustr_module, block_module->name());
1062 }
1063}
1064
1065/*---------------------------------------------------------------------------*/
1066/*---------------------------------------------------------------------------*/
1067
1069meshDimension() const
1070{
1071 return m_default_mesh_handle.mesh()->dimension();
1072}
1073
1074/*---------------------------------------------------------------------------*/
1075/*---------------------------------------------------------------------------*/
1076
1078findMesh(const String& name, bool throw_exception)
1079{
1080 return m_mesh_mng->findMesh(name, throw_exception);
1081}
1082
1083/*---------------------------------------------------------------------------*/
1084/*---------------------------------------------------------------------------*/
1085
1086void SubDomain::
1087_notifyWriteCheckpoint()
1088{
1089 info(4) << "SubDomain::_notifyWriteCheckpoint()";
1090 {
1091 Properties time_stats_properties(propertyMng(), "TimeStats");
1092 timeStats()->saveTimeValues(&time_stats_properties);
1093 }
1094 {
1095 Properties p(propertyMng(), "MessagePassingStats");
1096 parallelMng()->stat()->saveValues(traceMng(), &p);
1097 }
1098}
1099
1100/*---------------------------------------------------------------------------*/
1101/*---------------------------------------------------------------------------*/
1102
1105{
1106 m_is_initialized = true;
1107 info(4) << "SubDomain::setIsInitialized()";
1108 {
1109 Properties time_stats_properties(propertyMng(), "TimeStats");
1110 timeStats()->mergeTimeValues(&time_stats_properties);
1111 }
1112 {
1113 Properties p(propertyMng(), "MessagePassingStats");
1114 parallelMng()->stat()->mergeValues(traceMng(), &p);
1115 }
1116}
1117
1118/*---------------------------------------------------------------------------*/
1119/*---------------------------------------------------------------------------*/
1120
1128{
1129 bool do_print_affinity = false;
1130 if (auto v = Convert::Type<Int32>::tryParseFromEnvironment("ARCANE_PRINT_CPUAFFINITY", true))
1131 do_print_affinity = (v.value() > 0);
1132 if (!do_print_affinity)
1133 return;
1134 info() << "PrintCPUAffinity";
1136
1137 // It is possible that some sub-domains do not have an instance
1138 // of 'IProcessorAffinityService'. In this case, only '0' will be displayed.
1139
1140 UniqueArray<Byte> cpuset_bytes;
1141 const Int32 nb_byte = 48;
1142 if (pas) {
1143 String cpuset = pas->cpuSetString();
1144 cpuset_bytes = cpuset.bytes();
1145 }
1146 cpuset_bytes.resize(nb_byte, Byte{ 0 });
1147 cpuset_bytes[nb_byte - 1] = Byte{ 0 };
1148
1149 IParallelMng* pm = parallelMng();
1150 const Int32 nb_rank = pm->commSize();
1151 bool is_master = pm->isMasterIO();
1152
1153 UniqueArray2<Byte> all_cpuset_bytes;
1154 if (is_master)
1155 all_cpuset_bytes.resize(nb_rank, nb_byte);
1156 pm->gather(cpuset_bytes, all_cpuset_bytes.viewAsArray(), pm->masterIORank());
1157 if (is_master)
1158 for (Int32 i = 0; i < nb_rank; ++i) {
1159 info() << "CPUAffinity " << Trace::Width(5) << i << " = " << all_cpuset_bytes[i].data();
1160 }
1161}
1162
1163/*---------------------------------------------------------------------------*/
1164/*---------------------------------------------------------------------------*/
1165
1166/*---------------------------------------------------------------------------*/
1167/*---------------------------------------------------------------------------*/
1168
1169template <typename V> void SubDomain::
1170_applyPropertyVisitor(V& p)
1171{
1172 auto b = p.builder();
1173
1174 p << b.addBool("LegacyMeshCreation")
1175 .addDescription("Using legacy mesh creation")
1176 .addGetter([](auto a) { return a.x.isLegacyMeshCreation(); })
1177 .addSetter([](auto a) { a.x._setLegacyMeshCreation(a.v); });
1178}
1179
1180/*---------------------------------------------------------------------------*/
1181/*---------------------------------------------------------------------------*/
1182
1183ARCANE_REGISTER_PROPERTY_CLASS(SubDomain, ());
1184
1185/*---------------------------------------------------------------------------*/
1186/*---------------------------------------------------------------------------*/
1187
1188} // End namespace Arcane
1189
1190/*---------------------------------------------------------------------------*/
1191/*---------------------------------------------------------------------------*/
#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:434
eExecutionPolicy executionPolicy() const
Associated execution policy.
Definition Runner.cc:303
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.
Class managing a directory.
Definition Directory.h:36
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.
Definition IDirectory.h:32
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
static IMeshStats * create(ITraceMng *trace, IMesh *mesh, IParallelMng *pm)
Creation of a default instance.
Definition MeshStats.cc:43
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.
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:75
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:451
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:834
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:981
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:774
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:992
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:802
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:783
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:963
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:923
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:945
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:792
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:121
UniqueArray< Byte > ByteUniqueArray
Dynamic 1D array of characters.
Definition UtilsTypes.h:335
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:476
unsigned char Byte
Type of a byte.
Definition BaseTypes.h:43
UniqueArray< String > StringUniqueArray
Dynamic 1D array of strings.
Definition UtilsTypes.h:359
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.