openmp_support.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef PLANCK_OPENMP_SUPPORT_H
00033 #define PLANCK_OPENMP_SUPPORT_H
00034
00035 #ifdef _OPENMP
00036 #include <omp.h>
00037 #endif
00038
00039 #include "share_utils.h"
00040
00041 inline bool openmp_enabled()
00042 {
00043 #ifdef _OPENMP
00044 return true;
00045 #else
00046 return false;
00047 #endif
00048 }
00049
00050 inline int openmp_max_threads ()
00051 {
00052 #ifdef _OPENMP
00053 return omp_get_max_threads();
00054 #else
00055 return 1;
00056 #endif
00057 }
00058
00059 inline int openmp_num_threads ()
00060 {
00061 #ifdef _OPENMP
00062 return omp_get_num_threads();
00063 #else
00064 return 1;
00065 #endif
00066 }
00067
00068 inline int openmp_thread_num ()
00069 {
00070 #ifdef _OPENMP
00071 return omp_get_thread_num();
00072 #else
00073 return 0;
00074 #endif
00075 }
00076
00077
00078
00079
00080
00081
00082 inline void openmp_calc_share (int64 glo, int64 ghi, int64 &lo, int64 &hi)
00083 {
00084 #ifdef _OPENMP
00085 calcShareGeneral (glo,ghi,omp_get_num_threads(),omp_get_thread_num(),lo,hi);
00086 #else
00087 lo=glo; hi=ghi;
00088 #endif
00089 }
00090
00091 #endif