aboutsummaryrefslogtreecommitdiff
path: root/Carpet/Carpet/src/Recompose.cc
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2013-01-19 21:35:28 -0500
committerErik Schnetter <schnetter@gmail.com>2013-01-19 21:54:38 -0500
commit1258f552730890f0a06030ce037d763e7368a469 (patch)
treeefdd85ce9841bab94ede76cbd067d92e14cdfc04 /Carpet/Carpet/src/Recompose.cc
parent63308ace65a81b3501019a5d67ef7414485f5af2 (diff)
Carpet: Correct load-balancing algorithm to really prefer splitting in the z direction
Diffstat (limited to 'Carpet/Carpet/src/Recompose.cc')
-rw-r--r--Carpet/Carpet/src/Recompose.cc10
1 files changed, 7 insertions, 3 deletions
diff --git a/Carpet/Carpet/src/Recompose.cc b/Carpet/Carpet/src/Recompose.cc
index 642f335f7..fa4db13cf 100644
--- a/Carpet/Carpet/src/Recompose.cc
+++ b/Carpet/Carpet/src/Recompose.cc
@@ -1452,11 +1452,13 @@ namespace Carpet {
int alldims = 0;
CCTK_REAL mycost = 0;
CCTK_REAL totalcost = 1;
- // Prefer to split in the z direction
- for (int d=dim-1; d>=0; --d) {
+ for (int d=0; d<dim; ++d) {
if (not dims[d]) {
++ alldims;
CCTK_REAL const thiscost = rcost[d];
+ // Prefer to split in the z direction
+ // (Choose this dimension even if it is slightly worse than
+ // a previous dimension)
if (thiscost >= 0.999999 * mycost) {
mydim = d;
mycost = thiscost;
@@ -1472,7 +1474,9 @@ namespace Carpet {
// Choose a number of slices for this direction
CCTK_REAL const mycost1 =
mycost * pow(nprocs / totalcost, CCTK_REAL(1) / alldims);
- nslices = min (nprocs, int (floor (mycost1 + CCTK_REAL(0.5))));
+ // Round up, so that we use more slices in this direction than
+ // in the left-over directions
+ nslices = min (nprocs, int (lrint (ceil (mycost1))));
}
assert (nslices <= nprocs);
if (recompose_verbose) cout << "SRMAR " << mydim << " nprocs " << nprocs << endl;