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 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 <mpi.h>
32 #include <cinttypes>
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 #undef Pstream_CommonRoutines
37 #define Pstream_CommonRoutines(Native, TaggedType) \
38 void Foam::UPstream::mpiGather \
39 ( \
40  const Native* sendData, \
41  int sendCount, \
42  \
43  Native* recvData, \
44  int recvCount, \
45  const label comm \
46 ) \
47 { \
48  PstreamDetail::gather \
49  ( \
50  sendData, sendCount, recvData, recvCount, \
51  TaggedType, comm \
52  ); \
53 } \
54  \
55  \
56 void Foam::UPstream::mpiScatter \
57 ( \
58  const Native* sendData, \
59  int sendCount, \
60  \
61  Native* recvData, \
62  int recvCount, \
63  const label comm \
64 ) \
65 { \
66  PstreamDetail::scatter \
67  ( \
68  sendData, sendCount, recvData, recvCount, \
69  TaggedType, comm \
70  ); \
71 }
72 
73 Pstream_CommonRoutines(char, MPI_BYTE);
74 
75 #undef Pstream_CommonRoutines
76 
77 
78 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
79 
80 #undef Pstream_CommonRoutines
81 #define Pstream_CommonRoutines(Native, TaggedType) \
82 void Foam::UPstream::gather \
83 ( \
84  const Native* sendData, \
85  int sendCount, \
86  \
87  Native* recvData, \
88  const UList<int>& recvCounts, \
89  const UList<int>& recvOffsets, \
90  const label comm \
91 ) \
92 { \
93  PstreamDetail::gatherv \
94  ( \
95  sendData, sendCount, \
96  recvData, recvCounts, recvOffsets, \
97  TaggedType, comm \
98  ); \
99 } \
100  \
101 void Foam::UPstream::scatter \
102 ( \
103  const Native* sendData, \
104  const UList<int>& sendCounts, \
105  const UList<int>& sendOffsets, \
106  \
107  Native* recvData, \
108  int recvCount, \
109  const label comm \
110 ) \
111 { \
112  PstreamDetail::scatterv \
113  ( \
114  sendData, sendCounts, sendOffsets, \
115  recvData, recvCount, \
116  TaggedType, comm \
117  ); \
118 }
119 
120 
121 //TDB: Pstream_CommonRoutines(bool, MPI_C_BOOL);
122 Pstream_CommonRoutines(char, MPI_BYTE);
123 Pstream_CommonRoutines(int32_t, MPI_INT32_T);
124 Pstream_CommonRoutines(int64_t, MPI_INT64_T);
125 Pstream_CommonRoutines(uint32_t, MPI_UINT32_T);
126 Pstream_CommonRoutines(uint64_t, MPI_UINT64_T);
127 Pstream_CommonRoutines(float, MPI_FLOAT);
128 Pstream_CommonRoutines(double, MPI_DOUBLE);
129 
130 #undef Pstream_CommonRoutines
131 
132 // ************************************************************************* //
#define Pstream_CommonRoutines(Native, TaggedType)