Block-Structured AMR Software Framework
AMReX_OpenMP.H
Go to the documentation of this file.
1 #ifndef AMREX_OPENMP_H_
2 #define AMREX_OPENMP_H_
3 #include <AMReX_Config.H>
4 
5 #ifdef AMREX_USE_OMP
6 #include <AMReX_Extension.H>
7 #include <omp.h>
8 
9 namespace amrex::OpenMP {
10 
11  inline int get_num_threads () { return omp_get_num_threads(); }
12  inline int get_max_threads () { return omp_get_max_threads(); }
13  inline int get_thread_num () { return omp_get_thread_num(); }
14  inline int in_parallel () { return omp_in_parallel(); }
15  inline void set_num_threads (int num) { omp_set_num_threads(num); }
16 
17  void Initialize ();
18  void Finalize ();
19 
20 #if defined(_WIN32)
21  void** get_lock_impl (int ilock);
22 
23  inline omp_lock_t* get_lock (int ilock) {
24  return (omp_lock_t*)(*(get_lock_impl(ilock)));
25  }
26 #else
27  omp_lock_t* get_lock (int ilock);
28 #endif
29 }
30 
31 #else // AMREX_USE_OMP
32 
33 namespace amrex::OpenMP {
34 
35  constexpr int get_num_threads () { return 1; }
36  constexpr int get_max_threads () { return 1; }
37  constexpr int get_thread_num () { return 0; }
38  constexpr int in_parallel () { return false; }
39  constexpr void set_num_threads (int) { /* nothing */ }
40 }
41 
42 #endif // AMREX_USE_OMP
43 
44 namespace amrex {
46  int
48 }
49 
50 #endif
Definition: AMReX_OpenMP.H:33
constexpr int get_thread_num()
Definition: AMReX_OpenMP.H:37
constexpr void set_num_threads(int)
Definition: AMReX_OpenMP.H:39
constexpr int get_num_threads()
Definition: AMReX_OpenMP.H:35
constexpr int in_parallel()
Definition: AMReX_OpenMP.H:38
constexpr int get_max_threads()
Definition: AMReX_OpenMP.H:36
integer function omp_get_num_threads()
Definition: AMReX_omp_mod.F90:29
integer function omp_get_thread_num()
Definition: AMReX_omp_mod.F90:37
integer function omp_get_max_threads()
Definition: AMReX_omp_mod.F90:33
logical function omp_in_parallel()
Definition: AMReX_omp_mod.F90:41
Definition: AMReX_Amr.cpp:49
AMReX * Initialize(MPI_Comm mpi_comm, std::ostream &a_osout=std::cout, std::ostream &a_oserr=std::cerr, ErrorHandler a_errhandler=nullptr)
Definition: AMReX.cpp:322
void Finalize(AMReX *pamrex)
Definition: AMReX.cpp:731
int numUniquePhysicalCores()
Definition: AMReX_OpenMP.cpp:29