UPstreamGatherScatter.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2022-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "Pstream.H"
29 #include "UPstreamWrapping.H"
30 
31 #include <cinttypes>
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 #undef Pstream_CommonRoutines
36 #define Pstream_CommonRoutines(Native, TaggedType) \
37  \
38 void Foam::UPstream::mpiGather \
39 ( \
40  const Native* sendData, \
41  Native* recvData, \
42  int count, \
43  const label comm \
44 ) \
45 { \
46  PstreamDetail::gather \
47  ( \
48  sendData, recvData, count, \
49  TaggedType, comm \
50  ); \
51 } \
52  \
53  \
54 void Foam::UPstream::mpiScatter \
55 ( \
56  const Native* sendData, \
57  Native* recvData, \
58  int count, \
59  const label comm \
60 ) \
61 { \
62  PstreamDetail::scatter \
63  ( \
64  sendData, recvData, count, \
65  TaggedType, comm \
66  ); \
67 } \
68  \
69  \
70 void Foam::UPstream::mpiAllGather \
71 ( \
72  Native* allData, \
73  int count, \
74  const label comm \
75 ) \
76 { \
77  PstreamDetail::allGather \
78  ( \
79  allData, count, \
80  TaggedType, comm \
81  ); \
82 }
83 
84 Pstream_CommonRoutines(char, MPI_BYTE);
85 
86 #undef Pstream_CommonRoutines
87 
88 
89 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
90 
91 #undef Pstream_CommonRoutines
92 #define Pstream_CommonRoutines(Native, TaggedType) \
93 void Foam::UPstream::gather \
94 ( \
95  const Native* sendData, \
96  int sendCount, \
97  \
98  Native* recvData, \
99  const UList<int>& recvCounts, \
100  const UList<int>& recvOffsets, \
101  const label comm \
102 ) \
103 { \
104  PstreamDetail::gatherv \
105  ( \
106  sendData, sendCount, \
107  recvData, recvCounts, recvOffsets, \
108  TaggedType, comm \
109  ); \
110 } \
111  \
112 void Foam::UPstream::scatter \
113 ( \
114  const Native* sendData, \
115  const UList<int>& sendCounts, \
116  const UList<int>& sendOffsets, \
117  \
118  Native* recvData, \
119  int recvCount, \
120  const label comm \
121 ) \
122 { \
123  PstreamDetail::scatterv \
124  ( \
125  sendData, sendCounts, sendOffsets, \
126  recvData, recvCount, \
127  TaggedType, comm \
128  ); \
129 }
130 
131 
132 //TDB: Pstream_CommonRoutines(bool, MPI_C_BOOL);
133 Pstream_CommonRoutines(char, MPI_BYTE);
134 Pstream_CommonRoutines(int32_t, MPI_INT32_T);
135 Pstream_CommonRoutines(int64_t, MPI_INT64_T);
136 Pstream_CommonRoutines(uint32_t, MPI_UINT32_T);
137 Pstream_CommonRoutines(uint64_t, MPI_UINT64_T);
138 Pstream_CommonRoutines(float, MPI_FLOAT);
139 Pstream_CommonRoutines(double, MPI_DOUBLE);
140 
141 #undef Pstream_CommonRoutines
142 
143 // ************************************************************************* //
Functions to wrap MPI_Bcast, MPI_Allreduce, MPI_Iallreduce etc.
#define Pstream_CommonRoutines(Native, TaggedType)