PstreamGlobals.H
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) 2013-2015 OpenFOAM Foundation
9  Copyright (C) 2022 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Namespace
28  Foam::PstreamGlobals
29 
30 Description
31  Global functions and variables for working with parallel streams,
32  but principally for mpi
33 
34 SourceFiles
35  PstreamGlobals.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef Foam_PstreamGlobals_H
40 #define Foam_PstreamGlobals_H
41 
42 #include "DynamicList.H"
43 #include <mpi.h>
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 namespace PstreamGlobals
50 {
51 
52 //- Outstanding non-blocking operations.
53 extern DynamicList<MPI_Request> outstandingRequests_;
54 extern DynamicList<label> freedRequests_;
55 
56 //- Max outstanding message tag operations.
57 extern int nTags_;
58 
59 //- Free'd message tags
60 extern DynamicList<int> freedTags_;
61 
62 // Current communicators, which may be allocated or predefined
63 // (eg, MPI_COMM_SELF, MPI_COMM_WORLD)
64 extern DynamicList<MPI_Comm> MPICommunicators_;
65 
66 // Groups associated with the currrent communicators.
67 extern DynamicList<MPI_Group> MPIGroups_;
68 
69 
70 // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
71 
72 //- Fatal if comm is outside the allocated range
73 void checkCommunicator(const label comm, const label toProcNo);
74 
75 //- Reuse previously freed request locations or push request onto list
76 //- of outstanding requests.
77 //
78 // \return index of request within outstandingRequests_
79 inline label push_request(MPI_Request request)
80 {
81  label index;
82 
83  if (freedRequests_.size())
84  {
85  index = freedRequests_.back();
87  outstandingRequests_[index] = request;
88  }
89  else
90  {
91  index = outstandingRequests_.size();
92  outstandingRequests_.push_back(request);
93  }
94 
95  return index;
96 }
97 
98 
99 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
100 
101 } // End namespace PstreamGlobals
102 } // End namespace Foam
103 
104 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
105 
106 #endif
107 
108 // ************************************************************************* //
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:118
DynamicList< label > freedRequests_
DynamicList< MPI_Request > outstandingRequests_
Outstanding non-blocking operations.
DynamicList< int > freedTags_
Free&#39;d message tags.
DynamicList< MPI_Comm > MPICommunicators_
void checkCommunicator(const label comm, const label toProcNo)
Fatal if comm is outside the allocated range.
void pop_back(label n=1)
Reduce size by 1 or more elements. Can be called on an empty list.
Definition: DynamicListI.H:648
int nTags_
Max outstanding message tag operations.
DynamicList< MPI_Group > MPIGroups_
label push_request(MPI_Request request)
Reuse previously freed request locations or push request onto list of outstanding requests...
T & back()
Access last element of the list, position [size()-1].
Definition: UListI.H:209
Namespace for OpenFOAM.