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 "UPstream.H"
29 #include <cstring> // memmove
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 #undef Pstream_CommonRoutines
34 #define Pstream_CommonRoutines(Native) \
35  \
36 void Foam::UPstream::mpiGather \
37 ( \
38  const Native* sendData, \
39  Native* recvData, \
40  int count, \
41  const label comm \
42 ) \
43 { \
44  std::memmove(recvData, sendData, count*sizeof(Native)); \
45 } \
46  \
47  \
48 void Foam::UPstream::mpiScatter \
49 ( \
50  const Native* sendData, \
51  Native* recvData, \
52  int count, \
53  const label comm \
54 ) \
55 { \
56  std::memmove(recvData, sendData, count*sizeof(Native)); \
57 } \
58  \
59  \
60 void Foam::UPstream::mpiAllGather \
61 ( \
62  Native* allData, \
63  int count, \
64  const label comm \
65 ) \
66 {}
67 
69 
70 #undef Pstream_CommonRoutines
71 
72 
73 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74 
75 #undef Pstream_CommonRoutines
76 #define Pstream_CommonRoutines(Native) \
77 void Foam::UPstream::gather \
78 ( \
79  const Native* sendData, \
80  int sendCount, \
81  \
82  Native* recvData, \
83  const UList<int>& recvCounts, \
84  const UList<int>& recvOffsets, \
85  const label comm \
86 ) \
87 { \
88  /* recvCounts[0] may be invalid - use sendCount instead */ \
89  std::memmove(recvData, sendData, sendCount*sizeof(Native)); \
90 } \
91  \
92 void Foam::UPstream::scatter \
93 ( \
94  const Native* sendData, \
95  const UList<int>& sendCounts, \
96  const UList<int>& sendOffsets, \
97  \
98  Native* recvData, \
99  int recvCount, \
100  const label comm \
101 ) \
102 { \
103  std::memmove(recvData, sendData, recvCount*sizeof(Native)); \
104 }
107 //TDB: Pstream_CommonRoutines(bool);
109 Pstream_CommonRoutines(int32_t);
110 Pstream_CommonRoutines(int64_t);
111 Pstream_CommonRoutines(uint32_t);
112 Pstream_CommonRoutines(uint64_t);
114 Pstream_CommonRoutines(double);
115 
116 #undef Pstream_CommonRoutines
117 
118 // ************************************************************************* //
#define Pstream_CommonRoutines(Native)