Skip to content

Commit

Permalink
Fix parallelization issues
Browse files Browse the repository at this point in the history
  • Loading branch information
keskitalo committed Aug 29, 2024
1 parent 922b7bb commit b5c0bc1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/toast/ops/interpolate_healpix.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,21 @@ def _exec(self, data, detectors=None, **kwargs):
# timestreams.

world_comm = data.comm.comm_world
world_rank = world_comm.rank
if world_comm is None:
world_rank = 0
else:
world_rank = world_comm.rank

for file_name, map_name in zip(self.file_names, self.map_names):
if map_name not in self.maps:
if world_rank == 0:
m = np.atleast_2d(read_healpix(file_name, None, dtype=np.float32))
mshape = m.shape
map_shape = m.shape
else:
m = None
mshape = None
map_shape = world_comm.bcast(mshape)
map_shape = None
if world_comm is not None:
map_shape = world_comm.bcast(map_shape)
self.maps[map_name] = MPIShared(map_shape, np.float32, world_comm)
self.maps[map_name].set(m)

Expand Down
2 changes: 1 addition & 1 deletion src/toast/tests/ops_interpolate_healpix.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ def test_interpolate(self):
)
weights.apply(data)

hpix_file = os.path.join(self.outdir, "fake.fits")
if data.comm.comm_world is None or data.comm.comm_world.rank == 0:
# Create a smooth sky
lmax = 3 * pixels.nside
cls = np.ones([4, lmax + 1])
np.random.seed(98776)
fake_sky = hp.synfast(cls, pixels.nside, fwhm=np.radians(30))
# Write this to a file
hpix_file = os.path.join(self.outdir, "fake.fits")
hp.write_map(hpix_file, fake_sky)

# Scan the map from the file
Expand Down

0 comments on commit b5c0bc1

Please sign in to comment.