Release the GIL
This commit is contained in:
parent
a5cf276771
commit
5093212ec0
@ -385,8 +385,8 @@ def interp2d(x not None, y not None,
|
|||||||
|
|
||||||
@cython.boundscheck(False)
|
@cython.boundscheck(False)
|
||||||
@cython.cdivision(True)
|
@cython.cdivision(True)
|
||||||
cdef void INTERNAL_project_cic_no_mass(npx.ndarray[DTYPE_t, ndim=3] g,
|
cdef void INTERNAL_project_cic_no_mass(DTYPE_t[:,:,:] g,
|
||||||
npx.ndarray[DTYPE_t, ndim=2] x, int Ngrid, double Lbox, double shifter):
|
DTYPE_t[:,:] x, int Ngrid, double Lbox, double shifter) nogil:
|
||||||
cdef double delta_Box = Ngrid/Lbox
|
cdef double delta_Box = Ngrid/Lbox
|
||||||
cdef int i
|
cdef int i
|
||||||
cdef double a[3]
|
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.boundscheck(False)
|
||||||
@cython.cdivision(True)
|
@cython.cdivision(True)
|
||||||
cdef void INTERNAL_project_cic_no_mass_periodic(npx.ndarray[DTYPE_t, ndim=3] g,
|
cdef void INTERNAL_project_cic_no_mass_periodic(DTYPE_t[:,:,:] g,
|
||||||
npx.ndarray[DTYPE_t, ndim=2] x, int Ngrid, double Lbox, double shifter):
|
DTYPE_t[:,:] x, int Ngrid, double Lbox, double shifter) nogil:
|
||||||
cdef double delta_Box = Ngrid/Lbox
|
cdef double delta_Box = Ngrid/Lbox
|
||||||
cdef int i
|
cdef int i
|
||||||
cdef double a[3]
|
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.boundscheck(False)
|
||||||
@cython.cdivision(True)
|
@cython.cdivision(True)
|
||||||
cdef void INTERNAL_project_cic_with_mass(npx.ndarray[DTYPE_t, ndim=3] g,
|
cdef void INTERNAL_project_cic_with_mass(DTYPE_t[:,:,:] g,
|
||||||
npx.ndarray[DTYPE_t, ndim=2] x,
|
DTYPE_t[:,:] x,
|
||||||
npx.ndarray[DTYPE_t, ndim=1] mass,
|
DTYPE_t[:] mass,
|
||||||
int Ngrid, double Lbox, double shifter):
|
int Ngrid, double Lbox, double shifter) nogil:
|
||||||
cdef double delta_Box = Ngrid/Lbox
|
cdef double delta_Box = Ngrid/Lbox
|
||||||
cdef int i
|
cdef int i
|
||||||
cdef double a[3]
|
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.boundscheck(False)
|
||||||
@cython.cdivision(True)
|
@cython.cdivision(True)
|
||||||
cdef void INTERNAL_project_cic_with_mass_periodic(npx.ndarray[DTYPE_t, ndim=3] g,
|
cdef void INTERNAL_project_cic_with_mass_periodic(DTYPE_t[:,:,:] g,
|
||||||
npx.ndarray[DTYPE_t, ndim=2] x,
|
DTYPE_t[:,:] x,
|
||||||
npx.ndarray[DTYPE_t, ndim=1] mass,
|
DTYPE_t[:] mass,
|
||||||
int Ngrid, double Lbox, double shifter):
|
int Ngrid, double Lbox, double shifter) nogil:
|
||||||
cdef double half_Box = 0.5*Lbox, m0
|
cdef double half_Box = 0.5*Lbox, m0
|
||||||
cdef double delta_Box = Ngrid/Lbox
|
cdef double delta_Box = Ngrid/Lbox
|
||||||
cdef int i
|
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 npx.ndarray[DTYPE_t, ndim=3] g
|
||||||
cdef double shifter
|
cdef double shifter
|
||||||
|
cdef bool local_periodic
|
||||||
|
|
||||||
|
local_periodic = periodic
|
||||||
|
|
||||||
if centered:
|
if centered:
|
||||||
shifter = 0.5*Lbox
|
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)
|
g = np.zeros((Ngrid,Ngrid,Ngrid),dtype=DTYPE)
|
||||||
|
|
||||||
if not periodic:
|
if not local_periodic:
|
||||||
if mass is None:
|
if mass is None:
|
||||||
|
with nogil:
|
||||||
INTERNAL_project_cic_no_mass(g, x, Ngrid, Lbox, shifter)
|
INTERNAL_project_cic_no_mass(g, x, Ngrid, Lbox, shifter)
|
||||||
else:
|
else:
|
||||||
|
with nogil:
|
||||||
INTERNAL_project_cic_with_mass(g, x, mass, Ngrid, Lbox, shifter)
|
INTERNAL_project_cic_with_mass(g, x, mass, Ngrid, Lbox, shifter)
|
||||||
else:
|
else:
|
||||||
if mass is None:
|
if mass is None:
|
||||||
|
with nogil:
|
||||||
INTERNAL_project_cic_no_mass_periodic(g, x, Ngrid, Lbox, shifter)
|
INTERNAL_project_cic_no_mass_periodic(g, x, Ngrid, Lbox, shifter)
|
||||||
else:
|
else:
|
||||||
|
with nogil:
|
||||||
INTERNAL_project_cic_with_mass_periodic(g, x, mass, Ngrid, Lbox, shifter)
|
INTERNAL_project_cic_with_mass_periodic(g, x, mass, Ngrid, Lbox, shifter)
|
||||||
|
|
||||||
return g
|
return g
|
||||||
|
Loading…
Reference in New Issue
Block a user