Skip to content

Commit

Permalink
Fix SMP bug
Browse files Browse the repository at this point in the history
  • Loading branch information
joezuntz committed Feb 13, 2025
1 parent c3c2df5 commit b83b50f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cosmosis/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,8 @@ def run_cosmosis(ini, pool=None, pipeline=None, values=None, priors=None, overri
run_count_total = pipeline.run_count
run_count_ok_total = pipeline.run_count_ok
else:
run_count_total = pool.comm.allreduce(pipeline.run_count)
run_count_ok_total = pool.comm.allreduce(pipeline.run_count_ok)
run_count_total = pool.allreduce(pipeline.run_count)
run_count_ok_total = pool.allreduce(pipeline.run_count_ok)

Check warning on line 434 in cosmosis/main.py

View check run for this annotation

Codecov / codecov/patch

cosmosis/main.py#L433-L434

Added lines #L433 - L434 were not covered by tests

if is_root and sampler_name != 'test':
logs.overview(f"Total posterior evaluations = {run_count_total} across all processes")
Expand Down
3 changes: 3 additions & 0 deletions cosmosis/runtime/mpi_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ def send(self, data, dest=0, tag=0):
def recv(self, source=0, tag=0):
return self.comm.recv(source, tag)

def allreduce(self, data):
return self.comm.allreduce(data)

Check warning on line 118 in cosmosis/runtime/mpi_pool.py

View check run for this annotation

Codecov / codecov/patch

cosmosis/runtime/mpi_pool.py#L118

Added line #L118 was not covered by tests

def close(self):
if self.is_master():
for i in range(1, self.size):
Expand Down
6 changes: 3 additions & 3 deletions cosmosis/runtime/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1307,11 +1307,11 @@ def _set_likelihood_names_from_block(self, data):
self.likelihood_names = likelihood_names

# Tell the user what we found.
logs.overview("Using likelihooods from first run:")
logs.noisy("Using likelihooods from first run:")
for name in self.likelihood_names:
logs.overview(f" - {name}")
logs.noisy(f" - {name}")
if not self.likelihood_names:
logs.overview(" - (None found)")
logs.noisy(" - (None found)")

def _extract_likelihoods(self, data):
"Extract the likelihoods from the block"
Expand Down
2 changes: 2 additions & 0 deletions cosmosis/runtime/process_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def bcast(self, data):
def gather(self, data):
return self.data

def allreduce(self, data):
return self.data

Check warning on line 29 in cosmosis/runtime/process_pool.py

View check run for this annotation

Codecov / codecov/patch

cosmosis/runtime/process_pool.py#L29

Added line #L29 was not covered by tests

def __enter__(self):
return self
Expand Down

0 comments on commit b83b50f

Please sign in to comment.