diff options
author | Erik Schnetter <schnetter@cct.lsu.edu> | 2011-11-17 16:45:43 -0500 |
---|---|---|
committer | Erik Schnetter <schnetter@cct.lsu.edu> | 2011-11-17 16:45:43 -0500 |
commit | 0aa97c853844178e9c89fe623908819da80c9752 (patch) | |
tree | 77c2eb2c8faaf9dbde93685c370c57e2267d0be0 /Carpet/Carpet/src/Recompose.cc | |
parent | b57bdcf470b4ced9725d1ddf4244ad1b525b3028 (diff) |
Carpet: Correct implementation of no_split_direction
Take no_split_direction into account when deciding into how many
slices to cut the domain.
Diffstat (limited to 'Carpet/Carpet/src/Recompose.cc')
-rw-r--r-- | Carpet/Carpet/src/Recompose.cc | 55 |
1 files changed, 30 insertions, 25 deletions
diff --git a/Carpet/Carpet/src/Recompose.cc b/Carpet/Carpet/src/Recompose.cc index a4c157d8c..8dd7e3e3d 100644 --- a/Carpet/Carpet/src/Recompose.cc +++ b/Carpet/Carpet/src/Recompose.cc @@ -1468,39 +1468,44 @@ namespace Carpet { // Choose a direction int mydim = -1; - 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) { - if (not dims[d]) { - ++ alldims; - CCTK_REAL const thiscost = rcost[d]; - if (thiscost >= 0.999999 * mycost) { - mydim = d; - mycost = thiscost; + int nslices = -1; + if (no_split_direction!=-1 and not dims[no_split_direction]) { + 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) { + if (not dims[d]) { + ++ alldims; + CCTK_REAL const thiscost = rcost[d]; + if (thiscost >= 0.999999 * mycost) { + mydim = d; + mycost = thiscost; + } + totalcost *= thiscost; } - totalcost *= thiscost; } + assert (mydim>=0 and mydim<dim); + assert (mycost>=0); + if (recompose_verbose) cout << "SRMAR mydim " << mydim << endl; + if (recompose_verbose) cout << "SRMAR mycost " << mycost << endl; + + // 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)))); + } else { + mydim = no_split_direction; + nslices = 1; } - assert (mydim>=0 and mydim<dim); - assert (mycost>=0); - if (recompose_verbose) cout << "SRMAR mydim " << mydim << endl; - if (recompose_verbose) cout << "SRMAR mycost " << mycost << endl; + assert (nslices <= nprocs); + if (recompose_verbose) cout << "SRMAR " << mydim << " nprocs " << nprocs << endl; + if (recompose_verbose) cout << "SRMAR " << mydim << " nslices " << nslices << endl; // Mark this direction as done assert (not dims[mydim]); bvect const newdims = dims.replace(mydim, true); - // Choose a number of slices for this direction - CCTK_REAL const mycost1 = - mycost * pow(nprocs / totalcost, CCTK_REAL(1) / alldims); - int const nslices1 = min (nprocs, int (floor (mycost1 + CCTK_REAL(0.5)))); - int const nslices = mydim==no_split_direction ? 1 : nslices1; - assert (nslices <= nprocs); - if (recompose_verbose) cout << "SRMAR " << mydim << " nprocs " << nprocs << endl; - if (recompose_verbose) cout << "SRMAR " << mydim << " nslices " << nslices << endl; - // Split the remaining processors vector<int> mynprocs(nslices); int const mynprocs_base = nprocs / nslices; |