Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
HybridParallelMng.h
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/* HybridParallelMng.h (C) 2000-2026 */
9/* */
10/* Implementation of hybrid MPI/Shared Memory messages. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_PARALLEL_THREAD_HYBRIDPARALLELMNG_H
13#define ARCANE_PARALLEL_THREAD_HYBRIDPARALLELMNG_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/NotImplementedException.h"
18#include "arcane/utils/Array.h"
19#include "arcane/utils/Ref.h"
20
21#include "arcane/core/ParallelMngDispatcher.h"
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26namespace Arcane
27{
28class SerializeBuffer;
29class MpiParallelMng;
30} // namespace Arcane
31
33{
40
41/*---------------------------------------------------------------------------*/
42/*---------------------------------------------------------------------------*/
43
48{
49 public:
50
51 Int32 local_rank = -1;
52 Int32 local_nb_rank = -1;
53 MpiParallelMng* mpi_parallel_mng = nullptr;
54 ITraceMng* trace_mng = nullptr;
55 IThreadMng* thread_mng = nullptr;
56 IParallelMng* world_parallel_mng = nullptr;
57 ISharedMemoryMessageQueue* message_queue = nullptr;
58 IThreadBarrier* thread_barrier = nullptr;
59 Array<HybridParallelMng*>* parallel_mng_list = nullptr;
60 MpiThreadAllDispatcher* all_dispatchers = nullptr;
61 IParallelMngContainerFactory* sub_builder_factory = nullptr;
64};
65
66/*---------------------------------------------------------------------------*/
67/*---------------------------------------------------------------------------*/
68
72class HybridParallelMng
73: public ParallelMngDispatcher
74{
75 friend HybridSerializeMessageList;
76 class RequestList;
77 class Impl;
78
79 public:
80
81 explicit HybridParallelMng(const HybridParallelMngBuildInfo& bi);
82 ~HybridParallelMng() override;
83
84 bool isParallel() const override { return m_is_parallel; }
85 Int32 commRank() const override { return m_global_rank; }
86 Int32 commSize() const override { return m_global_nb_rank; }
87 void* getMPICommunicator() override;
88 MP::Communicator communicator() const override;
89 MP::Communicator machineCommunicator() const override;
90 bool isThreadImplementation() const override { return true; }
91 bool isHybridImplementation() const override { return true; }
92 ITraceMng* traceMng() const override { return m_trace; }
93 IThreadMng* threadMng() const override { return m_thread_mng; }
94 IParallelMng* worldParallelMng() const override { return m_world_parallel_mng; }
95 IIOMng* ioMng() const override { return m_io_mng; }
96
97 void initialize() override;
98 bool isMasterIO() const override { return commRank() == 0; }
99 Int32 masterIORank() const override { return 0; }
100
101 ITimerMng* timerMng() const override { return m_timer_mng; }
102
104 Ref<IParallelMng> sequentialParallelMngRef() override;
105 void sendSerializer(ISerializer* values, Int32 rank) override;
106 Request sendSerializer(ISerializer* values, Int32 rank, ByteArray& bytes) override;
108
109 void recvSerializer(ISerializer* values, Int32 rank) override;
111
112 void freeRequests(ArrayView<Request> requests) override;
113
114 void broadcastSerializer(ISerializer* values, Int32 rank) override;
115 MessageId probe(const PointToPointMessageInfo& message) override;
117 Request sendSerializer(const ISerializer* values, const PointToPointMessageInfo& message) override;
118 Request receiveSerializer(ISerializer* values, const PointToPointMessageInfo& message) override;
119
120 void printStats() override;
121 void barrier() override;
122 void waitAllRequests(ArrayView<Request> requests) override;
123
124 IParallelNonBlockingCollective* nonBlockingCollective() const override { return nullptr; }
125
126 void build() override;
127
128 public:
129
130 Int32 localRank() const { return m_local_rank; }
131 Int32 localNbRank() const { return m_local_nb_rank; }
132 MpiParallelMng* mpiParallelMng() { return m_mpi_parallel_mng; }
134 PointToPointMessageInfo buildMessage(Int32 dest, MP::eBlockingType is_blocking);
136
137 public:
138
139 IParallelMngInternal* _internalApi() override { return m_parallel_mng_internal; }
140
141 protected:
142
148 IVariableSynchronizer* createSynchronizer(const ItemGroup& group) override;
149 Parallel::IStat* stat() override { return m_stat; }
150 IParallelReplication* replication() const override;
151 void setReplication(IParallelReplication* v) override;
153 ISerializeMessageList* _createSerializeMessageList() override;
154 IParallelMng* _createSubParallelMng(Int32ConstArrayView kept_ranks) override;
157 bool _isAcceleratorAware() const override;
158
159 public:
160
161 IThreadBarrier* getThreadBarrier()
162 {
163 return m_thread_barrier;
164 }
165
166 private:
167
168 ITraceMng* m_trace;
169 IThreadMng* m_thread_mng;
170 IParallelMng* m_world_parallel_mng;
171 IIOMng* m_io_mng;
172 Ref<IParallelMng> m_sequential_parallel_mng;
173 ITimerMng* m_timer_mng;
174 IParallelReplication* m_replication;
175 HybridMessageQueue* m_message_queue;
176 bool m_is_parallel;
182 Parallel::IStat* m_stat = nullptr;
183 IThreadBarrier* m_thread_barrier = nullptr;
184 MpiParallelMng* m_mpi_parallel_mng = nullptr;
185 MpiThreadAllDispatcher* m_all_dispatchers = nullptr;
186 Array<HybridParallelMng*>* m_parallel_mng_list = nullptr;
187 IParallelMngContainerFactory* m_sub_builder_factory = nullptr;
188 Ref<IParallelMngContainer> m_parent_container_ref;
189 Ref<IParallelMngUtilsFactory> m_utils_factory;
190 IParallelMngInternal* m_parallel_mng_internal = nullptr;
191
192 private:
193
194 SerializeBuffer* _castSerializer(ISerializer* serializer);
195};
196
197/*---------------------------------------------------------------------------*/
198/*---------------------------------------------------------------------------*/
199
200} // End namespace Arcane::MessagePassing
201
202/*---------------------------------------------------------------------------*/
203/*---------------------------------------------------------------------------*/
204
205#endif
Modifiable view of an array of type T.
Base class for 1D data vectors.
Operations to access variable values from another subdomain.
Interface of the input/output manager.
Definition IIOMng.h:37
Interface of an entity family.
Definition IItemFamily.h:83
Information exchange between processors.
Interface for an 'IParallelMng' container factory.
Internal part of IParallelMng.
Interface of the parallelism manager for a subdomain.
Interface for non-blocking collective parallel operations.
Brief information on parallel subdomain replication.
Information on the computing core allocation topology.
Interface of a thread manager.
Definition IThreadMng.h:32
Interface of a timer manager.
Definition ITimerMng.h:50
Sends values across different processors.
Interface of a variable synchronization service.
Mesh entity group.
Definition ItemGroup.h:51
Interface for a message queue with threads.
Implementation of IRequestList for HybridParallelMng.
Thread-based parallelism manager.
bool isMasterIO() const override
true if the instance is a master I/O manager.
IParallelMng * worldParallelMng() const override
Parallelism manager over all allocated resources.
IParallelMngInternal * _internalApi() override
Internal Arcane API.
bool isThreadImplementation() const override
Indicates if the implementation uses threads.
Parallel::IStat * stat() override
Statistics manager.
void freeRequests(ArrayView< Request > requests) override
Frees the requests.
IParallelNonBlockingCollective * nonBlockingCollective() const override
Interface for non-blocking collective operations.
void printStats() override
Prints statistics related to this parallelism manager.
IParallelExchanger * createExchanger() override
Returns an interface for transferring messages between processors.
void barrier() override
Performs a barrier.
MP::Communicator communicator() const override
MPI communicator associated with this manager.
bool m_is_initialized
true if already initialized
ISerializeMessage * createReceiveSerializer(Int32 rank) override
Creates a non-blocking message to receive serialized data from rank rank.
Ref< Parallel::IRequestList > createRequestListRef() override
Creates a request list for this manager.
bool isParallel() const override
Returns true if the execution is parallel.
ITimerMng * timerMng() const override
Timer manager.
void build() override
Constructs the instance.
void waitAllRequests(ArrayView< Request > requests) override
Blocks while waiting for the rvalues requests to complete.
void initialize() override
Initializes the parallelism manager.
IThreadMng * threadMng() const override
Thread manager.
Int32 m_global_nb_rank
Total number of global ranks.
MessageSourceInfo legacyProbe(const PointToPointMessageInfo &message) override
Probes if messages are available.
Int32 m_local_rank
Local rank of the current processor.
ITraceMng * traceMng() const override
Trace manager.
IGetVariablesValuesParallelOperation * createGetVariablesValuesOperation() override
Returns an operation to retrieve the values of a variable on the entities of another subdomain.
void * getMPICommunicator() override
Address of the MPI communicator associated with this manager.
IParallelReplication * replication() const override
Replication information.
Ref< IParallelMngUtilsFactory > _internalUtilsFactory() const override
Factory for utility functions.
Int32 masterIORank() const override
Rank of the instance managing I/O (for which isMasterIO() is true).
Ref< IParallelMng > createSubParallelMngRef(Int32ConstArrayView kept_ranks) override
Creates a new parallelism manager for a subset of ranks.
MP::Communicator machineCommunicator() const override
MPI communicator derived from the communicator communicator() gathering all processes of the compute ...
IIOMng * ioMng() const override
I/O manager.
ITransferValuesParallelOperation * createTransferValuesOperation() override
Returns an operation to transfer values between subdomains.
IParallelTopology * createTopology() override
Creates an instance containing information about the rank topology of this manager.
void setReplication(IParallelReplication *v) override
Sets the Replication Information.
IParallelMng * sequentialParallelMng() override
Returns a sequential parallelism manager.
Int32 commSize() const override
Number of instances in the communicator.
bool isHybridImplementation() const override
Indicates if the implementation uses hybrid mode.
IVariableSynchronizer * createSynchronizer(IItemFamily *family) override
Returns an interface for synchronizing variables on the group of the family.
Int32 m_local_nb_rank
Number of local ranks.
MessageId probe(const PointToPointMessageInfo &message) override
Probes if messages are available.
ISerializeMessage * createSendSerializer(Int32 rank) override
Creates a non-blocking message to send serialized data to rank rank.
Int32 commRank() const override
Rank of this instance in the communicator.
Int32 m_global_rank
Current processor number.
PointToPointMessageInfo buildMessage(Int32 dest, MP::eBlockingType is_blocking)
Constructs a message with destination dest.
Information about the source of a message.
Information for sending/receiving a point-to-point message.
Parallelism manager using MPI.
Reference to an instance.
Implementation of a buffer for serialization.
Declarations of types and methods used by message exchange mechanisms.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Array< Byte > ByteArray
Dynamic one-dimensional array of characters.
Definition UtilsTypes.h:121
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
std::int32_t Int32
Signed integer type of 32 bits.
Info for constructing a HybridParallelMng.