8.3
general documentation
cs_all_to_all.h
Go to the documentation of this file.
1#ifndef __CS_ALL_TO_ALL_H__
2#define __CS_ALL_TO_ALL_H__
3
4/*============================================================================
5 * All-to-all parallel data exchange.
6 *============================================================================*/
7
8/*
9 This file is part of code_saturne, a general-purpose CFD tool.
10
11 Copyright (C) 1998-2024 EDF S.A.
12
13 This program is free software; you can redistribute it and/or modify it under
14 the terms of the GNU General Public License as published by the Free Software
15 Foundation; either version 2 of the License, or (at your option) any later
16 version.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
21 details.
22
23 You should have received a copy of the GNU General Public License along with
24 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
25 Street, Fifth Floor, Boston, MA 02110-1301, USA.
26*/
27
28/*----------------------------------------------------------------------------*/
29
30#if defined(HAVE_MPI)
31#include <mpi.h>
32#endif
33
34/*----------------------------------------------------------------------------
35 * Local headers
36 *----------------------------------------------------------------------------*/
37
38#include "cs_block_dist.h"
39#include "cs_defs.h"
40#include "cs_parall.h"
41#include "cs_rank_neighbors.h"
42
43/*----------------------------------------------------------------------------*/
44
46
47/*=============================================================================
48 * Macro definitions
49 *============================================================================*/
50
55#define CS_ALL_TO_ALL_USE_DEST_ID (1 << 0)
56#define CS_ALL_TO_ALL_ORDER_BY_SRC_RANK (1 << 1)
57
58#define CS_ALL_TO_ALL_NO_REVERSE (1 << 2)
59#define CS_ALL_TO_ALL_NEED_SRC_RANK (1 << 3)
60
61/*============================================================================
62 * Type definitions
63 *============================================================================*/
64
65/* All-to-all algorithm choice */
66
67typedef enum {
68
72
74
75/* Opaque all-to-all distribution structure */
76
77#if defined(HAVE_MPI)
78
79typedef struct _cs_all_to_all_t cs_all_to_all_t;
80
81#endif
82
83/*=============================================================================
84 * Public function prototypes
85 *============================================================================*/
86
87#if defined(HAVE_MPI)
88
89/*----------------------------------------------------------------------------*/
123/*----------------------------------------------------------------------------*/
124
126cs_all_to_all_create(size_t n_elts,
127 int flags,
128 const cs_lnum_t *dest_id,
129 const int dest_rank[],
130 MPI_Comm comm);
131
132/*----------------------------------------------------------------------------*/
154/*----------------------------------------------------------------------------*/
155
158 int flags,
159 const cs_gnum_t *src_gnum,
161 MPI_Comm comm);
162
163/*----------------------------------------------------------------------------*/
169/*----------------------------------------------------------------------------*/
170
171void
173
174/*----------------------------------------------------------------------------*/
184/*----------------------------------------------------------------------------*/
185
186void
188 int **dest_rank);
189
190/*----------------------------------------------------------------------------*/
201/*----------------------------------------------------------------------------*/
202
203void
205 cs_lnum_t **dest_id);
206
207/*----------------------------------------------------------------------------*/
220/*----------------------------------------------------------------------------*/
221
224
225/*----------------------------------------------------------------------------*/
252/*----------------------------------------------------------------------------*/
253
254void *
256 cs_datatype_t datatype,
257 int stride,
258 bool reverse,
259 const void *src_data,
260 void *dest_data);
261
262/*----------------------------------------------------------------------------*/
286/*----------------------------------------------------------------------------*/
287
288cs_lnum_t *
290 bool reverse,
291 const cs_lnum_t *src_index,
292 cs_lnum_t *dest_index);
293
294/*----------------------------------------------------------------------------*/
322/*----------------------------------------------------------------------------*/
323
324void *
326 cs_datatype_t datatype,
327 bool reverse,
328 const cs_lnum_t *src_index,
329 const void *src_data,
330 const cs_lnum_t *dest_index,
331 void *dest_data);
332
333/*----------------------------------------------------------------------------*/
356/*----------------------------------------------------------------------------*/
357
358int *
360
361#endif /* defined(HAVE_MPI) */
362
363/*----------------------------------------------------------------------------*/
369/*----------------------------------------------------------------------------*/
370
373
374/*----------------------------------------------------------------------------*/
380/*----------------------------------------------------------------------------*/
381
382void
384
385/*----------------------------------------------------------------------------*/
391/*----------------------------------------------------------------------------*/
392
393void
395
396/*----------------------------------------------------------------------------*/
402/*----------------------------------------------------------------------------*/
403
404void
406
407/*----------------------------------------------------------------------------*/
412/*----------------------------------------------------------------------------*/
413
414void
416
417/*----------------------------------------------------------------------------*/
418
420
421#if defined(HAVE_MPI)
422
423#if defined(__cplusplus)
424
425/*----------------------------------------------------------------------------*/
450/*----------------------------------------------------------------------------*/
451
452template <typename T>
453T *
455 int stride,
456 bool reverse,
457 const T *src_data)
458{
459 return static_cast<T *>(cs_all_to_all_copy_array(d,
460 cs_datatype_from_type<T>(),
461 stride,
462 reverse,
463 src_data,
464 nullptr));
465};
466
467/*----------------------------------------------------------------------------*/
493/*----------------------------------------------------------------------------*/
494
495template <typename T>
496void
498 int stride,
499 bool reverse,
500 const T *src_data,
501 void *dest_data)
502{
504 cs_datatype_from_type<T>(),
505 stride,
506 reverse,
507 src_data,
508 dest_data);
509};
510
511/*----------------------------------------------------------------------------*/
537/*----------------------------------------------------------------------------*/
538
539template <typename T>
540T *
542 bool reverse,
543 const cs_lnum_t *src_index,
544 const T *src_data,
545 const cs_lnum_t *dest_index)
546{
547 return static_cast<T *>(cs_all_to_all_copy_indexed(d,
548 cs_datatype_from_type<T>(),
549 reverse,
550 src_index,
551 src_data,
552 dest_index,
553 nullptr));
554};
555
556/*----------------------------------------------------------------------------*/
583/*----------------------------------------------------------------------------*/
584
585template <typename T>
586void
588 bool reverse,
589 const cs_lnum_t *src_index,
590 const T *src_data,
591 const cs_lnum_t *dest_index,
592 void *dest_data)
593{
595 cs_datatype_from_type<T>(),
596 reverse,
597 src_index,
598 src_data,
599 dest_index,
600 dest_data);
601};
602
603#endif //__cplusplus
604
605#endif
606
607#endif /* __CS_ALL_TO_ALL_H__ */
void * cs_all_to_all_copy_array(cs_all_to_all_t *d, cs_datatype_t datatype, int stride, bool reverse, const void *src_data, void *dest_data)
Communicate array data using all-to-all distributor.
Definition: cs_all_to_all.cpp:2797
void * cs_all_to_all_copy_indexed(cs_all_to_all_t *d, cs_datatype_t datatype, bool reverse, const cs_lnum_t *src_index, const void *src_data, const cs_lnum_t *dest_index, void *dest_data)
Communicate local index using all-to-all distributor.
Definition: cs_all_to_all.cpp:3170
void cs_all_to_all_set_type(cs_all_to_all_type_t t)
Set current type of all-to-all distributor algorithm choice.
Definition: cs_all_to_all.cpp:3557
void cs_all_to_all_destroy(cs_all_to_all_t **d)
Destroy an all-to-all distributor.
Definition: cs_all_to_all.cpp:2520
cs_lnum_t cs_all_to_all_n_elts_dest(cs_all_to_all_t *d)
Get number of elements associated with all-to-all distributor.
Definition: cs_all_to_all.cpp:2633
struct _cs_all_to_all_t cs_all_to_all_t
Definition: cs_all_to_all.h:79
cs_all_to_all_type_t cs_all_to_all_get_type(void)
Get current type of all-to-all distributor algorithm choice.
Definition: cs_all_to_all.cpp:3514
void cs_all_to_all_log_finalize(void)
Log performance information relative to instrumented all-to-all distribution.
Definition: cs_all_to_all.cpp:3570
cs_lnum_t * cs_all_to_all_copy_index(cs_all_to_all_t *d, bool reverse, const cs_lnum_t *src_index, cs_lnum_t *dest_index)
Communicate local index using all-to-all distributor.
Definition: cs_all_to_all.cpp:3069
cs_all_to_all_type_t
Definition: cs_all_to_all.h:67
@ CS_ALL_TO_ALL_MPI_DEFAULT
Definition: cs_all_to_all.h:69
@ CS_ALL_TO_ALL_HYBRID
Definition: cs_all_to_all.h:70
@ CS_ALL_TO_ALL_CRYSTAL_ROUTER
Definition: cs_all_to_all.h:71
int * cs_all_to_all_get_src_rank(cs_all_to_all_t *d)
Get array of source element ranks associated with an all-to-all distributor.
Definition: cs_all_to_all.cpp:3443
cs_all_to_all_t * cs_all_to_all_create_from_block(size_t n_elts, int flags, const cs_gnum_t *src_gnum, cs_block_dist_info_t bi, MPI_Comm comm)
Create an all-to-all distributor for elements whose destination rank is determined from global number...
Definition: cs_all_to_all.cpp:2445
void cs_all_to_all_set_hybrid_parameters(cs_rank_neighbors_exchange_t rne_type)
Set current type of all-to-all distributor algorithm choice.
Definition: cs_all_to_all.cpp:3543
void cs_all_to_all_get_hybrid_parameters(cs_rank_neighbors_exchange_t *rne_type)
Get current type of hybrid all-to-all distributor parameters.
Definition: cs_all_to_all.cpp:3528
void cs_all_to_all_transfer_dest_id(cs_all_to_all_t *d, cs_lnum_t **dest_id)
Transfer ownership of destination ids to an all-to-all distributor.
Definition: cs_all_to_all.cpp:2600
cs_all_to_all_t * cs_all_to_all_create(size_t n_elts, int flags, const cs_lnum_t *dest_id, const int dest_rank[], MPI_Comm comm)
Create an all-to-all distributor based on destination rank.
Definition: cs_all_to_all.cpp:2387
void cs_all_to_all_transfer_dest_rank(cs_all_to_all_t *d, int **dest_rank)
Transfer ownership of destination rank to an all-to-all distributor.
Definition: cs_all_to_all.cpp:2569
cs_datatype_t
Definition: cs_defs.h:300
#define BEGIN_C_DECLS
Definition: cs_defs.h:542
uint64_t cs_gnum_t
global mesh entity number
Definition: cs_defs.h:325
#define END_C_DECLS
Definition: cs_defs.h:543
int cs_lnum_t
local mesh entity id
Definition: cs_defs.h:335
@ t
Definition: cs_field_pointer.h:94
cs_rank_neighbors_exchange_t
Definition: cs_rank_neighbors.h:55
Definition: cs_block_dist.h:50