Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
SharedMemoryParallelMng.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/* SharedMemoryParallelMng.h (C) 2000-2026 */
9/* */
10/* Implementation of messages in shared memory mode. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_PARALLEL_THREAD_SHAREDMEMORYPARALLELMNG_H
13#define ARCANE_PARALLEL_THREAD_SHAREDMEMORYPARALLELMNG_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/core/ParallelMngDispatcher.h"
18
19#include "arcane/utils/TraceInfo.h"
20#include "arcane/utils/NotImplementedException.h"
21#include "arcane/utils/Ref.h"
22#include "arccore/base/ReferenceCounter.h"
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27namespace Arcane
28{
29class SerializeBuffer;
31} // namespace Arcane
32
34{
38
39/*---------------------------------------------------------------------------*/
40/*---------------------------------------------------------------------------*/
41
45struct ARCANE_THREAD_EXPORT SharedMemoryParallelMngBuildInfo
46{
47 public:
48
49 SharedMemoryParallelMngBuildInfo()
50 : rank(-1)
51 , nb_rank(0)
52 , trace_mng(nullptr)
53 , thread_mng(nullptr)
54 , message_queue(nullptr)
55 , thread_barrier(nullptr)
56 , all_dispatchers(nullptr)
57 , window_creator(nullptr)
58 {}
59
60 public:
61
62 Int32 rank;
63 Int32 nb_rank;
64 ITraceMng* trace_mng;
65 IThreadMng* thread_mng;
66 Ref<IParallelMng> sequential_parallel_mng;
67 IParallelMng* world_parallel_mng = nullptr;
68 ISharedMemoryMessageQueue* message_queue = nullptr;
69 IThreadBarrier* thread_barrier = nullptr;
70 SharedMemoryAllDispatcher* all_dispatchers = nullptr;
71 IParallelMngContainerFactory* sub_builder_factory = nullptr;
73 MP::Communicator communicator;
74 SharedMemoryMachineShMemWinBaseInternalCreator* window_creator = nullptr;
75};
76
77/*---------------------------------------------------------------------------*/
78/*---------------------------------------------------------------------------*/
79
83class ARCANE_THREAD_EXPORT SharedMemoryParallelMng
84: public ParallelMngDispatcher
85{
86 public:
87
88 class RequestList;
89 class Impl;
90
91 public:
92
93 explicit SharedMemoryParallelMng(const SharedMemoryParallelMngBuildInfo& build_info);
94 ~SharedMemoryParallelMng() override;
95
96 bool isParallel() const override { return m_is_parallel; }
97 Int32 commRank() const override { return m_rank; }
98 Int32 commSize() const override { return m_nb_rank; }
99 void* getMPICommunicator() override { return m_mpi_communicator.communicatorAddress(); }
100 MP::Communicator communicator() const override { return m_mpi_communicator; }
101 MP::Communicator machineCommunicator() const override { return m_mpi_communicator; }
102 bool isThreadImplementation() const override { return true; }
103 bool isHybridImplementation() const override { return false; }
104 ITraceMng* traceMng() const override { return m_trace.get(); }
105 IThreadMng* threadMng() const override { return m_thread_mng; }
106 void initialize() override;
107 bool isMasterIO() const override { return commRank() == 0; }
108 Integer masterIORank() const override { return 0; }
109 IIOMng* ioMng() const override { return m_io_mng; }
110 IParallelMng* worldParallelMng() const override { return m_world_parallel_mng; }
111 ITimerMng* timerMng() const override { return m_timer_mng; }
112
113 IParallelMng* sequentialParallelMng() override;
114 Ref<IParallelMng> sequentialParallelMngRef() override;
115 void sendSerializer(ISerializer* values, Int32 rank) override;
116 Request sendSerializer(ISerializer* values, Int32 rank, ByteArray& bytes) override;
117 ISerializeMessage* createSendSerializer(Int32 rank) override;
118
119 void recvSerializer(ISerializer* values, Int32 rank) override;
120 ISerializeMessage* createReceiveSerializer(Int32 rank) override;
121
122 void freeRequests(ArrayView<Parallel::Request> requests) override;
123
124 void broadcastSerializer(ISerializer* values, Int32 rank) override;
125 MessageId probe(const PointToPointMessageInfo& message) override;
126 MessageSourceInfo legacyProbe(const PointToPointMessageInfo& message) override;
127 Request sendSerializer(const ISerializer* values, const PointToPointMessageInfo& message) override;
128 Request receiveSerializer(ISerializer* values, const PointToPointMessageInfo& message) override;
129
130 void printStats() override;
131 void barrier() override;
132 void waitAllRequests(ArrayView<Request> requests) override;
133
134 ARCANE_DEPRECATED_260 Real reduceRank(eReduceType rt, Real v, Int32* rank)
135 {
136 Real rv = reduce(rt, v);
137 if (rank)
138 *rank = 0;
139 return rv;
140 }
141
143
144 void build() override;
145
146 IParallelMngInternal* _internalApi() override { return m_parallel_mng_internal; }
147
148 public:
149
150 IThreadBarrier* getThreadBarrier()
151 {
152 return m_thread_barrier;
153 }
154
155 public:
156
158 PointToPointMessageInfo buildMessage(Int32 dest, MP::eBlockingType is_blocking);
160
161 protected:
162
168 IVariableSynchronizer* createSynchronizer(const ItemGroup& group) override;
169 Parallel::IStat* stat() override { return m_stat; }
170 IParallelReplication* replication() const override;
171 void setReplication(IParallelReplication* v) override;
172 Ref<Parallel::IRequestList> createRequestListRef() override;
173 Ref<IParallelMng> createSubParallelMngRef(Int32ConstArrayView kept_ranks) override;
174 Ref<IParallelMngUtilsFactory> _internalUtilsFactory() const override;
175
176 protected:
177
178 ISerializeMessageList* _createSerializeMessageList() override;
179 IParallelMng* _createSubParallelMng(Int32ConstArrayView kept_ranks) override;
180 bool _isAcceleratorAware() const override { return true; }
181
182 private:
183
185 IThreadMng* m_thread_mng;
186 Ref<IParallelMng> m_sequential_parallel_mng;
187 ITimerMng* m_timer_mng;
188 IParallelReplication* m_replication;
189 IParallelMng* m_world_parallel_mng;
190 IIOMng* m_io_mng;
191 ISharedMemoryMessageQueue* m_message_queue;
192 bool m_is_parallel;
196 Parallel::IStat* m_stat;
197 IThreadBarrier* m_thread_barrier;
198 SharedMemoryAllDispatcher* m_all_dispatchers;
199 IParallelMngContainerFactory* m_sub_builder_factory;
200 Ref<IParallelMngContainer> m_parent_container_ref;
201 MP::Communicator m_mpi_communicator;
202 Ref<IParallelMngUtilsFactory> m_utils_factory;
203 IParallelMngInternal* m_parallel_mng_internal = nullptr;
204};
205
206/*---------------------------------------------------------------------------*/
207/*---------------------------------------------------------------------------*/
208
209} // End namespace Arcane::MessagePassing
210
211/*---------------------------------------------------------------------------*/
212/*---------------------------------------------------------------------------*/
213
214#endif
Modifiable view of an array of type T.
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
Information about the source of a message.
Information for sending/receiving a point-to-point message.
Implementation of IRequestList for SharedMemoryParallelMng.
IParallelTopology * createTopology() override
Creates an instance containing information about the rank topology of this manager.
IGetVariablesValuesParallelOperation * createGetVariablesValuesOperation() override
Returns an operation to retrieve the values of a variable on the entities of another subdomain.
bool isThreadImplementation() const override
Indicates if the implementation uses threads.
bool isMasterIO() const override
true if the instance is a master I/O manager.
Integer masterIORank() const override
Rank of the instance managing I/O (for which isMasterIO() is true).
IParallelNonBlockingCollective * nonBlockingCollective() const override
Interface for non-blocking collective operations.
PointToPointMessageInfo buildMessage(Int32 dest, MP::eBlockingType is_blocking)
Constructs a message with destination dest.
IParallelMng * worldParallelMng() const override
Parallelism manager over all allocated resources.
Parallel::IStat * stat() override
Statistics manager.
IParallelMngInternal * _internalApi() override
Internal Arcane API.
IVariableSynchronizer * createSynchronizer(IItemFamily *family) override
Returns an interface for synchronizing variables on the group of the family.
MP::Communicator communicator() const override
MPI communicator associated with this manager.
ITraceMng * traceMng() const override
Trace manager.
bool isParallel() const override
Returns true if the execution is parallel.
bool isHybridImplementation() const override
Indicates if the implementation uses hybrid mode.
Int32 commSize() const override
Number of instances in the communicator.
MP::Communicator machineCommunicator() const override
MPI communicator derived from the communicator communicator() gathering all processes of the compute ...
Int32 commRank() const override
Rank of this instance in the communicator.
IParallelExchanger * createExchanger() override
Returns an interface for transferring messages between processors.
IThreadMng * threadMng() const override
Thread manager.
void * getMPICommunicator() override
Address of the MPI communicator associated with this manager.
ITransferValuesParallelOperation * createTransferValuesOperation() override
Returns an operation to transfer values between subdomains.
ITimerMng * timerMng() const override
Timer manager.
Reference to an instance.
Encapsulation of a pointer with a reference counter.
Implementation of a buffer for serialization.
Declarations of types and methods used by message exchange mechanisms.
eReduceType
Supported reduction types.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
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
double Real
Type representing a real number.
std::int32_t Int32
Signed integer type of 32 bits.