Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
MpiSerializeDispatcher.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/* MpiSerializeDispatcher.h (C) 2000-2025 */
9/* */
10/* Serialization message handling with MPI. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCCORE_MESSAGEPASSINGMPI_INTERNAL_MPISERIALIZEDISPATCHER_H
13#define ARCCORE_MESSAGEPASSINGMPI_INTERNAL_MPISERIALIZEDISPATCHER_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/message_passing_mpi/MessagePassingMpiGlobal.h"
18#include "arccore/message_passing/ISerializeDispatcher.h"
19#include "arccore/message_passing/Request.h"
20#include "arccore/collections/Array.h"
21#include "arccore/serialize/SerializeGlobal.h"
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27namespace Arcane::MessagePassing::Mpi
28{
29class ARCCORE_MESSAGEPASSINGMPI_EXPORT MpiSerializeDispatcher
31{
32 friend MpiSerializeMessageList;
35
36 public:
37
39 {
40 public:
41
42 static const int MAX_REQUEST_SIZE = 256;
43
44 public:
45
46 Byte m_bytes[MAX_REQUEST_SIZE];
47 Request m_request;
48 };
49
50 public:
51
52 explicit MpiSerializeDispatcher(MpiAdapter* adapter, IMessagePassingMng* message_passing_mng);
53 ~MpiSerializeDispatcher() override;
54
55 public:
56
58 Request sendSerializer(const ISerializer* s, const PointToPointMessageInfo& message) override;
60
61 public:
62
63 // These methods are specific to the MPI version.
65 Int64 serializeBufferSize() const { return m_serialize_buffer_size; }
66 Request legacySendSerializer(ISerializer* values, const PointToPointMessageInfo& message);
67 Request sendSerializer(const ISerializer* s, const PointToPointMessageInfo& message, bool force_one_message);
68 void legacyReceiveSerializer(ISerializer* values, MessageRank rank, MessageTag mpi_tag);
69 void checkFinishedSubRequests();
70 MpiAdapter* adapter() const { return m_adapter; }
71 static MessageTag nextSerializeTag(MessageTag tag);
73
74 void broadcastSerializer(ISerializer* values, MessageRank rank);
75 ITraceMng* traceMng() const { return m_trace; }
76
77 protected:
78
79 // These two methods are also used by 'MpiSerializeMessageList'
80 Request _recvSerializerBytes(Span<Byte> bytes, MessageRank rank, MessageTag tag, bool is_blocking);
81 Request _recvSerializerBytes(Span<Byte> bytes, MessageId message_id, bool is_blocking);
82
83 private:
84
85 MpiAdapter* m_adapter = nullptr;
86 IMessagePassingMng* m_message_passing_mng = nullptr;
87 ITraceMng* m_trace = nullptr;
88 Int64 m_serialize_buffer_size;
89 Int64 m_max_serialize_buffer_size;
91 bool m_is_trace_serializer = false;
92 MPI_Datatype m_byte_serializer_datatype;
93
94 private:
95
96 BasicSerializer* _castSerializer(ISerializer* serializer);
97 const BasicSerializer* _castSerializer(const ISerializer* serializer);
98 void _checkBigMessage(Int64 message_size);
99 Request _sendSerializerWithTag(ISerializer* values, MessageRank rank,
100 MessageTag mpi_tag, bool is_blocking);
101 Request _sendSerializerBytes(Span<const Byte> bytes, MessageRank rank,
102 MessageTag tag, bool is_blocking);
103 void _init();
104};
105
106/*---------------------------------------------------------------------------*/
107/*---------------------------------------------------------------------------*/
108
109} // namespace Arcane::MessagePassing::Mpi
110
111/*---------------------------------------------------------------------------*/
112/*---------------------------------------------------------------------------*/
113
114#endif
Declarations of types for the 'base' component of Arccore.
Basic implementation of 'ISerializer'.
Interface of the message passing manager.
Interface for serialization messages.
Request receiveSerializer(ISerializer *s, const PointToPointMessageInfo &message) override
Receiving message.
Ref< ISerializeMessageList > createSerializeMessageListRef() override
Create a list of serialization messages.
Request sendSerializer(const ISerializer *s, const PointToPointMessageInfo &message) override
Sending message.
Information for sending/receiving a point-to-point message.
Reference to an instance.
View of an array of elements of type T.
Definition Span.h:635
1D data vector with value semantics (STL style).
std::int64_t Int64
Signed integer type of 64 bits.
unsigned char Byte
Type of a byte.
Definition BaseTypes.h:43