Fixed openmp usage
This commit is contained in:
parent
ab36a5b24a
commit
8198cef3c5
@ -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:
|
||||
|
@ -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)
|
||||
|
@ -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 <omp.h>
|
||||
#include "openmp.hpp"
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <inttypes.h>
|
||||
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user