Release the GIL

This commit is contained in:
Guilhem Lavaux 2018-04-03 11:28:29 +02:00
parent a5cf276771
commit 5093212ec0

View File

@ -385,8 +385,8 @@ def interp2d(x not None, y not None,
@cython.boundscheck(False)
@cython.cdivision(True)
cdef void INTERNAL_project_cic_no_mass(npx.ndarray[DTYPE_t, ndim=3] g,
npx.ndarray[DTYPE_t, ndim=2] x, int Ngrid, double Lbox, double shifter):
cdef void INTERNAL_project_cic_no_mass(DTYPE_t[:,:,:] g,
DTYPE_t[:,:] x, int Ngrid, double Lbox, double shifter) nogil:
cdef double delta_Box = Ngrid/Lbox
cdef int i
cdef double a[3]
@ -418,8 +418,8 @@ cdef void INTERNAL_project_cic_no_mass(npx.ndarray[DTYPE_t, ndim=3] g,
@cython.boundscheck(False)
@cython.cdivision(True)
cdef void INTERNAL_project_cic_no_mass_periodic(npx.ndarray[DTYPE_t, ndim=3] g,
npx.ndarray[DTYPE_t, ndim=2] x, int Ngrid, double Lbox, double shifter):
cdef void INTERNAL_project_cic_no_mass_periodic(DTYPE_t[:,:,:] g,
DTYPE_t[:,:] x, int Ngrid, double Lbox, double shifter) nogil:
cdef double delta_Box = Ngrid/Lbox
cdef int i
cdef double a[3]
@ -459,10 +459,10 @@ cdef void INTERNAL_project_cic_no_mass_periodic(npx.ndarray[DTYPE_t, ndim=3] g,
@cython.boundscheck(False)
@cython.cdivision(True)
cdef void INTERNAL_project_cic_with_mass(npx.ndarray[DTYPE_t, ndim=3] g,
npx.ndarray[DTYPE_t, ndim=2] x,
npx.ndarray[DTYPE_t, ndim=1] mass,
int Ngrid, double Lbox, double shifter):
cdef void INTERNAL_project_cic_with_mass(DTYPE_t[:,:,:] g,
DTYPE_t[:,:] x,
DTYPE_t[:] mass,
int Ngrid, double Lbox, double shifter) nogil:
cdef double delta_Box = Ngrid/Lbox
cdef int i
cdef double a[3]
@ -496,10 +496,10 @@ cdef void INTERNAL_project_cic_with_mass(npx.ndarray[DTYPE_t, ndim=3] g,
@cython.boundscheck(False)
@cython.cdivision(True)
cdef void INTERNAL_project_cic_with_mass_periodic(npx.ndarray[DTYPE_t, ndim=3] g,
npx.ndarray[DTYPE_t, ndim=2] x,
npx.ndarray[DTYPE_t, ndim=1] mass,
int Ngrid, double Lbox, double shifter):
cdef void INTERNAL_project_cic_with_mass_periodic(DTYPE_t[:,:,:] g,
DTYPE_t[:,:] x,
DTYPE_t[:] mass,
int Ngrid, double Lbox, double shifter) nogil:
cdef double half_Box = 0.5*Lbox, m0
cdef double delta_Box = Ngrid/Lbox
cdef int i
@ -544,6 +544,9 @@ def project_cic(npx.ndarray[DTYPE_t, ndim=2] x not None, npx.ndarray[DTYPE_t, nd
"""
cdef npx.ndarray[DTYPE_t, ndim=3] g
cdef double shifter
cdef bool local_periodic
local_periodic = periodic
if centered:
shifter = 0.5*Lbox
@ -558,15 +561,19 @@ def project_cic(npx.ndarray[DTYPE_t, ndim=2] x not None, npx.ndarray[DTYPE_t, nd
g = np.zeros((Ngrid,Ngrid,Ngrid),dtype=DTYPE)
if not periodic:
if not local_periodic:
if mass is None:
with nogil:
INTERNAL_project_cic_no_mass(g, x, Ngrid, Lbox, shifter)
else:
with nogil:
INTERNAL_project_cic_with_mass(g, x, mass, Ngrid, Lbox, shifter)
else:
if mass is None:
with nogil:
INTERNAL_project_cic_no_mass_periodic(g, x, Ngrid, Lbox, shifter)
else:
with nogil:
INTERNAL_project_cic_with_mass_periodic(g, x, mass, Ngrid, Lbox, shifter)
return g