16#include "arccore/base/NotSupportedException.h"
17#include "arccore/base/FatalErrorException.h"
18#include "arccore/base/NotImplementedException.h"
20#include "arccore/serialize/BasicSerializer.h"
21#include "arccore/serialize/internal/BasicSerializerInternal.h"
23#include "arccore/message_passing/BasicSerializeMessage.h"
24#include "arccore/message_passing/ISerializeDispatcher.h"
25#include "arccore/message_passing/IControlDispatcher.h"
26#include "arccore/message_passing/MessageId.h"
27#include "arccore/message_passing/PointToPointMessageInfo.h"
51 template <
typename DataType>
void
56 recv_buffer.
copy(buf);
63void BasicSerializeGatherMessage::
89 sizes[0] = send_real.
size();
90 sizes[1] = send_int16.
size();
91 sizes[2] = send_int32.
size();
92 sizes[3] = send_int64.
size();
93 sizes[4] = send_byte.
size();
94 sizes[5] = send_int8.
size();
95 sizes[6] = send_float16.
size();
96 sizes[7] = send_bfloat16.
size();
97 sizes[8] = send_float32.
size();
98 sizes[9] = send_float128.
size();
99 sizes[10] = send_int128.
size();
103 Int64 recv_nb_real = sizes[0];
104 Int64 recv_nb_int16 = sizes[1];
105 Int64 recv_nb_int32 = sizes[2];
106 Int64 recv_nb_int64 = sizes[3];
107 Int64 recv_nb_byte = sizes[4];
108 Int64 recv_nb_int8 = sizes[5];
109 Int64 recv_nb_float16 = sizes[6];
110 Int64 recv_nb_bfloat16 = sizes[7];
111 Int64 recv_nb_float32 = sizes[8];
112 Int64 recv_nb_float128 = sizes[9];
113 Int64 recv_nb_int128 = sizes[10];
115 if (recv_nb_float16 != 0)
117 if (recv_nb_bfloat16 != 0)
119 if (recv_nb_float128 != 0)
121 if (recv_nb_int128 != 0)
124 recv_p2->allocateBuffer(recv_nb_real, recv_nb_int16, recv_nb_int32, recv_nb_int64, recv_nb_byte,
125 recv_nb_int8, recv_nb_float16, recv_nb_bfloat16, recv_nb_float32, recv_nb_float128, recv_nb_int128);
127 auto recv_p = recv_buf->_p();
129 _doGatherOne(pm, send_real, recv_p->getRealBuffer());
130 _doGatherOne(pm, send_int32, recv_p->getInt32Buffer());
131 _doGatherOne(pm, send_int16, recv_p->getInt16Buffer());
132 _doGatherOne(pm, send_int64, recv_p->getInt64Buffer());
133 _doGatherOne(pm, send_byte, recv_p->getByteBuffer());
134 _doGatherOne(pm, send_int8, recv_p->getInt8Buffer());
135 _doGatherOne(pm, send_float32, recv_p->getFloat32Buffer());
157 auto d = pm->dispatchers()->controlDispatcher();
166 auto d = pm->dispatchers()->controlDispatcher();
167 d->waitAllRequests(requests);
183 auto d = pm->dispatchers()->controlDispatcher();
184 d->waitSomeRequests(requests, indexes,
false);
192 auto d = pm->dispatchers()->controlDispatcher();
193 d->waitSomeRequests(requests, indexes,
true);
222 auto d = pm->dispatchers()->controlDispatcher();
223 return d->probe(message);
232 auto d = pm->dispatchers()->controlDispatcher();
233 return d->legacyProbe(message);
242 auto d = pm->dispatchers()->controlDispatcher();
243 return d->commSplit(keep);
252 auto d = pm->dispatchers()->controlDispatcher();
253 return d->splitCommunicator(keep);
261 auto d = pm->dispatchers()->controlDispatcher();
271 auto d = pm->dispatchers()->controlDispatcher();
272 return d->nonBlockingBarrier();
281 auto d = pm->dispatchers()->serializeDispatcher();
292 auto d = pm->dispatchers()->serializeDispatcher();
303 auto d = pm->dispatchers()->serializeDispatcher();
326 ARCCORE_FATAL(
"receive_serializer is not a BasicSerializer");
328 message.doAllGather(pm, s, r);
367 DataType* x =
nullptr;
368 auto* dispatcher = pm->dispatchers()->dispatcher(x);
374#define ARCCORE_GENERATE_MESSAGEPASSING_DEFINITION(type) \
375 void mpAllGather(IMessagePassingMng* pm, Span<const type> send_buf, Span<type> recv_buf) \
377 _getDispatcher<type>(pm)->allGather(send_buf, recv_buf); \
379 void mpGather(IMessagePassingMng* pm, Span<const type> send_buf, Span<type> recv_buf, Int32 rank) \
381 _getDispatcher<type>(pm)->gather(send_buf, recv_buf, rank); \
383 Request mpNonBlockingAllGather(IMessagePassingMng* pm, Span<const type> send_buf, Span<type> recv_buf) \
385 return _getDispatcher<type>(pm)->nonBlockingAllGather(send_buf, recv_buf); \
387 Request mpNonBlockingGather(IMessagePassingMng* pm, Span<const type> send_buf, Span<type> recv_buf, Int32 rank) \
389 return _getDispatcher<type>(pm)->nonBlockingGather(send_buf, recv_buf, rank); \
391 void mpAllGatherVariable(IMessagePassingMng* pm, Span<const type> send_buf, Array<type>& recv_buf) \
393 _getDispatcher<type>(pm)->allGatherVariable(send_buf, recv_buf); \
395 void mpGatherVariable(IMessagePassingMng* pm, Span<const type> send_buf, Array<type>& recv_buf, Int32 rank) \
397 _getDispatcher<type>(pm)->gatherVariable(send_buf, recv_buf, rank); \
399 Request mpGather(IMessagePassingMng* pm, GatherMessageInfo<type>& gather_info) \
401 return _getDispatcher<type>(pm)->gather(gather_info); \
403 void mpScatterVariable(IMessagePassingMng* pm, Span<const type> send_buf, Span<type> recv_buf, Int32 root) \
405 return _getDispatcher<type>(pm)->scatterVariable(send_buf, recv_buf, root); \
407 type mpAllReduce(IMessagePassingMng* pm, eReduceType rt, type v) \
409 return _getDispatcher<type>(pm)->allReduce(rt, v); \
411 void mpAllReduce(IMessagePassingMng* pm, eReduceType rt, Span<type> buf) \
413 _getDispatcher<type>(pm)->allReduce(rt, buf); \
415 void mpAllReduce(IMessagePassingMng* pm, eReduceType rt, Span<const type> send_buf, Span<type> receive_buf) \
417 _getDispatcher<type>(pm)->allReduce(rt, send_buf, receive_buf); \
419 void mpScanExclusive(IMessagePassingMng* pm, eReduceType rt, Span<const type> send_buf, Span<type> receive_buf) \
421 _getDispatcher<type>(pm)->scanExclusive(rt, send_buf, receive_buf); \
423 Request mpNonBlockingAllReduce(IMessagePassingMng* pm, eReduceType rt, Span<const type> send_buf, Span<type> recv_buf) \
425 return _getDispatcher<type>(pm)->nonBlockingAllReduce(rt, send_buf, recv_buf); \
427 void mpBroadcast(IMessagePassingMng* pm, Span<type> send_buf, Int32 rank) \
429 _getDispatcher<type>(pm)->broadcast(send_buf, rank); \
431 Request mpNonBlockingBroadcast(IMessagePassingMng* pm, Span<type> send_buf, Int32 rank) \
433 return _getDispatcher<type>(pm)->nonBlockingBroadcast(send_buf, rank); \
435 void mpSend(IMessagePassingMng* pm, Span<const type> values, Int32 rank) \
437 _getDispatcher<type>(pm)->send(values, rank, true); \
439 void mpReceive(IMessagePassingMng* pm, Span<type> values, Int32 rank) \
441 _getDispatcher<type>(pm)->receive(values, rank, true); \
443 Request mpSend(IMessagePassingMng* pm, Span<const type> values, Int32 rank, bool is_blocked) \
445 return _getDispatcher<type>(pm)->send(values, rank, is_blocked); \
447 Request mpSend(IMessagePassingMng* pm, Span<const type> values, const PointToPointMessageInfo& message) \
449 return _getDispatcher<type>(pm)->send(values, message); \
451 Request mpReceive(IMessagePassingMng* pm, Span<type> values, Int32 rank, bool is_blocked) \
453 return _getDispatcher<type>(pm)->receive(values, rank, is_blocked); \
455 Request mpReceive(IMessagePassingMng* pm, Span<type> values, const PointToPointMessageInfo& message) \
457 return _getDispatcher<type>(pm)->receive(values, message); \
459 void mpAllToAll(IMessagePassingMng* pm, Span<const type> send_buf, Span<type> recv_buf, Int32 count) \
461 return _getDispatcher<type>(pm)->allToAll(send_buf, recv_buf, count); \
463 Request mpNonBlockingAllToAll(IMessagePassingMng* pm, Span<const type> send_buf, Span<type> recv_buf, Int32 count) \
465 return _getDispatcher<type>(pm)->nonBlockingAllToAll(send_buf, recv_buf, count); \
467 void mpAllToAllVariable(IMessagePassingMng* pm, Span<const type> send_buf, ConstArrayView<Int32> send_count, \
468 ConstArrayView<Int32> send_index, Span<type> recv_buf, \
469 ConstArrayView<Int32> recv_count, ConstArrayView<Int32> recv_index) \
471 _getDispatcher<type>(pm)->allToAllVariable(send_buf, send_count, send_index, recv_buf, recv_count, recv_index); \
473 Request mpNonBlockingAllToAllVariable(IMessagePassingMng* pm, Span<const type> send_buf, ConstArrayView<Int32> send_count, \
474 ConstArrayView<Int32> send_index, Span<type> recv_buf, \
475 ConstArrayView<Int32> recv_count, ConstArrayView<Int32> recv_index) \
477 return _getDispatcher<type>(pm)->nonBlockingAllToAllVariable(send_buf, send_count, send_index, recv_buf, recv_count, recv_index); \
483ARCCORE_GENERATE_MESSAGEPASSING_DEFINITION(
char)
484ARCCORE_GENERATE_MESSAGEPASSING_DEFINITION(
signed char)
485ARCCORE_GENERATE_MESSAGEPASSING_DEFINITION(
unsigned char)
487ARCCORE_GENERATE_MESSAGEPASSING_DEFINITION(
short)
488ARCCORE_GENERATE_MESSAGEPASSING_DEFINITION(
unsigned short)
489ARCCORE_GENERATE_MESSAGEPASSING_DEFINITION(
int)
490ARCCORE_GENERATE_MESSAGEPASSING_DEFINITION(
unsigned int)
491ARCCORE_GENERATE_MESSAGEPASSING_DEFINITION(
long)
492ARCCORE_GENERATE_MESSAGEPASSING_DEFINITION(
unsigned long)
493ARCCORE_GENERATE_MESSAGEPASSING_DEFINITION(
long long)
494ARCCORE_GENERATE_MESSAGEPASSING_DEFINITION(
unsigned long long)
496ARCCORE_GENERATE_MESSAGEPASSING_DEFINITION(
float)
497ARCCORE_GENERATE_MESSAGEPASSING_DEFINITION(
double)
498ARCCORE_GENERATE_MESSAGEPASSING_DEFINITION(
long double)
500ARCCORE_GENERATE_MESSAGEPASSING_DEFINITION(BFloat16)
501ARCCORE_GENERATE_MESSAGEPASSING_DEFINITION(
Float16)
#define ARCCORE_FATAL(...)
Macro throwing a FatalErrorException.
#define ARCCORE_THROW(exception_class,...)
Macro to throw an exception with formatting.
#define ARCCORE_CHECK_POINTER(ptr)
Macro that returns the pointer ptr if it is not null or throws an exception if it is null.
Brief list of message exchange functions.
Modifiable view of an array of type T.
void fill(const T &o) noexcept
Fills the array with the value o.
Basic implementation of 'ISerializer'.
virtual Ref< IRequestList > createRequestListRef()=0
Creation of a request list associated with this manager.
Interface of the message passing manager.
virtual Int32 commRank() const =0
Rank of this instance in the communicator.
virtual Request receiveSerializer(ISerializer *s, const PointToPointMessageInfo &message)=0
Receiving message.
virtual Request sendSerializer(const ISerializer *s, const PointToPointMessageInfo &message)=0
Sending message.
virtual Ref< ISerializeMessageList > createSerializeMessageListRef()=0
Create a list of serialization messages.
Parallel message handling for the type Type.
Information about the source of a message.
Information for sending/receiving a point-to-point message.
Exception when a function is not implemented.
Exception when an operation is not supported.
Reference to an instance.
__host__ __device__ void copy(const U ©_array)
Copies the array copy_array into the instance.
constexpr __host__ __device__ SizeType size() const noexcept
Returns the size of the array.
View of an array of elements of type T.
1D data vector with value semantics (STL style).
Declarations of types and methods used by message exchange mechanisms.
Ref< ISerializeMessage > mpCreateSerializeMessage(IMessagePassingMng *pm, MessageRank target, ePointToPointMessageType type)
Creates a serialization message.
void mpTestSome(IMessagePassingMng *pm, ArrayView< Request > requests, ArrayView< bool > indexes)
Tests if any of the requests in request are finished.
Ref< ISerializeMessageList > mpCreateSerializeMessageListRef(IMessagePassingMng *pm)
Creates a serialization message list.
Ref< ISerializeMessage > mpCreateSendSerializeMessage(IMessagePassingMng *pm, MessageRank destination)
Creates a serialization message for sending.
MessageSourceInfo mpLegacyProbe(IMessagePassingMng *pm, const PointToPointMessageInfo &message)
Tests if a message is available.
Ref< IMessagePassingMng > mpSplitCommunicator(IMessagePassingMng *pm, bool keep)
Creates a sub communicator.
Ref< ISerializeMessage > mpCreateReceiveSerializeMessage(IMessagePassingMng *pm, MessageRank source)
Creates a serialization message for receiving.
MessageId mpProbe(IMessagePassingMng *pm, const PointToPointMessageInfo &message)
Tests if a message is available.
C char mpAllReduce(IMessagePassingMng *pm, eReduceType rt, char v)
Ref< IRequestList > mpCreateRequestListRef(IMessagePassingMng *pm)
Creates a list of requests.
C void mpAllGatherVariable(IMessagePassingMng *pm, Span< const char > send_buf, Array< char > &recv_buf)
@ WaitSome
Wait until all messages in the list are processed.
void mpBarrier(IMessagePassingMng *pm)
Performs a barrier.
Request mpNonBlockingBarrier(IMessagePassingMng *pm)
Performs a non-blocking barrier.
void mpWait(IMessagePassingMng *pm, Request request)
Blocks until the request request is finished.
void mpAllGather(IMessagePassingMng *pm, const ISerializer *send_serializer, ISerializer *receive_serialize)
allGather() message for serialization
void mpWaitAll(IMessagePassingMng *pm, ArrayView< Request > requests)
Blocks until the requests in requests are finished.
IMessagePassingMng * mpSplit(IMessagePassingMng *pm, bool keep)
Creates a sub communicator.
ePointToPointMessageType
Point-to-point message type.
@ ReduceSum
Sum of values.
Request mpReceive(IMessagePassingMng *pm, ISerializer *values, const PointToPointMessageInfo &message)
Receive message using an ISerializer.
void mpWaitSome(IMessagePassingMng *pm, ArrayView< Request > requests, ArrayView< bool > indexes)
Blocks until at least one of the requests in request is finished.
Request mpSend(IMessagePassingMng *pm, const ISerializer *values, const PointToPointMessageInfo &message)
Send message using an ISerializer.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
@ Float16
Float16 data type.