Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the broken decomposition #27

Merged
merged 2 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions _episodes/16-parallel.md
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,8 @@ We replace the `start_time` and `counts` lines with the lines:
if rank == 0:
start_time = datetime.datetime.now()
partitions = [ int(n_samples / cpus) ] * cpus
for a in range(n_samples - sum(partitions)):
partitions[a] += 1
counts = [ int(0) ] * cpus
else:
partitions = None
Expand Down
2 changes: 2 additions & 0 deletions files/pi-mpi-minimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def inside_circle(total_count):
n_samples = int(sys.argv[1])
if rank == 0:
partitions = [ int(n_samples / cpus) ] * cpus
for a in range(n_samples - sum(partitions)):
partitions[a] += 1
counts = [ int(0) ] * cpus
else:
partitions = None
Expand Down
5 changes: 5 additions & 0 deletions files/pi-mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ def inside_circle(total_count):
# one for the number of samples they should run, and
# one to store the count info each rank returns.
partitions = [ int(n_samples / cpus) ] * cpus
# if the number of partitions does not equally divide the number of
# samples, we need to tidy up - work out left over and add 1
# to each of that many partitions.
for a in range(n_samples - sum(partitions)):
partitions[a] += 1
counts = [ int(0) ] * cpus
else:
partitions = None
Expand Down
Loading