Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_GlobalMPISession.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef TEUCHOS_GLOBAL_MPI_SESSION_HPP
11 #define TEUCHOS_GLOBAL_MPI_SESSION_HPP
12 
18 #include "TeuchosCore_ConfigDefs.hpp"
19 
20 #include "Teuchos_ArrayView.hpp"
21 
22 
23 namespace Teuchos {
24 
34 //
81 class TEUCHOSCORE_LIB_DLL_EXPORT GlobalMPISession
82 {
83 public:
84 
86 
87 
130  GlobalMPISession( int* argc, char*** argv, std::ostream *out = &std::cout );
131 
133  ~GlobalMPISession();
134 
136 
138 
139 
144  static void abort();
145 
147 
148 
156  static bool mpiIsInitialized();
157 
163  static bool mpiIsFinalized();
164 
175  static int getRank();
176 
187  static int getNProc();
188 
197  static void barrier();
198 
215  static int sum(int localVal);
216 
232  static void allGather(int localVal, const ArrayView<int> &allVals);
233 
234 #ifdef HAVE_TEUCHOSCORE_KOKKOS
235  static std::vector<std::string> getArgv ();
243 #endif // HAVE_TEUCHOSCORE_KOKKOS
244 
245 
246 private:
247 
248  static bool haveMPIState_;
249  static bool mpiIsFinalized_;
250  static int rank_;
251  static int nProc_;
252 #ifdef HAVE_TEUCHOSCORE_KOKKOS
253  static std::vector<std::string> argvCopy_;
261 #endif // HAVE_TEUCHOSCORE_KOKKOS
262 
263  static void initialize( std::ostream *out );
264 
265  static void justInTimeInitialize();
266 
267 };
268 
269 } // namespace Teuchos
270 
271 #endif // TEUCHOS_GLOBAL_MPI_SESSION_HPP
Initialize, finalize, and query the global MPI session.