deal.II version GIT relicensing-2289-g1e5549a87a 2024-12-21 21:30:00+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
vector_data_exchange.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2020 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15
16#ifndef dealii_matrix_free_vector_data_exchange_h
17#define dealii_matrix_free_vector_data_exchange_h
18
19
20#include <deal.II/base/config.h>
21
25
27
28#include <memory>
29
31
32namespace internal
33{
34 namespace MatrixFreeFunctions
35 {
40 namespace VectorDataExchange
41 {
45 class Base
46 {
47 public:
48 virtual ~Base() = default;
49
50 virtual unsigned int
51 locally_owned_size() const = 0;
52
53 virtual unsigned int
54 n_ghost_indices() const = 0;
55
56 virtual unsigned int
57 n_import_indices() const = 0;
58
59 virtual unsigned int
60 n_import_sm_procs() const = 0;
61
63 size() const = 0;
64
65 virtual void
67 const unsigned int communication_channel,
68 const ArrayView<const double> &locally_owned_array,
69 const std::vector<ArrayView<const double>> &shared_arrays,
70 const ArrayView<double> &ghost_array,
71 const ArrayView<double> &temporary_storage,
72 std::vector<MPI_Request> &requests) const = 0;
73
74 virtual void
76 const ArrayView<const double> &locally_owned_array,
77 const std::vector<ArrayView<const double>> &shared_arrays,
78 const ArrayView<double> &ghost_array,
79 std::vector<MPI_Request> &requests) const = 0;
80
81 virtual void
83 const VectorOperation::values vector_operation,
84 const unsigned int communication_channel,
85 const ArrayView<const double> &locally_owned_array,
86 const std::vector<ArrayView<const double>> &shared_arrays,
87 const ArrayView<double> &ghost_array,
88 const ArrayView<double> &temporary_storage,
89 std::vector<MPI_Request> &requests) const = 0;
90
91 virtual void
93 const VectorOperation::values vector_operation,
94 const ArrayView<double> &locally_owned_storage,
95 const std::vector<ArrayView<const double>> &shared_arrays,
96 const ArrayView<double> &ghost_array,
97 const ArrayView<const double> &temporary_storage,
98 std::vector<MPI_Request> &requests) const = 0;
99
100 virtual void
101 reset_ghost_values(const ArrayView<double> &ghost_array) const = 0;
102
103 virtual void
105 const unsigned int communication_channel,
106 const ArrayView<const float> &locally_owned_array,
107 const std::vector<ArrayView<const float>> &shared_arrays,
108 const ArrayView<float> &ghost_array,
109 const ArrayView<float> &temporary_storage,
110 std::vector<MPI_Request> &requests) const = 0;
111
112 virtual void
114 const ArrayView<const float> &locally_owned_array,
115 const std::vector<ArrayView<const float>> &shared_arrays,
116 const ArrayView<float> &ghost_array,
117 std::vector<MPI_Request> &requests) const = 0;
118
119 virtual void
121 const VectorOperation::values vector_operation,
122 const unsigned int communication_channel,
123 const ArrayView<const float> &locally_owned_array,
124 const std::vector<ArrayView<const float>> &shared_arrays,
125 const ArrayView<float> &ghost_array,
126 const ArrayView<float> &temporary_storage,
127 std::vector<MPI_Request> &requests) const = 0;
128
129 virtual void
131 const VectorOperation::values vector_operation,
132 const ArrayView<float> &locally_owned_storage,
133 const std::vector<ArrayView<const float>> &shared_arrays,
134 const ArrayView<float> &ghost_array,
135 const ArrayView<const float> &temporary_storage,
136 std::vector<MPI_Request> &requests) const = 0;
137
138 virtual void
139 reset_ghost_values(const ArrayView<float> &ghost_array) const = 0;
140 };
141
142
147 {
148 public:
150 const std::shared_ptr<const Utilities::MPI::Partitioner>
151 &partitioner);
152
153 virtual ~PartitionerWrapper() = default;
154
155 unsigned int
156 locally_owned_size() const override;
157
158 unsigned int
159 n_ghost_indices() const override;
160
161 unsigned int
162 n_import_indices() const override;
163
164 unsigned int
165 n_import_sm_procs() const override;
166
168 size() const override;
169
170 void
172 const unsigned int communication_channel,
173 const ArrayView<const double> &locally_owned_array,
174 const std::vector<ArrayView<const double>> &shared_arrays,
175 const ArrayView<double> &ghost_array,
176 const ArrayView<double> &temporary_storage,
177 std::vector<MPI_Request> &requests) const override;
178
179 void
181 const ArrayView<const double> &locally_owned_array,
182 const std::vector<ArrayView<const double>> &shared_arrays,
183 const ArrayView<double> &ghost_array,
184 std::vector<MPI_Request> &requests) const override;
185
186 void
188 const VectorOperation::values vector_operation,
189 const unsigned int communication_channel,
190 const ArrayView<const double> &locally_owned_array,
191 const std::vector<ArrayView<const double>> &shared_arrays,
192 const ArrayView<double> &ghost_array,
193 const ArrayView<double> &temporary_storage,
194 std::vector<MPI_Request> &requests) const override;
195
196 void
198 const VectorOperation::values vector_operation,
199 const ArrayView<double> &locally_owned_storage,
200 const std::vector<ArrayView<const double>> &shared_arrays,
201 const ArrayView<double> &ghost_array,
202 const ArrayView<const double> &temporary_storage,
203 std::vector<MPI_Request> &requests) const override;
204
205 void
206 reset_ghost_values(const ArrayView<double> &ghost_array) const override;
207
208 void
210 const unsigned int communication_channel,
211 const ArrayView<const float> &locally_owned_array,
212 const std::vector<ArrayView<const float>> &shared_arrays,
213 const ArrayView<float> &ghost_array,
214 const ArrayView<float> &temporary_storage,
215 std::vector<MPI_Request> &requests) const override;
216
217 void
219 const ArrayView<const float> &locally_owned_array,
220 const std::vector<ArrayView<const float>> &shared_arrays,
221 const ArrayView<float> &ghost_array,
222 std::vector<MPI_Request> &requests) const override;
223
224 void
226 const VectorOperation::values vector_operation,
227 const unsigned int communication_channel,
228 const ArrayView<const float> &locally_owned_array,
229 const std::vector<ArrayView<const float>> &shared_arrays,
230 const ArrayView<float> &ghost_array,
231 const ArrayView<float> &temporary_storage,
232 std::vector<MPI_Request> &requests) const override;
233
234 void
236 const VectorOperation::values vector_operation,
237 const ArrayView<float> &locally_owned_storage,
238 const std::vector<ArrayView<const float>> &shared_arrays,
239 const ArrayView<float> &ghost_array,
240 const ArrayView<const float> &temporary_storage,
241 std::vector<MPI_Request> &requests) const override;
242
243 void
244 reset_ghost_values(const ArrayView<float> &ghost_array) const override;
245
246 private:
247 template <typename Number>
248 void
249 reset_ghost_values_impl(const ArrayView<Number> &ghost_array) const;
250
251 const std::shared_ptr<const Utilities::MPI::Partitioner> partitioner;
252 };
253
254
255
261 class Full : public Base
262 {
263 public:
264 Full(
265 const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner,
266 const MPI_Comm communicator_sm);
267
268 unsigned int
269 locally_owned_size() const override;
270
271 unsigned int
272 n_ghost_indices() const override;
273
274 unsigned int
275 n_import_indices() const override;
276
277 virtual unsigned int
278 n_import_sm_procs() const override;
279
281 size() const override;
282
285
286 void
288 const unsigned int communication_channel,
289 const ArrayView<const double> &locally_owned_array,
290 const std::vector<ArrayView<const double>> &shared_arrays,
291 const ArrayView<double> &ghost_array,
292 const ArrayView<double> &temporary_storage,
293 std::vector<MPI_Request> &requests) const override;
294
295 void
297 const ArrayView<const double> &locally_owned_array,
298 const std::vector<ArrayView<const double>> &shared_arrays,
299 const ArrayView<double> &ghost_array,
300 std::vector<MPI_Request> &requests) const override;
301
302 void
304 const VectorOperation::values vector_operation,
305 const unsigned int communication_channel,
306 const ArrayView<const double> &locally_owned_array,
307 const std::vector<ArrayView<const double>> &shared_arrays,
308 const ArrayView<double> &ghost_array,
309 const ArrayView<double> &temporary_storage,
310 std::vector<MPI_Request> &requests) const override;
311
312 void
314 const VectorOperation::values vector_operation,
315 const ArrayView<double> &locally_owned_storage,
316 const std::vector<ArrayView<const double>> &shared_arrays,
317 const ArrayView<double> &ghost_array,
318 const ArrayView<const double> &temporary_storage,
319 std::vector<MPI_Request> &requests) const override;
320
321 void
322 reset_ghost_values(const ArrayView<double> &ghost_array) const override;
323
324 void
326 const unsigned int communication_channel,
327 const ArrayView<const float> &locally_owned_array,
328 const std::vector<ArrayView<const float>> &shared_arrays,
329 const ArrayView<float> &ghost_array,
330 const ArrayView<float> &temporary_storage,
331 std::vector<MPI_Request> &requests) const override;
332
333 void
335 const ArrayView<const float> &locally_owned_array,
336 const std::vector<ArrayView<const float>> &shared_arrays,
337 const ArrayView<float> &ghost_array,
338 std::vector<MPI_Request> &requests) const override;
339
340 void
342 const VectorOperation::values vector_operation,
343 const unsigned int communication_channel,
344 const ArrayView<const float> &locally_owned_array,
345 const std::vector<ArrayView<const float>> &shared_arrays,
346 const ArrayView<float> &ghost_array,
347 const ArrayView<float> &temporary_storage,
348 std::vector<MPI_Request> &requests) const override;
349
350 void
352 const VectorOperation::values vector_operation,
353 const ArrayView<float> &locally_owned_storage,
354 const std::vector<ArrayView<const float>> &shared_arrays,
355 const ArrayView<float> &ghost_array,
356 const ArrayView<const float> &temporary_storage,
357 std::vector<MPI_Request> &requests) const override;
358
359 void
360 reset_ghost_values(const ArrayView<float> &ghost_array) const override;
361
362 private:
363 template <typename Number>
364 void
366 const unsigned int communication_channel,
367 const ArrayView<const Number> &locally_owned_array,
368 const std::vector<ArrayView<const Number>> &shared_arrays,
369 const ArrayView<Number> &ghost_array,
370 const ArrayView<Number> &temporary_storage,
371 std::vector<MPI_Request> &requests) const;
372
373 template <typename Number>
374 void
376 const ArrayView<const Number> &locally_owned_array,
377 const std::vector<ArrayView<const Number>> &shared_arrays,
378 const ArrayView<Number> &ghost_array,
379 std::vector<MPI_Request> &requests) const;
380
381 template <typename Number>
382 void
384 const VectorOperation::values vector_operation,
385 const unsigned int communication_channel,
386 const ArrayView<const Number> &locally_owned_array,
387 const std::vector<ArrayView<const Number>> &shared_arrays,
388 const ArrayView<Number> &ghost_array,
389 const ArrayView<Number> &temporary_storage,
390 std::vector<MPI_Request> &requests) const;
391
392 template <typename Number>
393 void
395 const VectorOperation::values vector_operation,
396 const ArrayView<Number> &locally_owned_storage,
397 const std::vector<ArrayView<const Number>> &shared_arrays,
398 const ArrayView<Number> &ghost_array,
399 const ArrayView<const Number> &temporary_storage,
400 std::vector<MPI_Request> &requests) const;
401
402 template <typename Number>
403 void
404 reset_ghost_values_impl(const ArrayView<Number> &ghost_array) const;
405
406 private:
411
416
420 const unsigned int n_local_elements;
421
425 const unsigned int n_ghost_elements;
426
431
437
442 std::pair<std::vector<unsigned int>,
443 std::vector<std::pair<unsigned int, unsigned int>>>
445
450 std::vector<std::array<unsigned int, 3>> ghost_targets_data;
451
458 std::vector<std::array<unsigned int, 3>> import_targets_data;
459
468 std::pair<std::vector<unsigned int>,
469 std::vector<std::pair<unsigned int, unsigned int>>>
471
476 std::vector<unsigned int> sm_ghost_ranks;
477
482 std::pair<std::vector<unsigned int>,
483 std::vector<std::pair<unsigned int, unsigned int>>>
485
490 std::pair<std::vector<unsigned int>,
491 std::vector<std::pair<unsigned int, unsigned int>>>
493
498 std::vector<unsigned int> sm_import_ranks;
499
504 std::pair<std::vector<unsigned int>,
505 std::vector<std::pair<unsigned int, unsigned int>>>
507
512 std::pair<std::vector<unsigned int>,
513 std::vector<std::pair<unsigned int, unsigned int>>>
515 };
516
517 } // namespace VectorDataExchange
518 } // end of namespace MatrixFreeFunctions
519} // end of namespace internal
520
522
523#endif
virtual void import_from_ghosted_array_start(const VectorOperation::values vector_operation, const unsigned int communication_channel, const ArrayView< const float > &locally_owned_array, const std::vector< ArrayView< const float > > &shared_arrays, const ArrayView< float > &ghost_array, const ArrayView< float > &temporary_storage, std::vector< MPI_Request > &requests) const =0
virtual void export_to_ghosted_array_finish(const ArrayView< const float > &locally_owned_array, const std::vector< ArrayView< const float > > &shared_arrays, const ArrayView< float > &ghost_array, std::vector< MPI_Request > &requests) const =0
virtual void reset_ghost_values(const ArrayView< float > &ghost_array) const =0
virtual types::global_dof_index size() const =0
virtual unsigned int locally_owned_size() const =0
virtual void import_from_ghosted_array_finish(const VectorOperation::values vector_operation, const ArrayView< float > &locally_owned_storage, const std::vector< ArrayView< const float > > &shared_arrays, const ArrayView< float > &ghost_array, const ArrayView< const float > &temporary_storage, std::vector< MPI_Request > &requests) const =0
virtual void reset_ghost_values(const ArrayView< double > &ghost_array) const =0
virtual void export_to_ghosted_array_start(const unsigned int communication_channel, const ArrayView< const float > &locally_owned_array, const std::vector< ArrayView< const float > > &shared_arrays, const ArrayView< float > &ghost_array, const ArrayView< float > &temporary_storage, std::vector< MPI_Request > &requests) const =0
virtual void import_from_ghosted_array_start(const VectorOperation::values vector_operation, const unsigned int communication_channel, const ArrayView< const double > &locally_owned_array, const std::vector< ArrayView< const double > > &shared_arrays, const ArrayView< double > &ghost_array, const ArrayView< double > &temporary_storage, std::vector< MPI_Request > &requests) const =0
virtual void import_from_ghosted_array_finish(const VectorOperation::values vector_operation, const ArrayView< double > &locally_owned_storage, const std::vector< ArrayView< const double > > &shared_arrays, const ArrayView< double > &ghost_array, const ArrayView< const double > &temporary_storage, std::vector< MPI_Request > &requests) const =0
virtual void export_to_ghosted_array_start(const unsigned int communication_channel, const ArrayView< const double > &locally_owned_array, const std::vector< ArrayView< const double > > &shared_arrays, const ArrayView< double > &ghost_array, const ArrayView< double > &temporary_storage, std::vector< MPI_Request > &requests) const =0
virtual void export_to_ghosted_array_finish(const ArrayView< const double > &locally_owned_array, const std::vector< ArrayView< const double > > &shared_arrays, const ArrayView< double > &ghost_array, std::vector< MPI_Request > &requests) const =0
void export_to_ghosted_array_start(const unsigned int communication_channel, const ArrayView< const double > &locally_owned_array, const std::vector< ArrayView< const double > > &shared_arrays, const ArrayView< double > &ghost_array, const ArrayView< double > &temporary_storage, std::vector< MPI_Request > &requests) const override
void reset_ghost_values(const ArrayView< double > &ghost_array) const override
std::vector< std::array< unsigned int, 3 > > ghost_targets_data
std::pair< std::vector< unsigned int >, std::vector< std::pair< unsigned int, unsigned int > > > sm_export_data_this
void export_to_ghosted_array_finish(const ArrayView< const double > &locally_owned_array, const std::vector< ArrayView< const double > > &shared_arrays, const ArrayView< double > &ghost_array, std::vector< MPI_Request > &requests) const override
void import_from_ghosted_array_start(const VectorOperation::values vector_operation, const unsigned int communication_channel, const ArrayView< const double > &locally_owned_array, const std::vector< ArrayView< const double > > &shared_arrays, const ArrayView< double > &ghost_array, const ArrayView< double > &temporary_storage, std::vector< MPI_Request > &requests) const override
void export_to_ghosted_array_start_impl(const unsigned int communication_channel, const ArrayView< const Number > &locally_owned_array, const std::vector< ArrayView< const Number > > &shared_arrays, const ArrayView< Number > &ghost_array, const ArrayView< Number > &temporary_storage, std::vector< MPI_Request > &requests) const
void import_from_ghosted_array_finish_impl(const VectorOperation::values vector_operation, const ArrayView< Number > &locally_owned_storage, const std::vector< ArrayView< const Number > > &shared_arrays, const ArrayView< Number > &ghost_array, const ArrayView< const Number > &temporary_storage, std::vector< MPI_Request > &requests) const
std::pair< std::vector< unsigned int >, std::vector< std::pair< unsigned int, unsigned int > > > sm_export_data
std::vector< std::array< unsigned int, 3 > > import_targets_data
std::pair< std::vector< unsigned int >, std::vector< std::pair< unsigned int, unsigned int > > > ghost_indices_subset_data
void import_from_ghosted_array_finish(const VectorOperation::values vector_operation, const ArrayView< double > &locally_owned_storage, const std::vector< ArrayView< const double > > &shared_arrays, const ArrayView< double > &ghost_array, const ArrayView< const double > &temporary_storage, std::vector< MPI_Request > &requests) const override
void export_to_ghosted_array_finish_impl(const ArrayView< const Number > &locally_owned_array, const std::vector< ArrayView< const Number > > &shared_arrays, const ArrayView< Number > &ghost_array, std::vector< MPI_Request > &requests) const
std::pair< std::vector< unsigned int >, std::vector< std::pair< unsigned int, unsigned int > > > sm_import_data
void import_from_ghosted_array_start_impl(const VectorOperation::values vector_operation, const unsigned int communication_channel, const ArrayView< const Number > &locally_owned_array, const std::vector< ArrayView< const Number > > &shared_arrays, const ArrayView< Number > &ghost_array, const ArrayView< Number > &temporary_storage, std::vector< MPI_Request > &requests) const
void reset_ghost_values_impl(const ArrayView< Number > &ghost_array) const
std::pair< std::vector< unsigned int >, std::vector< std::pair< unsigned int, unsigned int > > > sm_import_data_this
virtual types::global_dof_index size() const override
std::pair< std::vector< unsigned int >, std::vector< std::pair< unsigned int, unsigned int > > > import_indices_data
const std::shared_ptr< const Utilities::MPI::Partitioner > partitioner
void export_to_ghosted_array_finish(const ArrayView< const double > &locally_owned_array, const std::vector< ArrayView< const double > > &shared_arrays, const ArrayView< double > &ghost_array, std::vector< MPI_Request > &requests) const override
void export_to_ghosted_array_start(const unsigned int communication_channel, const ArrayView< const double > &locally_owned_array, const std::vector< ArrayView< const double > > &shared_arrays, const ArrayView< double > &ghost_array, const ArrayView< double > &temporary_storage, std::vector< MPI_Request > &requests) const override
void reset_ghost_values_impl(const ArrayView< Number > &ghost_array) const
void import_from_ghosted_array_finish(const VectorOperation::values vector_operation, const ArrayView< double > &locally_owned_storage, const std::vector< ArrayView< const double > > &shared_arrays, const ArrayView< double > &ghost_array, const ArrayView< const double > &temporary_storage, std::vector< MPI_Request > &requests) const override
void reset_ghost_values(const ArrayView< double > &ghost_array) const override
void import_from_ghosted_array_start(const VectorOperation::values vector_operation, const unsigned int communication_channel, const ArrayView< const double > &locally_owned_array, const std::vector< ArrayView< const double > > &shared_arrays, const ArrayView< double > &ghost_array, const ArrayView< double > &temporary_storage, std::vector< MPI_Request > &requests) const override
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:498
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499