UPstreamReduce.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 "PstreamReduceOps.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 // Special reductions for bool
34 
35 void Foam::UPstream::reduceAnd(bool& value, const label comm)
36 {}
37 
38 void Foam::UPstream::reduceOr(bool& value, const label comm)
39 {}
40 
41 
42 void Foam::reduce
43 (
44  bool& value,
45  const andOp<bool>&,
46  const int tag,
47  const label comm
48 )
49 {}
50 
51 void Foam::reduce
52 (
53  bool& value,
54  const orOp<bool>&,
55  const int tag,
56  const label comm
57 )
58 {}
59 
60 
61 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62 
63 // Common reductions
64 
65 #undef Pstream_CommonReductions
66 #define Pstream_CommonReductions(Native) \
67  \
68 void Foam::reduce \
69 ( \
70  Native values[], \
71  const int size, \
72  const minOp<Native>&, \
73  const int tag, \
74  const label comm \
75 ) \
76 {} \
77  \
78 void Foam::reduce \
79 ( \
80  Native values[], \
81  const int size, \
82  const maxOp<Native>&, \
83  const int tag, \
84  const label comm \
85 ) \
86 {} \
87  \
88 void Foam::reduce \
89 ( \
90  Native values[], \
91  const int size, \
92  const sumOp<Native>&, \
93  const int tag, \
94  const label comm \
95 ) \
96 {} \
97  \
98 void Foam::reduce \
99 ( \
100  Native& value, \
101  const minOp<Native>&, \
102  const int tag, \
103  const label comm \
104 ) \
105 {} \
106  \
107 void Foam::reduce \
108 ( \
109  Native& value, \
110  const maxOp<Native>&, \
111  const int tag, \
112  const label comm \
113 ) \
114 {} \
115  \
116 void Foam::reduce \
117 ( \
118  Native& value, \
119  const sumOp<Native>&, \
120  const int tag, \
121  const label comm \
122 ) \
123 {}
125 
126 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
127 
128 // Floating-point reductions
129 
130 #undef Pstream_FloatReductions
131 #define Pstream_FloatReductions(Native) \
132  \
133 Pstream_CommonReductions(Native); \
134  \
135 void Foam::reduce \
136 ( \
137  Native values[], \
138  const int size, \
139  const sumOp<Native>&, \
140  const int tag, \
141  const label comm, \
142  UPstream::Request& req \
143 ) \
144 {} \
145  \
146 /* Deprecated: prefer version with UPstream::Request */ \
147 void Foam::reduce \
148 ( \
149  Native values[], \
150  const int size, \
151  const sumOp<Native>&, \
152  const int tag, \
153  const label comm, \
154  label& requestID \
155 ) \
156 {} \
157  \
158 void Foam::reduce \
159 ( \
160  Native& value, \
161  const sumOp<Native>&, \
162  const int tag, \
163  const label comm, \
164  UPstream::Request& req \
165 ) \
166 {} \
167  \
168 /* Deprecated: prefer version with UPstream::Request */ \
169 void Foam::reduce \
170 ( \
171  Native& value, \
172  const sumOp<Native>&, \
173  const int tag, \
174  const label comm, \
175  label& requestID \
176 ) \
177 {} \
178  \
179 void Foam::sumReduce \
180 ( \
181  Native& value, \
182  label& count, \
183  const int tag, \
184  const label comm \
185 ) \
186 {}
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 // Bitwise reductions
192 
193 #undef Pstream_BitwiseReductions
194 #define Pstream_BitwiseReductions(Native) \
195  \
196 void Foam::reduce \
197 ( \
198  Native values[], \
199  const int size, \
200  const bitOrOp<Native>&, \
201  const int tag, \
202  const label comm \
203 ) \
204 {} \
205  \
206 void Foam::reduce \
207 ( \
208  Native& value, \
209  const bitOrOp<Native>&, \
210  const int tag, \
211  const label comm \
212 ) \
213 {}
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 Pstream_CommonReductions(int32_t);
221 Pstream_CommonReductions(uint64_t);
222 
225 
226 Pstream_BitwiseReductions(unsigned char);
227 Pstream_BitwiseReductions(unsigned int);
228 
229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230 
231 #undef Pstream_CommonReductions
232 #undef Pstream_FloatReductions
233 #undef Pstream_BitwiseReductions
234 
235 
236 // ************************************************************************* //
Inter-processor communication reduction functions.
static void reduceOr(bool &value, const label communicator=worldComm)
Logical (or) reduction (MPI_AllReduce)
#define Pstream_BitwiseReductions(Native)
static void reduceAnd(bool &value, const label communicator=worldComm)
Logical (and) reduction (MPI_AllReduce)
#define Pstream_FloatReductions(Native)
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
#define Pstream_CommonReductions(Native)