From 3097b0035e0747116706223423d4e454bd3b2a59 Mon Sep 17 00:00:00 2001 From: Jarno Rantaharju Date: Tue, 24 Nov 2026 10:28:47 +0200 Subject: [PATCH 1/4] time full MPI section --- content/parallel.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/content/parallel.rst b/content/parallel.rst index b237ed89..ce1815ef 100644 --- a/content/parallel.rst +++ b/content/parallel.rst @@ -327,11 +327,12 @@ to get this MPI example to work: t0 = time.perf_counter() _, n_inside_circle = sample(n_task) - t = time.perf_counter() - t0 print(f"before gather: rank {rank}, n_inside_circle: {n_inside_circle}") n_inside_circle = comm.gather(n_inside_circle, root=0) print(f"after gather: rank {rank}, n_inside_circle: {n_inside_circle}") + + t = time.perf_counter() - t0 if rank == 0: pi_estimate = 4.0 * sum(n_inside_circle) / n From 606d408b75158886c2c04fc1afe153c8f033aa80 Mon Sep 17 00:00:00 2001 From: Jarno Rantaharju Date: Tue, 24 Nov 2026 10:46:55 +0200 Subject: [PATCH 2/4] Remove check for more than 1 mpi rank, division works anyway --- content/parallel.rst | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/content/parallel.rst b/content/parallel.rst index ce1815ef..ad36dbfa 100644 --- a/content/parallel.rst +++ b/content/parallel.rst @@ -290,7 +290,7 @@ algorithm from above, and we have highlighted the lines which are important to get this MPI example to work: .. code-block:: python - :emphasize-lines: 3,23-25,29,39,42 + :emphasize-lines: 3,23-25,36,39 import random import time @@ -320,10 +320,7 @@ to get this MPI example to work: n = 10 ** 7 - if size > 1: - n_task = int(n / size) - else: - n_task = n + n_task = int(n / size) t0 = time.perf_counter() _, n_inside_circle = sample(n_task) From 2f02ff4c2558a1600a999f37aa73b95f328e0ba1 Mon Sep 17 00:00:00 2001 From: Jarno Rantaharju Date: Tue, 24 Nov 2026 10:47:37 +0200 Subject: [PATCH 3/4] Fix highlighted line number --- content/parallel.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/parallel.rst b/content/parallel.rst index ad36dbfa..6e89b464 100644 --- a/content/parallel.rst +++ b/content/parallel.rst @@ -290,7 +290,7 @@ algorithm from above, and we have highlighted the lines which are important to get this MPI example to work: .. code-block:: python - :emphasize-lines: 3,23-25,36,39 + :emphasize-lines: 3,23-25,35,39 import random import time From d117eba68bb2b243400673470adef82fa7a10f75 Mon Sep 17 00:00:00 2001 From: Jarno Rantaharju Date: Tue, 24 Nov 2026 11:26:16 +0200 Subject: [PATCH 4/4] Update content/parallel.rst Co-authored-by: Lauri Niemi <113029612+niemilau@users.noreply.github.com> --- content/parallel.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/parallel.rst b/content/parallel.rst index 6e89b464..ac21d363 100644 --- a/content/parallel.rst +++ b/content/parallel.rst @@ -290,7 +290,7 @@ algorithm from above, and we have highlighted the lines which are important to get this MPI example to work: .. code-block:: python - :emphasize-lines: 3,23-25,35,39 + :emphasize-lines: 3,23-25,35,40 import random import time