Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
ITransferValuesParallelOperation.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/* ITransferValuesParallelOperation.h (C) 2000-2025 */
9/* */
10/* Value transfer across different processors. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_ITRANSFERVALUESPARALLELOPERATION_H
13#define ARCANE_CORE_ITRANSFERVALUESPARALLELOPERATION_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/Array.h"
18
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30/*!
31 * \brief Sends values across different processors.
32 *
33 * This operation allows values to be communicated with other
34 * processors. The array \a ranks indicates for each element the rank
35 * of the processor it is intended for. It is then possible to specify
36 * arrays containing the values to send and to receive. The
37 * send arrays must have the same number of elements as \a ranks
38 *
39 * An instance is used only once. Once the transfer is complete,
40 * it can be destroyed.
41 *
42 * For example, for a case with 3 processors:
43 * \code
44 * // Processor of rank 0:
45 * Int32UniqueArray ranks;
46 * ranks.add(2); // Sends to rank 2
47 * ranks.add(1); // Sends to rank 1
48 * ranks.add(1); // Sends to rank 1
49 * Int32UniqueArray values_1;
50 * values_1.add(5); // Sends 5 to rank 2 (ranks[0])
51 * values_1.add(7); // Sends 7 to rank 1 (ranks[1])
52 * values_1.add(6); // Sends 6 to rank 1 (ranks[2])
53 * Int64UniqueArray values_2;
54 * values_2.add(-5); // Sends -5 to rank 2 (ranks[0])
55 * values_2.add(-7); // Sends -7 to rank 1 (ranks[1])
56 * values_2.add(-6); // Sends -6 to rank 1 (ranks[2])
57
58 * // Processor of rank 1:
59 * Int32UniqueArray ranks;
60 * ranks.add(0); // Sends to rank 0
61 * ranks.add(2); // Sends to rank 2
62 * Int32UniqueArray values_1;
63 * values_1.add(1); // Sends 1 to rank 0 (ranks[0])
64 * values_1.add(3); // Sends 3 to rank 2 (ranks[1])
65 * Int64UniqueArray values_2;
66 * values_2.add(23); // Sends 23 to rank 0 (ranks[0])
67 * values_2.add(24); // Sends 24 to rank 2 (ranks[1])
68
69 * // Processor of rank 2:
70 * Int32UniqueArray ranks;
71 * ranks.add(0); // Sends to rank 0
72 * ranks.add(0); // Sends to rank 0
73 * Int32UniqueArray values_1;
74 * values_1.add(0); // Sends 1 to rank 0 (ranks[0])
75 * values_1.add(4); // Sends 3 to rank 0 (ranks[1])
76 * Int64UniqueArray values_2;
77 * values_2.add(-1); // Sends -1 to rank 0 (ranks[0])
78 * values_2.add(4); // Sends 4 to rank 0 (ranks[1])
79
80 * \endcode
81 *
82 * To perform the transfer
83 *
84 * \code
85 * Int32UniqueArray recv_values_1;
86 * Int64UniqueArray recv_values_2;
87 * op->setTransferRanks(ranks);
88 * op->addArray(values_1,recv_values_1);
89 * op->addArray(values_2,recv_values_2);
90 * op->transferValues();
91 * \endcode
92 *
93 * After sending, processor of rank 0 will have the following values:
94 * \code
95 * recv_values_1[0] == 1; // sent by rank 1
96 * recv_values_1[1] == 0; // sent by rank 2
97 * recv_values_1[2] == 4; // sent by rank 2
98 * recv_values_2[0] == 23; // sent by rank 1
99 * recv_values_2[1] == -1; // sent by rank 2
100 * recv_values_2[2] == 4; // sent by rank 2
101 * \endcode
102 *
103 * Note that the order of elements is undetermined
104 */
105class ARCANE_CORE_EXPORT ITransferValuesParallelOperation
106{
107 public:
108
109 //! Destructor
111
112 public:
113
114 //! Associated parallelism manager
115 virtual IParallelMng* parallelMng() = 0;
116
117 public:
118
119 //! Positions the array indicating who to send the values to.
120 virtual void setTransferRanks(Int32ConstArrayView ranks) = 0;
121 //! Adds an array of \c Int32
122 virtual void addArray(Int32ConstArrayView send_values, SharedArray<Int32> recv_value) = 0;
123 //! Adds an array of \c Int64
124 virtual void addArray(Int64ConstArrayView send_values, SharedArray<Int64> recv_values) = 0;
125 //! Adds an array of \c Int64
126 virtual void addArray(RealConstArrayView send_values, SharedArray<Real> recv_values) = 0;
127 /*!
128 * \brief Sends and receives values.
129 *
130 * This call is collective and blocking.
131 */
132 virtual void transferValues() = 0;
133};
134
135/*---------------------------------------------------------------------------*/
136/*---------------------------------------------------------------------------*/
137
138} // namespace Arcane
139
140/*---------------------------------------------------------------------------*/
141/*---------------------------------------------------------------------------*/
142
143#endif
Declarations of Arcane's general types.
Interface of the parallelism manager for a subdomain.
Sends values across different processors.
virtual void addArray(Int32ConstArrayView send_values, SharedArray< Int32 > recv_value)=0
Adds an array of Int32.
virtual void addArray(RealConstArrayView send_values, SharedArray< Real > recv_values)=0
Adds an array of Int64.
virtual ~ITransferValuesParallelOperation()=default
Destructor.
virtual void transferValues()=0
Sends and receives values.
virtual void addArray(Int64ConstArrayView send_values, SharedArray< Int64 > recv_values)=0
Adds an array of Int64.
virtual IParallelMng * parallelMng()=0
Associated parallelism manager.
virtual void setTransferRanks(Int32ConstArrayView ranks)=0
Positions the array indicating who to send the values to.
1D vector of data with reference semantics.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
ConstArrayView< Int64 > Int64ConstArrayView
C equivalent of a 1D array of 64-bit integers.
Definition UtilsTypes.h:480
ConstArrayView< Real > RealConstArrayView
C equivalent of a 1D array of reals.
Definition UtilsTypes.h:488