From 9aedf86a2fa1e24d1eff55e1e5ee344daf7c84da Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Mon, 7 Mar 2005 16:58:00 +0000 Subject: Carpet: Add new flag Carpet::constant_load_per_processor Add a new flag Carpet::constant_load_per_processor which takes the specified grid size and multiplies it by the number of processors. When running benchmarks, this keeps the local load constant. darcs-hash:20050307165844-891bb-7b4c36a5e3bb152086d2eb240a898cb2ac5a3122.gz --- Carpet/Carpet/param.ccl | 4 ++++ Carpet/Carpet/src/SetupGH.cc | 44 ++++++++++++++++++++++++++++++++++++++------ 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/Carpet/Carpet/param.ccl b/Carpet/Carpet/param.ccl index ae7012b22..ee6304d0a 100644 --- a/Carpet/Carpet/param.ccl +++ b/Carpet/Carpet/param.ccl @@ -274,6 +274,10 @@ CCTK_INT split_direction "Direction in which the domain should be split" STEERAB 0:* :: "0 for x, 1 for y, 2 for z, etc." } 2 +BOOLEAN constant_load_per_processor "Keep the load per processor constant -- this is meant for benchmarks" +{ +} "no" + STRING grid_structure_filename "File name to output grid structure to (empty = no output)" STEERABLE=recover diff --git a/Carpet/Carpet/src/SetupGH.cc b/Carpet/Carpet/src/SetupGH.cc index de72abfb9..a2c227056 100644 --- a/Carpet/Carpet/src/SetupGH.cc +++ b/Carpet/Carpet/src/SetupGH.cc @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "cctk.h" @@ -305,7 +306,8 @@ namespace Carpet { CCTK_INT ghost_size_x, CCTK_INT ghost_size_y, CCTK_INT ghost_size_z); static ivect make_global_number_of_grid_points (CCTK_INT global_nsize, - CCTK_INT global_nx, CCTK_INT global_ny, CCTK_INT global_nz); + CCTK_INT global_nx, CCTK_INT global_ny, CCTK_INT global_nz, + CCTK_INT constant_load_per_processor); static void check_time_hierarchy (const vector &vdd, int m, CCTK_INT max_refinement_levels, CCTK_INT refinement_factor, @@ -388,7 +390,8 @@ namespace Carpet { ghost_size_x, ghost_size_y, ghost_size_z); ivect ughosts = lghosts; ivect npoints = make_global_number_of_grid_points (global_nsize, - global_nx, global_ny, global_nz); + global_nx, global_ny, global_nz, + constant_load_per_processor); allocate_map (cgh, m, domain_from_coordbase, convergence_factor, refinement_factor, @@ -623,13 +626,42 @@ namespace Carpet { } - ivect make_global_number_of_grid_points (CCTK_INT global_nsize, - CCTK_INT global_nx, CCTK_INT global_ny, CCTK_INT global_nz) { + ivect + make_global_number_of_grid_points (CCTK_INT const global_nsize, + CCTK_INT const global_nx, + CCTK_INT const global_ny, + CCTK_INT const global_nz, + CCTK_INT const constant_load_per_processor) + { + ivect npoints; if (global_nsize == -1) { - return ivect (global_nx, global_ny, global_nz); + npoints = ivect (global_nx, global_ny, global_nz); } else { - return ivect (global_nsize, global_nsize, global_nsize); + npoints = ivect (global_nsize, global_nsize, global_nsize); + } + if (constant_load_per_processor) { + // Enlarge the domain so that each processor has the specified + // number of grid points + int const nprocs = dist::size(); + // Factorise the number of processors + stack factors; + for (int procsleft = nprocs; procsleft > 1;) { + for (int divisor = 2; divisor <= procsleft; ++divisor) { + if (procsleft % divisor == 0) { + factors.push (divisor); + procsleft /= divisor; + } + } + } + // Distribute the factors greedily onto the directions + while (! factors.empty()) { + int const mindir = minloc (npoints); + int const factor = factors.top(); + factors.pop(); + npoints[mindir] *= factor; + } } + return npoints; } ivect make_ghost_zone_vect (CCTK_INT ghost_size, -- cgit v1.2.3