Anasazi  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
AnasaziGlobalComm.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Anasazi: Block Eigensolvers Package
4 //
5 // Copyright 2004 NTESS and the Anasazi contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef ANASAZI_GLOBAL_COMM_HPP
11 #define ANASAZI_GLOBAL_COMM_HPP
12 
13 #include "AnasaziConfigDefs.hpp"
14 
15 #ifdef HAVE_MPI
16 
17 #include <mpi.h>
18 #include <mutex>
19 
20 namespace Anasazi {
21 
22 static std::mutex mpi_mutex;
23 static MPI_Comm Global_Anasazi_Comm = MPI_COMM_WORLD;
24 
25 inline void initialize_global_comm(MPI_Comm comm) {
26  std::lock_guard<std::mutex> guard(mpi_mutex);
27  Global_Anasazi_Comm = comm;
28 }
29 
30 inline MPI_Comm get_global_comm() {
31  std::lock_guard<std::mutex> guard(mpi_mutex);
32  return Global_Anasazi_Comm;
33 }
34 } // namespace Anasazi
35 
36 #endif // HAVE_MPI
37 
38 #endif // ANASAZI_GLOBAL_COMM_HPP
Anasazi header file which uses auto-configuration information to include necessary C++ headers...