Alien  1.3.0
User documentation
Loading...
Searching...
No Matches
VectorDistribution.h
Go to the documentation of this file.
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2025 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/*!
9 * \file VectorDistribution.h
10 * \brief VectorDistribution.h
11 */
12
13#pragma once
14
15#include <arccore/message_passing/MessagePassingGlobal.h>
16#include "alien/data/ISpace.h"
17
18/*---------------------------------------------------------------------------*/
19/*---------------------------------------------------------------------------*/
20
21namespace Alien
22{
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27/*!
28 * \ingroup distribution
29 * \brief Computes a vector distribution
30 *
31 * Computes or use a pre-existing block row distribution for vectors
32 */
33class ALIEN_EXPORT VectorDistribution
34{
35 public:
36 //! Constructor
38
39 /*!
40 * \brief Constructor
41 * \param[in] space The space of the vector
42 * \param[in] parallel_mng The parallel manager
43 */
45 const ISpace& space, Arccore::MessagePassing::IMessagePassingMng* parallel_mng);
46
47 /*!
48 * \brief Constructor
49 * \param[in] space The space of the vector
50 * \param[in] parallel_mng The parallel manager
51 */
53 std::shared_ptr<Arccore::MessagePassing::IMessagePassingMng> parallel_mng);
54
55 /*!
56 * \brief Constructor
57 * \param[in] global_size The global size of the vector
58 * \param[in] parallel_mng The parallel manager
59 */
60 VectorDistribution(Arccore::Integer global_size,
61 Arccore::MessagePassing::IMessagePassingMng* parallel_mng);
62
63 /*!
64 * \brief Constructor
65 * \param[in] global_size The global size of the vector
66 * \param[in] parallel_mng The parallel manager
67 */
68 // FIXME: not implemented !
69 VectorDistribution(Arccore::Integer global_size,
70 std::shared_ptr<Arccore::MessagePassing::IMessagePassingMng> parallel_mng);
71
72 /*!
73 * \brief Constructor
74 * \param[in] space The space of the vector
75 * \param[in] local_size The local size of the vector
76 * \param[in] parallel_mng The parallel manager
77 */
78 VectorDistribution(const ISpace& space, Arccore::Integer local_size,
79 Arccore::MessagePassing::IMessagePassingMng* parallel_mng);
80
81 /*!
82 * \brief Constructor
83 * \param[in] space The space of the vector
84 * \param[in] local_size The local size of the vector
85 * \param[in] parallel_mng The parallel manager
86 */
87 VectorDistribution(const ISpace& space, Arccore::Integer local_size,
88 std::shared_ptr<Arccore::MessagePassing::IMessagePassingMng> parallel_mng);
89
90 /*!
91 * \brief Constructor
92 * \param[in] global_size The global size of the vector
93 * \param[in] local_size The local size of the vector
94 * \param[in] parallel_mng The parallel manager
95 */
96 VectorDistribution(Arccore::Integer global_size, Arccore::Integer local_size,
97 Arccore::MessagePassing::IMessagePassingMng* parallel_mng);
98
99 /*!
100 * \brief Constructor
101 * \param[in] global_size The global size of the vector
102 * \param[in] local_size The local size of the vector
103 * \param[in] parallel_mng The parallel manager
104 */
105 VectorDistribution(Arccore::Integer global_size, Arccore::Integer local_size,
106 std::shared_ptr<Arccore::MessagePassing::IMessagePassingMng> parallel_mng);
107
108 /*!
109 * \brief Copy constructor
110 * \parm[in] dist The distribution to copy
111 */
113
114 /*!
115 * \brief Rvalue constructor
116 * \param[in] dist The distribution to take
117 */
119
120 //! Free resources
122
123 /*!
124 * \brief Equal operator
125 * \param[in] dist The distribution to copy
126 * \returns The copied distribution
127 */
129
130 /*!
131 * \brief Equal operator
132 * \param[in] dist The distribution to copy
133 * \returns The copied distribution
134 */
136
137 /*!
138 * \brief Comparison operator
139 * \param[in] dist The distribution to compare
140 * \returns Whether or not the distribution are identical
141 */
142 bool operator==(const VectorDistribution& dist) const;
143
144 /*!
145 * \brief Whether or not the run is parallel
146 * \returns Whether or not the run is parallel
147 */
148 bool isParallel() const;
149
150 /*!
151 * \brief Get the parallel manager
152 * \returns The parallel manager
153 */
154 std::shared_ptr<Arccore::MessagePassing::IMessagePassingMng> sharedParallelMng() const;
155
156 /*!
157 * \brief Get the parallel manager
158 * \returns The parallel manager
159 */
160 Arccore::MessagePassing::IMessagePassingMng* parallelMng() const;
161
162 /*!
163 * \brief Get the space
164 * \returns The vector space
165 */
166 const ISpace& space() const;
167
168 /*!
169 * \brief Get the local size
170 * \returns The local size
171 */
172 Arccore::Integer localSize() const;
173
174 /*!
175 * \brief Get the global size
176 * \returns The global size
177 */
178 Arccore::Integer globalSize() const;
179
180 /*!
181 * \brief Get the offset
182 * \return The offset
183 */
184 Arccore::Integer offset() const;
185
186 /*!
187 * \brief Get the offset for a specific proc
188 * \param[in] p The requested proc
189 * \returns The offset for the specific proc
190 */
191 Arccore::Integer offset(Arccore::Integer p) const;
192
193 /*!
194 * \brief Get all the offsets
195 * \returns Offsets array
196 */
197
198 Arccore::ConstArrayView<Integer> offsets() const;
199
200 /*!
201 * \brief Get the owner of an entry
202 * \param[in] i The global id of the element
203 * \returns The proc owner
204 */
205 Arccore::Integer owner(Arccore::Integer i) const;
206
207 /*!
208 * \brief Clone the distribution
209 * \returns A clone of the distribution
210 */
211 std::shared_ptr<VectorDistribution> clone() const;
212
213 /*!
214 * \brief Get the local id of an elements with its global id
215 * \param[in] i The global id of the element
216 * \returns The local id of the element
217 */
218 Arccore::Integer globalToLocal(Arccore::Integer i) const;
219
220 private:
221 /*!
222 * \brief Get the local id of a non local element with its global id
223 * \param[in] i The global id of the non local element
224 * \param[in] p The proc which owns the element
225 * \returns The local id of the element
226 */
227 Arccore::Integer globalToLocal(Arccore::Integer i, Arccore::Integer p) const;
228
229 /*!
230 * \brief Get the global id of an elements with its local id
231 * \param[in] i The local id of the element
232 * \returns The global id of the element
233 */
234 Arccore::Integer localToGlobal(Arccore::Integer i) const;
235
236 /*!
237 * \brief Get the global id of a non local element with its local id
238 * \param[in] i The local id of the non local element
239 * \param[in] p The proc which owns the element
240 * \returns The global id of the element
241 */
242 Arccore::Integer localToGlobal(Arccore::Integer i, Arccore::Integer p) const;
243
244 // due to 'private' of VectorDistribution methods
245 // will be removed
246 friend class MatrixDistribution;
247
248 private:
249 struct Internal;
250 //! Internal implementation of the vector distribution
251 std::shared_ptr<Internal> m_internal;
252};
253
254/*---------------------------------------------------------------------------*/
255/*---------------------------------------------------------------------------*/
256
257//! Print the distribution
258extern ALIEN_EXPORT std::ostream& operator<<(
259std::ostream& nout, const VectorDistribution& dist);
260
261/*---------------------------------------------------------------------------*/
262/*---------------------------------------------------------------------------*/
263
264} // namespace Alien
265
266/*---------------------------------------------------------------------------*/
267/*---------------------------------------------------------------------------*/
ISpace.h.
Interface for algebraic space objects.
Definition ISpace.h:44
Computes a vector distribution.
VectorDistribution & operator=(const VectorDistribution &dist)
Equal operator.
std::shared_ptr< VectorDistribution > clone() const
Clone the distribution.
VectorDistribution(const ISpace &space, Arccore::Integer local_size, std::shared_ptr< Arccore::MessagePassing::IMessagePassingMng > parallel_mng)
Constructor.
bool operator==(const VectorDistribution &dist) const
Comparison operator.
std::shared_ptr< Arccore::MessagePassing::IMessagePassingMng > sharedParallelMng() const
Get the parallel manager.
Arccore::Integer offset(Arccore::Integer p) const
Get the offset for a specific proc.
Arccore::Integer offset() const
Get the offset.
Arccore::ConstArrayView< Integer > offsets() const
Get all the offsets.
const ISpace & space() const
Get the space.
Arccore::Integer owner(Arccore::Integer i) const
Get the owner of an entry.
Arccore::Integer globalToLocal(Arccore::Integer i) const
Get the local id of an elements with its global id.
VectorDistribution(const ISpace &space, Arccore::Integer local_size, Arccore::MessagePassing::IMessagePassingMng *parallel_mng)
Constructor.
VectorDistribution(Arccore::Integer global_size, Arccore::Integer local_size, Arccore::MessagePassing::IMessagePassingMng *parallel_mng)
Constructor.
VectorDistribution(Arccore::Integer global_size, Arccore::Integer local_size, std::shared_ptr< Arccore::MessagePassing::IMessagePassingMng > parallel_mng)
Constructor.
Arccore::Integer localSize() const
Get the local size.
bool isParallel() const
Whether or not the run is parallel.
VectorDistribution(const ISpace &space, Arccore::MessagePassing::IMessagePassingMng *parallel_mng)
Constructor.
VectorDistribution(Arccore::Integer global_size, std::shared_ptr< Arccore::MessagePassing::IMessagePassingMng > parallel_mng)
Constructor.
Arccore::Integer globalSize() const
Get the global size.
VectorDistribution(const ISpace &space, std::shared_ptr< Arccore::MessagePassing::IMessagePassingMng > parallel_mng)
Constructor.
Arccore::MessagePassing::IMessagePassingMng * parallelMng() const
Get the parallel manager.
VectorDistribution(Arccore::Integer global_size, Arccore::MessagePassing::IMessagePassingMng *parallel_mng)
Constructor.
~VectorDistribution()
Free resources.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17
std::ostream & operator<<(std::ostream &nout, const MatrixDistribution &dist)
Print the distribution.
Internal implementation of the vector distribution.