Fix parallelization of the projector to make a proper reporting of the progress
This commit is contained in:
parent
0aeb0d80c3
commit
6967a1f55c
@ -731,6 +731,18 @@ cdef double _spherical_projloop(double theta, double phi, DTYPE_t[:,:,:] density
|
||||
|
||||
return C_line_of_sight_projection(density, u0, min_distance, max_distance, shifter, integrator_id)
|
||||
|
||||
@cython.boundscheck(False)
|
||||
cdef npx.uint64_t _mysum(int[:] jobs) nogil:
|
||||
cdef npx.uint64_t s
|
||||
cdef npx.uint64_t N
|
||||
cdef int i
|
||||
|
||||
s = 0
|
||||
N = jobs.shape[0]
|
||||
for i in xrange(N):
|
||||
s += jobs[i]
|
||||
return s
|
||||
|
||||
|
||||
@cython.boundscheck(False)
|
||||
def spherical_projection(int Nside,
|
||||
@ -744,6 +756,7 @@ def spherical_projection(int Nside,
|
||||
cdef DTYPE_t[:] theta,phi
|
||||
cdef DTYPE_t[:,:,:] density_view
|
||||
cdef DTYPE_t[:] outm
|
||||
cdef int[:] job_done
|
||||
cdef npx.ndarray[DTYPE_t, ndim=1] outm_array
|
||||
cdef long N
|
||||
cdef double stheta
|
||||
@ -760,13 +773,16 @@ def spherical_projection(int Nside,
|
||||
p = pb.ProgressBar(maxval=outm.size,widgets=[pb.BouncingBar(), pb.ETA()]).start()
|
||||
|
||||
N = outm.size
|
||||
job_done = view.array(shape=(1,), format="i", itemsize=sizeof(int))
|
||||
job_done[:] = 0
|
||||
theta,phi = hp.pix2ang(Nside, np.arange(N))
|
||||
with nogil, parallel():
|
||||
for i in prange(N):
|
||||
if progress != 0 and (i%booster) == 0:
|
||||
with gil:
|
||||
p.update(i)
|
||||
p.update(_mysum(job_done))
|
||||
outm[i] = _spherical_projloop(theta[i], phi[i], density_view, min_distance, max_distance, shifter, integrator_id)
|
||||
job_done[i] = 1
|
||||
|
||||
if progress:
|
||||
p.finish()
|
||||
|
@ -9,7 +9,7 @@ cosmo['omega_B_0']=0.049
|
||||
cosmo['SIGMA8']=0.8344
|
||||
cosmo['ns']=0.9624
|
||||
|
||||
supergen=4
|
||||
supergen=8
|
||||
zstart=50
|
||||
astart=1/(1.+zstart)
|
||||
halfPixelShift=False
|
||||
|
Loading…
Reference in New Issue
Block a user