Reactivate parallel for sphrical projection, add some auxiliary attribute in ctpv.

This commit is contained in:
Guilhem Lavaux 2018-05-10 15:31:48 +02:00
parent 897427436e
commit 18c81baac9
2 changed files with 13 additions and 4 deletions

View File

@ -874,11 +874,11 @@ def spherical_projection(int Nside,
job_done = view.array(shape=(N,), format="i", itemsize=sizeof(int))
job_done[:] = 0
theta,phi = hp.pix2ang(Nside, np.arange(N0))
if True:#nogil, parallel():
with nogil, parallel():
tid = smp_get_thread_id()
for i in range(N0):#prange(N0,schedule='dynamic',chunksize=256):
for i in prange(N0,schedule='dynamic',chunksize=256):
if progress != 0 and (i%booster) == 0:
# with gil:
with gil:
p.update(_mysum(job_done))
outm[i] = _spherical_projloop(theta[i], phi[i], density_view, min_distance, max_distance, shifter, integrator_id)
job_done[tid] += 1

View File

@ -4,7 +4,7 @@ from contextlib import contextmanager
class ProgrammableParticleLoad(object):
@staticmethod
def main_script(source, particles, aname="default"):
def main_script(source, particles, aname="default", aux=None):
import vtk
from vtk.util import numpy_support as ns
@ -20,6 +20,15 @@ class ProgrammableParticleLoad(object):
out.Allocate(1,1)
out.SetPoints(vv)
if aux is not None:
for n,a in aux:
a_vtk = ns.numpy_to_vtk(
np.ascontiguousarray(a.astype(np.float64)
),
deep=1)
a_vtk.SetName(n)
out.GetPointData().AddArray(a_vtk)
out.InsertNextCell(vtk.VTK_VERTEX, particles.shape[0], range(particles.shape[0]))
@staticmethod