diff --git a/python/_project.pyx b/python/_project.pyx index ae5b4b9..e432495 100644 --- a/python/_project.pyx +++ b/python/_project.pyx @@ -6,7 +6,6 @@ import numpy as np cimport numpy as npx cimport cython from copy cimport * -from openmp cimport omp_get_max_threads, omp_get_thread_num ctypedef npx.float64_t DTYPE_t DTYPE=np.float64 @@ -18,6 +17,10 @@ cdef extern from "project_tool.hpp" namespace "": DTYPE_t compute_projection(DTYPE_t *vertex_value, DTYPE_t *u, DTYPE_t *u0, DTYPE_t rho) nogil +cdef extern from "openmp.hpp" namespace "CosmoTool": + int smp_get_max_threads() nogil + int smp_get_thread_id() nogil + @cython.boundscheck(False) @cython.cdivision(True) @@ -850,7 +853,7 @@ def spherical_projection(int Nside, if progress != 0: p = pb.ProgressBar(maxval=outm.size,widgets=[pb.Bar(), pb.ETA()]).start() - N = omp_get_max_threads() + N = smp_get_max_threads() N0 = outm.size if booster < 0: @@ -860,7 +863,7 @@ def spherical_projection(int Nside, job_done[:] = 0 theta,phi = hp.pix2ang(Nside, np.arange(N0)) with nogil, parallel(): - tid = omp_get_thread_num() + tid = smp_get_thread_id() for i in prange(N0): if progress != 0 and (i%booster) == 0: with gil: diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5d42ce4..ce0aea7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -9,10 +9,10 @@ SET(CosmoTool_SRCS miniargs.cpp growthFactor.cpp cosmopower.cpp + cic.cpp ) IF (ENABLE_OPENMP) - set(CosmoTool_SRCS ${CosmoTool_SRCS} cic.cpp) ENDIF (ENABLE_OPENMP) IF(FOUND_NETCDF3) diff --git a/src/cic.cpp b/src/cic.cpp index 8be6016..31596ca 100644 --- a/src/cic.cpp +++ b/src/cic.cpp @@ -32,7 +32,7 @@ same conditions as regards security. The fact that you are presently reading this means that you have had knowledge of the CeCILL license and that you accept its terms. +*/ -#include +#include "openmp.hpp" #include #include #include @@ -62,7 +62,7 @@ void CICFilter::resetMesh() void CICFilter::putParticles(CICParticles *particles, uint32_t N) { - int threadUsed = omp_get_max_threads(); + int threadUsed = smp_get_max_threads(); double *threadedDensity[threadUsed]; bool threadActivated[threadUsed]; uint32_t tUsedMin[threadUsed], tUsedMax[threadUsed]; @@ -79,7 +79,7 @@ void CICFilter::putParticles(CICParticles *particles, uint32_t N) #pragma omp parallel { - int thisThread = omp_get_thread_num(); + int thisThread = smp_get_thread_id(); double *dg = threadedDensity[thisThread]; threadActivated[thisThread] = true;