Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
openmp.h
Go to the documentation of this file.
1 #ifndef INCLUDED_EXTERNAL_LIBRARIES_OPENMP
2 #define INCLUDED_EXTERNAL_LIBRARIES_OPENMP
3 
4 // allows removing all OpenMP-related code via #define ENABLE_OPENMP 0
5 // before including this header. (useful during debugging, because the
6 // VC debugger isn't able to display OpenMP private variables)
7 #ifdef ENABLE_OPENMP
8 # if ENABLE_OPENMP && !defined(_OPENMP)
9 # error "either enable OpenMP in the compiler settings or don't set ENABLE_OPENMP to 1"
10 # endif
11 #else // no user preference; default to compiler setting
12 # ifdef _OPENMP
13 # define ENABLE_OPENMP 1
14 # else
15 # define ENABLE_OPENMP 0
16 # endif
17 #endif
18 
19 #if ENABLE_OPENMP
20 # include <omp.h>
21 #else
22 # define omp_get_num_threads() 1
23 # define omp_get_thread_num() 0
24 # define omp_in_parallel() 0
25 #endif
26 
27 // wrapper macro that evaluates to nothing if !ENABLE_OPENMP
28 // (much more convenient than individual #if ENABLE_OPENMP)
29 #if ENABLE_OPENMP
30 # if MSC_VERSION
31 # define OMP(args) __pragma(omp args)
32 # elif GCC_VERSION
33 # define OMP _Pragma("omp " #args)
34 # else
35 # error "port"
36 # endif
37 #else
38 # define OMP(args)
39 #endif
40 
41 #endif // #ifndef INCLUDED_EXTERNAL_LIBRARIES_OPENMP