QMCPACK
OpenMP.h
Go to the documentation of this file.
1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2016 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
8 // Jeremy McMinnis, jmcminis@gmail.com, University of Illinois at Urbana-Champaign
9 //
10 // File created by: Jeongnim Kim, jeongnim.kim@gmail.com, University of Illinois at Urbana-Champaign
11 //////////////////////////////////////////////////////////////////////////////////////
12 
13 
14 #ifndef OHMMS_OPENMP_H
15 #define OHMMS_OPENMP_H
16 
17 #ifdef HAVE_CONFIG_H
18 #include "config.h"
19 #endif
20 
21 #ifdef _OPENMP
22 #include <omp.h>
23 #else
24 using omp_int_t = int;
25 inline omp_int_t omp_get_thread_num() { return 0; }
26 inline omp_int_t omp_get_max_threads() { return 1; }
27 inline omp_int_t omp_get_num_threads() { return 1; }
28 inline omp_int_t omp_get_level() { return 0; }
29 inline omp_int_t omp_get_ancestor_thread_num(int level) { return 0; }
30 inline omp_int_t omp_get_max_active_levels() { return 1; }
31 inline void omp_set_num_threads(int num_threads) {}
32 #endif
33 
34 /// get the number of threads at the next parallel level
36 {
37  int num_threads = 1;
38 #pragma omp parallel
39  {
40 #pragma omp master
41  num_threads = omp_get_num_threads();
42  }
43  return num_threads;
44 }
45 
46 #endif // OHMMS_COMMUNICATE_H
void omp_set_num_threads(int num_threads)
Definition: OpenMP.h:31
omp_int_t omp_get_ancestor_thread_num(int level)
Definition: OpenMP.h:29
int omp_int_t
Definition: OpenMP.h:24
omp_int_t omp_get_thread_num()
Definition: OpenMP.h:25
omp_int_t omp_get_max_threads()
Definition: OpenMP.h:26
omp_int_t omp_get_max_active_levels()
Definition: OpenMP.h:30
omp_int_t omp_get_num_threads()
Definition: OpenMP.h:27
omp_int_t omp_get_level()
Definition: OpenMP.h:28
int getNextLevelNumThreads()
get the number of threads at the next parallel level
Definition: OpenMP.h:35