Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
IParallelExchanger.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/* IParallelExchanger.h (C) 2000-2025 */
9/* */
10/* Information exchange between processors. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_IPARALLELEXCHANGER_H
13#define ARCANE_CORE_IPARALLELEXCHANGER_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
19#include "arcane/core/ParallelExchangerOptions.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30/*!
31 * \brief Information exchange between processors.
32 *
33 * This class allows sending and receiving arbitrary messages
34 * from any number of other processors.
35 *
36 * The operation is as follows.
37 *
38 * 1. indicate the other PEs you wish to communicate with by calling
39 * addSender(), possibly multiple times.
40 * 2. call initializeCommunicationsMessages() to determine the list of
41 * PEs from which we must receive information. There are two overloads
42 * for this method depending on whether we know the number of ranks for
43 * which we must receive information.
44 * 3. for each outgoing message, serialize the information you wish
45 * to send.
46 * 4. perform the sends and receives by calling processExchange()
47 * 5. retrieve the received messages (via messageToReceive()) and deserialize
48 * their information.
49 *
50 * It is possible to specify, before calling processExchange(), how
51 * the messages will be sent via setExchangeMode(). By default, the mechanism
52 * used is that of point-to-point communications (EM_Independant) but it
53 * is possible to use a collective mode (EM_Collective) which uses
54 * 'all to all' type messages.
55 */
56class ARCANE_CORE_EXPORT IParallelExchanger
57{
58 public:
59
61 {
62 //! Uses point-to-point exchanges (send/recv)
64 //! Uses collective operations (allToAll)
66 //! Automatically chooses between point-to-point or collective.
68 };
69
70 public:
71
72 virtual ~IParallelExchanger() = default;
73
74 public:
75
76 /*!
77 * \brief Calculates communications.
78 *
79 * Based on \a m_send_ranks provided by each processor,
80 * determines the list of processors to which a message must be sent.
81 *
82 * To know the processors from which information is expected,
83 * it is necessary to perform a communication (allGatherVariable()). If we know
84 * these processors beforehand, we must use one of the overloaded versions of this
85 * method.
86 *
87 * \retval true if there is nothing to exchange
88 * \retval false otherwise.
89 */
91
92 /*! \brief Calculates communications.
93 *
94 * Assumes that the list of processors from which information is desired is in
95 * \a recv_ranks.
96 */
98
99 //! Performs the exchange using the default options of ParallelExchangerOptions.
100 virtual void processExchange() = 0;
101
102 //! Performs the exchange using the options \a options
103 virtual void processExchange(const ParallelExchangerOptions& options) = 0;
104
105 public:
106
107 virtual IParallelMng* parallelMng() const = 0;
108
109 //! Number of processors to which we send
110 virtual Integer nbSender() const = 0;
111 //! List of ranks of processors to which we send
112 virtual Int32ConstArrayView senderRanks() const = 0;
113 //! Adds a processor to send to
114 virtual void addSender(Int32 rank) = 0;
115 //! Message intended for the \a i-th processor
117
118 //! Number of processors from which we will receive messages
119 virtual Integer nbReceiver() const = 0;
120 //! List of ranks of processors from which we will receive messages
122 //! Message received from the \a i-th processor
124
125 //! Sets the exchange mode.
126 [[deprecated("Y2021: Use ParallelExchangerOptions::setExchangeMode()")]]
127 virtual void setExchangeMode(eExchangeMode mode) = 0;
128 //! Specified exchange mode
129 [[deprecated("Y2021: Use ParallelExchangerOptions::exchangeMode()")]]
130 virtual eExchangeMode exchangeMode() const = 0;
131
132 //! Sets the verbosity level
133 virtual void setVerbosityLevel(Int32 v) = 0;
134 //! Verbosity level
135 virtual Int32 verbosityLevel() const = 0;
136
137 //! Sets the instance name. This name is used during prints
138 virtual void setName(const String& name) = 0;
139 //! Instance name
140 virtual String name() const = 0;
141};
142
143/*---------------------------------------------------------------------------*/
144/*---------------------------------------------------------------------------*/
145
146} // namespace Arcane
147
148/*---------------------------------------------------------------------------*/
149/*---------------------------------------------------------------------------*/
150
151#endif
Declarations of Arcane's general types.
File containing declarations concerning the message passing model.
Information exchange between processors.
virtual void addSender(Int32 rank)=0
Adds a processor to send to.
@ EM_Independant
Uses point-to-point exchanges (send/recv).
@ EM_Collective
Uses collective operations (allToAll).
@ EM_Auto
Automatically chooses between point-to-point or collective.
virtual void setName(const String &name)=0
Sets the instance name. This name is used during prints.
virtual Integer nbSender() const =0
Number of processors to which we send.
virtual void setExchangeMode(eExchangeMode mode)=0
Sets the exchange mode.
virtual Integer nbReceiver() const =0
Number of processors from which we will receive messages.
virtual String name() const =0
Instance name.
virtual void initializeCommunicationsMessages(Int32ConstArrayView recv_ranks)=0
Calculates communications.
virtual void setVerbosityLevel(Int32 v)=0
Sets the verbosity level.
virtual Int32 verbosityLevel() const =0
Verbosity level.
virtual eExchangeMode exchangeMode() const =0
Specified exchange mode.
virtual bool initializeCommunicationsMessages()=0
Calculates communications.
virtual ISerializeMessage * messageToSend(Integer i)=0
Message intended for the i-th processor.
virtual void processExchange()=0
Performs the exchange using the default options of ParallelExchangerOptions.
virtual void processExchange(const ParallelExchangerOptions &options)=0
Performs the exchange using the options options.
virtual Int32ConstArrayView senderRanks() const =0
List of ranks of processors to which we send.
virtual Int32ConstArrayView receiverRanks()=0
List of ranks of processors from which we will receive messages.
virtual ISerializeMessage * messageToReceive(Integer i)=0
Message received from the i-th processor.
Interface of the parallelism manager for a subdomain.
Options for IParallelMng::processExchange().
@ EM_Auto
Automatically chooses between point-to-point or collective.
@ EM_Collective
Uses collective operations (allToAll).
@ EM_Independant
Uses point-to-point exchanges (send/recv).
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
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.