From 84c94097ff9ef69d691f013790f260881b9f3e90 Mon Sep 17 00:00:00 2001 From: Pablo Brubeck Date: Tue, 14 Jan 2025 15:43:48 +0000 Subject: [PATCH] Rename option to view_patch_sizes, include the average patch size --- firedrake/preconditioners/asm.py | 12 ++++++++---- tests/firedrake/regression/test_star_pc.py | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/firedrake/preconditioners/asm.py b/firedrake/preconditioners/asm.py index baa21f8828..f3eaa037d9 100644 --- a/firedrake/preconditioners/asm.py +++ b/firedrake/preconditioners/asm.py @@ -92,13 +92,17 @@ def initialize(self, pc): self.asmpc = asmpc self._patch_statistics = [] - if opts.getBool("print_patch_statistics", default=False): + if opts.getBool("view_patch_sizes", default=False): # Compute and stash patch statistics + mpi_comm = pc.comm.tompi4py() max_local_patch = max(is_.getSize() for is_ in ises) min_local_patch = min(is_.getSize() for is_ in ises) - max_global_patch = pc.comm.tompi4py().allreduce(max_local_patch, op=MPI.MAX) - min_global_patch = pc.comm.tompi4py().allreduce(min_local_patch, op=MPI.MIN) - msg = f"Minimum / maximum patch sizes: {min_global_patch} / {max_global_patch}\n" + sum_local_patch = sum(is_.getSize() for is_ in ises) + max_global_patch = mpi_comm.allreduce(max_local_patch, op=MPI.MAX) + min_global_patch = mpi_comm.allreduce(min_local_patch, op=MPI.MIN) + sum_global_patch = mpi_comm.allreduce(sum_local_patch, op=MPI.SUM) + avg_global_patch = sum_global_patch / mpi_comm.allreduce(len(ises) if sum_local_patch > 0 else 0, op=MPI.SUM) + msg = f"Minimum / average / maximum patch sizes : {min_global_patch} / {avg_global_patch} / {max_global_patch}\n" self._patch_statistics.append(msg) @abc.abstractmethod diff --git a/tests/firedrake/regression/test_star_pc.py b/tests/firedrake/regression/test_star_pc.py index cd6c05cdc9..eb02c665e8 100644 --- a/tests/firedrake/regression/test_star_pc.py +++ b/tests/firedrake/regression/test_star_pc.py @@ -51,8 +51,8 @@ def test_star_equivalence(problem_type, backend): "mg_levels_ksp_max_it": 1, "mg_levels_pc_type": "python", "mg_levels_pc_python_type": "firedrake.ASMStarPC", - "mg_levels_pc_star_print_patch_statistics": None, - "mg_levels_pc_star_construct_dim": 0} + "mg_levels_pc_star_construct_dim": 0, + "mg_levels_pc_star_view_patch_sizes": None} comp_params = {"mat_type": "aij", "snes_type": "ksponly",