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