pysphereproj/sphereproj/openmp.hpp
2024-11-01 17:05:09 +02:00

42 lines
575 B
C++

#pragma once
#ifdef _OPENMP
#include <omp.h>
#endif
namespace sphereproj {
static int smp_get_max_threads() {
#ifdef _OPENMP
return omp_get_max_threads();
#else
return 1;
#endif
}
static int smp_get_thread_id() {
#ifdef _OPENMP
return omp_get_thread_num();
#else
return 0;
#endif
}
static int smp_get_num_threads() {
#ifdef _OPENMP
return omp_get_num_threads();
#else
return 1;
#endif
}
static void smp_set_nested(bool n) {
#ifdef _OPENMP
omp_set_nested(n ? 1 : 0);
#endif
}
};