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 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  label& requestID \
143 ) \
144 {} \
145  \
146 void Foam::reduce \
147 ( \
148  Native& value, \
149  const sumOp<Native>&, \
150  const int tag, \
151  const label comm, \
152  label& requestID \
153 ) \
154 {} \
155  \
156 void Foam::sumReduce \
157 ( \
158  Native& value, \
159  label& count, \
160  const int tag, \
161  const label comm \
162 ) \
163 {}
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 Pstream_CommonReductions(int32_t);
169 Pstream_CommonReductions(int64_t);
170 Pstream_CommonReductions(uint32_t);
171 Pstream_CommonReductions(uint64_t);
172 
175 
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
179 #undef Pstream_CommonReductions
180 #undef Pstream_FloatReductions
181 
182 
183 // ************************************************************************* //
Inter-processor communication reduction functions.
static void reduceOr(bool &value, const label communicator=worldComm)
Logical (or) reduction (cf. MPI AllReduce)
static void reduceAnd(bool &value, const label communicator=worldComm)
Logical (and) reduction (cf. 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)