Belos  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BelosGlobalComm.hpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Belos: Block Linear Solvers Package
4 //
5 // Copyright 2004-2016 NTESS and the Belos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef BELOS_GLOBAL_COMM_HPP
11 #define BELOS_GLOBAL_COMM_HPP
12 
13 #ifdef HAVE_MPI
14 
15 #include <mpi.h>
16 #include <mutex>
17 
18 namespace Belos {
19 
20 static std::mutex mpi_mutex;
21 static MPI_Comm Global_MPI_Comm = MPI_COMM_WORLD; // CHECK: ALLOW MPI_COMM_WORLD
22 
23 inline void initialize_global_comm(MPI_Comm comm) {
24  std::lock_guard<std::mutex> guard(mpi_mutex);
25  Global_MPI_Comm = comm;
26 }
27 
28 inline MPI_Comm get_global_comm() {
29  std::lock_guard<std::mutex> guard(mpi_mutex);
30  return Global_MPI_Comm;
31 }
32 
33 }
34 
35 #endif // HAVE_MPI
36 #endif // BELOS_GLOBAL_COMM_HPP

Generated on Fri Nov 22 2024 09:23:06 for Belos by doxygen 1.8.5