Skip to content

Commit

Permalink
Parallelize pixelize_sph_kernel_* methods. Fixes yt-project#2682
Browse files Browse the repository at this point in the history
  • Loading branch information
Xarthisius committed Jun 24, 2020
1 parent b92a05d commit e0146b6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions yt/utilities/lib/pixelization_routines.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1026,13 +1026,14 @@ def pixelize_sph_kernel_projection(
ih_j2 = 1.0/h_j2

prefactor_j = pmass[j] / pdens[j] / hsml[j]**2

if weight_field is None:
prefactor_j *= quantity_to_smooth[j]
else:
prefactor_j *= quantity_to_smooth[j] * _weight_field[j]

# found pixels we deposit on, loop through those pixels
for xi in range(x0, x1):
for xi in prange(x0, x1, schedule="static"):
# we use the centre of the pixel to calculate contribution
x = (xi + 0.5) * dx + x_min

Expand All @@ -1056,6 +1057,7 @@ def pixelize_sph_kernel_projection(
# now we just use the kernel projection
buff[xi, yi] += prefactor_j * itab.interpolate(q_ij2)


@cython.boundscheck(False)
@cython.wraparound(False)
def interpolate_sph_positions_gather(np.float64_t[:] buff,
Expand Down Expand Up @@ -1279,7 +1281,7 @@ def pixelize_sph_kernel_slice(

# Now we know which pixels to deposit onto for this particle,
# so loop over them and add this particle's contribution
for xi in range(x0, x1):
for xi in prange(x0, x1, schedule="static"):
x = (xi + 0.5) * dx + x_min

posx_diff = posx[j] - x
Expand Down Expand Up @@ -1371,7 +1373,7 @@ def pixelize_sph_kernel_arbitrary_grid(np.float64_t[:, :, :] buff,

# Now we know which voxels to deposit onto for this particle,
# so loop over them and add this particle's contribution
for xi in range(x0, x1):
for xi in range(x0, x1, schedule="static"):
x = (xi + 0.5) * dx + x_min

posx_diff = posx[j] - x
Expand Down

0 comments on commit e0146b6

Please sign in to comment.