Alien  1.3.0
User documentation
Loading...
Searching...
No Matches
MatrixDistribution.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 MatrixDistribution.h
10 * \brief MatrixDistribution.h
11 */
12
13#pragma once
14
15#include <arccore/base/BaseTypes.h>
16#include <arccore/message_passing/MessagePassingGlobal.h>
17
18#include <alien/data/ISpace.h>
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23namespace Alien
24{
25
26/*---------------------------------------------------------------------------*/
27/*---------------------------------------------------------------------------*/
28
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
34/*!
35 * \ingroup distribution
36 * \brief Computes a matrix distribution
37 *
38 * Computes or use a pre-existing block row distribution for matrices
39 */
40class ALIEN_EXPORT MatrixDistribution
41{
42 public:
43 //! Constructor
45
46 /*!
47 * \brief Constructor
48 * \param[in] row_space The row space of the matrix
49 * \param[in] col_space The col space of the matrix
50 * \param[in] parallel_mng The parallel manager
51 */
52 MatrixDistribution(const ISpace& row_space, const ISpace& col_space,
53 Arccore::MessagePassing::IMessagePassingMng* parallel_mng);
54
55 /*!
56 * \brief Constructor
57 * \param[in] global_row_size The number of rows in the matrix
58 * \param[in] global_col_size The number of cols in the matrix
59 * \param[in] parallel_mng The parallel manager
60 */
61 MatrixDistribution(Arccore::Integer global_row_size, Arccore::Integer global_col_size,
62 Arccore::MessagePassing::IMessagePassingMng* parallel_mng);
63
64 /*!
65 * \brief Constructor
66 * \param[in] global_row_size The number of rows in the matrix
67 * \param[in] global_col_size The number of cols in the matrix
68 * \param[in] parallel_mng The parallel manager
69 */
70 MatrixDistribution(Arccore::Integer global_row_size, Arccore::Integer global_col_size,
71 std::shared_ptr<Arccore::MessagePassing::IMessagePassingMng> parallel_mng);
72
73 /*!
74 * \brief Constructor
75 * \param[in] row_space The row space of the matrix
76 * \param[in] col_space The col space of the matrix
77 * \param[in] local_row_size The number of local rows in the matrix
78 * \param[in] parallel_mng The parallel manager
79 */
80 MatrixDistribution(const ISpace& row_space, const ISpace& col_space,
81 Integer local_row_size, IMessagePassingMng* parallel_mng);
82
83 /*!
84 * \brief Constructor
85 * \param[in] row_space The row space of the matrix
86 * \param[in] col_space The col space of the matrix
87 * \param[in] local_row_size The number of local rows in the matrix
88 * \param[in] local_col_size The number of local cols in the matrix
89 * \param[in] parallel_mng The parallel manager
90 */
91 MatrixDistribution(const ISpace& row_space, const ISpace& col_space,
92 Integer local_row_size, Integer local_col_size, IMessagePassingMng* parallel_mng);
93
94 /*!
95 * \brief Constructor
96 * \param[in] global_row_size The number of rows in the matrix
97 * \param[in] global_col_size The number of cols in the matrix
98 * \param[in] local_row_size The number of local cols in the matrix
99 * \param[in] parallel_mng The parallel manager
100 */
101 MatrixDistribution(Arccore::Integer global_row_size, Arccore::Integer global_col_size,
102 Arccore::Integer local_row_size,
103 Arccore::MessagePassing::IMessagePassingMng* parallel_mng);
104
105 /*!
106 * \brief Constructor
107 * \param[in] global_row_size The number of rows in the matrix
108 * \param[in] global_col_size The number of cols in the matrix
109 * \param[in] local_row_size The number of local cols in the matrix
110 * \param[in] local_col_size The number of local cols in the matrix
111 * \param[in] parallel_mng The parallel manager
112 */
113 MatrixDistribution(Arccore::Integer global_row_size, Arccore::Integer global_col_size,
114 Arccore::Integer local_row_size, Arccore::Integer local_col_size,
115 Arccore::MessagePassing::IMessagePassingMng* parallel_mng);
116
117 /*!
118 * \brief Constructor
119 * \param[in] global_row_size The number of rows in the matrix
120 * \param[in] global_col_size The number of cols in the matrix
121 * \param[in] local_row_size The number of local cols in the matrix
122 * \param[in] parallel_mng The parallel manager
123 */
124 MatrixDistribution(Arccore::Integer global_row_size, Arccore::Integer global_col_size,
125 Arccore::Integer local_row_size,
126 std::shared_ptr<Arccore::MessagePassing::IMessagePassingMng> parallel_mng);
127
128 /*!
129 * \brief Constructor
130 * \param[in] global_row_size The number of rows in the matrix
131 * \param[in] global_col_size The number of cols in the matrix
132 * \param[in] local_row_size The number of local cols in the matrix
133 * \param[in] local_col_size The number of local cols in the matrix
134 * \param[in] parallel_mng The parallel manager
135 */
136 MatrixDistribution(Arccore::Integer global_row_size, Arccore::Integer global_col_size,
137 Arccore::Integer local_row_size, Arccore::Integer local_col_size,
138 std::shared_ptr<Arccore::MessagePassing::IMessagePassingMng> parallel_mng);
139
140 /*!
141 * \brief Copy constructor
142 * \param[in] dist The matrix distribution to copy
143 */
145
146 /*!
147 * \brief Rvalue constructor
148 * \param[in] dist The distribution to take
149 */
151
152 //! Free resources
154
155 /*!
156 * \brief Operator equal
157 * \param[in] dist The matrix distribution to copy
158 * \returns The new matrix distribution
159 */
161
162 /*!
163 * \brief Operator equal
164 * \param[in] dist The matrix distribution to copy
165 * \returns The new matrix distribution
166 */
168
169 /*!
170 * \brief Comparison operator
171 * \param[in] dist The matrix distribution to compare
172 * \returns Whether or not the matrices distribution are the same
173 */
174 bool operator==(const MatrixDistribution& dist) const;
175
176 /*!
177 * \brief Whether or not the run is parallel
178 * \returns Whether or not the run is parallel
179 */
180 bool isParallel() const;
181
182 /*!
183 * \brief Get the parallel manager
184 * \returns The parallel manager
185 */
186 Arccore::MessagePassing::IMessagePassingMng* parallelMng() const;
187
188 /*!
189 * \brief Get the row distribution
190 * \returns The row distribution
191 */
192 const VectorDistribution& rowDistribution() const;
193
194 /*!
195 * \brief Get the col distribution
196 * \returns The col distribution
197 */
198 const VectorDistribution& colDistribution() const;
199
200 /*!
201 * \brief Get the row space
202 * \returns The row space
203 */
204 const ISpace& rowSpace() const;
205
206 /*!
207 * \brief Get the col space
208 * \returns The col space
209 */
210 const ISpace& colSpace() const;
211
212 /*!
213 * \brief Get the local row size
214 * \returns The local row size
215 */
216 Arccore::Integer localRowSize() const;
217
218 /*!
219 * \brief Get the local col size
220 * \returns The local col size
221 */
222 Arccore::Integer localColSize() const;
223
224 /*!
225 * \brief Get the global row size
226 * \returns The global row size
227 */
228 Arccore::Integer globalRowSize() const;
229
230 /*!
231 * \brief Get the global col size
232 * \returns The global col size
233 */
234 Arccore::Integer globalColSize() const;
235
236 /*!
237 * \brief Get the row offset
238 * \return The row offset
239 */
240 Arccore::Integer rowOffset() const;
241
242 /*!
243 * \brief Get the row offset for a specific proc
244 * \param[in] p The requested proc
245 * \returns The row offset for the specific proc
246 */
247 Arccore::Integer rowOffset(Arccore::Integer p) const;
248
249 /*!
250 * \brief Get the col offset
251 * \return The col offset
252 */
253 Arccore::Integer colOffset() const;
254
255 /*!
256 * \brief Get the col offset for a specific proc
257 * \param[in] p The requested proc
258 * \returns The col offset for the specific proc
259 */
260 Arccore::Integer colOffset(Arccore::Integer p) const;
261
262 /*!
263 * \brief Clone the distribution
264 * \returns A clone of this distribution
265 */
266 std::shared_ptr<MatrixDistribution> clone() const;
267
268 private:
269 /*!
270 * \brief Get the local id of a row with its global id
271 * \param[in] i The global id of the row
272 * \returns The local id of the row
273 */
274 Arccore::Integer rowGlobalToLocal(Arccore::Integer i) const;
275
276 /*!
277 * \brief Get the local id of a non local row with its global id
278 * \param[in] i The global id of the non local row
279 * \param[in] p The proc which owns the row
280 * \returns The local id of the row
281 */
282 Arccore::Integer rowGlobalToLocal(Arccore::Integer i, Arccore::Integer p) const;
283
284 /*!
285 * \brief Get the local id of a col with its global id
286 * \param[in] i The global id of the col
287 * \returns The local id of the col
288 */
289 Arccore::Integer colGlobalToLocal(Arccore::Integer i) const;
290
291 /*!
292 * \brief Get the local id of a non local col with its global id
293 * \param[in] i The global id of the non local col
294 * \param[in] p The proc which owns the col
295 * \returns The local id of the col
296 */
297 Arccore::Integer colGlobalToLocal(Arccore::Integer i, Arccore::Integer p) const;
298
299 /*!
300 * \brief Get the global id of a row with its local id
301 * \param[in] i The local id of the row
302 * \returns The global id of the row
303 */
304 Arccore::Integer rowLocalToGlobal(Arccore::Integer i) const;
305
306 /*!
307 * \brief Get the global id of a non local row with its local id
308 * \param[in] i The local id of the non local row
309 * \param[in] p The proc which owns the row
310 * \returns The global id of the row
311 */
312 Arccore::Integer rowLocalToGlobal(Arccore::Integer i, Arccore::Integer p) const;
313
314 /*!
315 * \brief Get the global id of a col with its local id
316 * \param[in] i The local id of the col
317 * \returns The global id of the col
318 */
319 Arccore::Integer colLocalToGlobal(Arccore::Integer i) const;
320
321 /*!
322 * \brief Get the global id of a non local col with its local id
323 * \param[in] i The local id of the non local col
324 * \param[in] p The proc which owns the col
325 * \returns The global id of the col
326 */
327 Arccore::Integer colLocalToGlobal(Arccore::Integer i, Arccore::Integer p) const;
328
329 /*!
330 * \brief Get the owner of an entry
331 * \param[in] i The global id of the row
332 * \param[in] j The global id of the col
333 * \returns The proc owner
334 */
335 Arccore::Integer owner(Arccore::Integer i, Arccore::Integer j) const;
336
337 private:
338 struct Internal;
339 //! Internal implementation of the matrix distribution
340 std::shared_ptr<Internal> m_internal;
341};
342
343/*---------------------------------------------------------------------------*/
344/*---------------------------------------------------------------------------*/
345
346//! Print the distribution
347extern ALIEN_EXPORT std::ostream& operator<<(
348std::ostream& nout, const MatrixDistribution& dist);
349
350/*---------------------------------------------------------------------------*/
351/*---------------------------------------------------------------------------*/
352
353} // namespace Alien
354
355/*---------------------------------------------------------------------------*/
356/*---------------------------------------------------------------------------*/
ISpace.h.
Interface for algebraic space objects.
Definition ISpace.h:44
Computes a matrix distribution.
const VectorDistribution & rowDistribution() const
Get the row distribution.
bool isParallel() const
Whether or not the run is parallel.
MatrixDistribution(const ISpace &row_space, const ISpace &col_space, Arccore::MessagePassing::IMessagePassingMng *parallel_mng)
Constructor.
Arccore::Integer globalColSize() const
Get the global col size.
Arccore::Integer localColSize() const
Get the local col size.
Arccore::Integer localRowSize() const
Get the local row size.
MatrixDistribution & operator=(const MatrixDistribution &dist)
Operator equal.
MatrixDistribution(Arccore::Integer global_row_size, Arccore::Integer global_col_size, Arccore::Integer local_row_size, std::shared_ptr< Arccore::MessagePassing::IMessagePassingMng > parallel_mng)
Constructor.
const ISpace & rowSpace() const
Get the row space.
MatrixDistribution(const MatrixDistribution &dist)
Copy constructor.
MatrixDistribution(Arccore::Integer global_row_size, Arccore::Integer global_col_size, Arccore::MessagePassing::IMessagePassingMng *parallel_mng)
Constructor.
MatrixDistribution(MatrixDistribution &&dist)
Rvalue constructor.
MatrixDistribution(Arccore::Integer global_row_size, Arccore::Integer global_col_size, Arccore::Integer local_row_size, Arccore::MessagePassing::IMessagePassingMng *parallel_mng)
Constructor.
MatrixDistribution(Arccore::Integer global_row_size, Arccore::Integer global_col_size, std::shared_ptr< Arccore::MessagePassing::IMessagePassingMng > parallel_mng)
Constructor.
Arccore::Integer globalRowSize() const
Get the global row size.
bool operator==(const MatrixDistribution &dist) const
Comparison operator.
MatrixDistribution & operator=(MatrixDistribution &&dist)
Operator equal.
Arccore::Integer rowOffset(Arccore::Integer p) const
Get the row offset for a specific proc.
std::shared_ptr< MatrixDistribution > clone() const
Clone the distribution.
MatrixDistribution(Arccore::Integer global_row_size, Arccore::Integer global_col_size, Arccore::Integer local_row_size, Arccore::Integer local_col_size, Arccore::MessagePassing::IMessagePassingMng *parallel_mng)
Constructor.
const ISpace & colSpace() const
Get the col space.
MatrixDistribution(Arccore::Integer global_row_size, Arccore::Integer global_col_size, Arccore::Integer local_row_size, Arccore::Integer local_col_size, std::shared_ptr< Arccore::MessagePassing::IMessagePassingMng > parallel_mng)
Constructor.
Arccore::Integer colOffset(Arccore::Integer p) const
Get the col offset for a specific proc.
const VectorDistribution & colDistribution() const
Get the col distribution.
Arccore::Integer colOffset() const
Get the col offset.
Arccore::Integer rowOffset() const
Get the row offset.
Arccore::MessagePassing::IMessagePassingMng * parallelMng() const
Get the parallel manager.
~MatrixDistribution()
Free resources.
Computes a vector distribution.
-- 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 matrix distribution.