43static void printRows(
const char*
tag,
const std::vector<Row>& rows) {
44 for (std::size_t L = 0; L < rows.size(); ++L) {
45 const Row& r = rows[L];
47 " %s L%zu global %3dx%3dx%3d ranks %2d block0 %3dx%3dx%3d ratio(%d,%d,%d)%s\n",
tag,
48 L, r.global.x, r.global.y, r.global.z, r.ranks, r.block.x, r.block.y, r.block.z, r.ratio.x,
50 r.tele ? (r.repartition ?
" -> REPARTITION" :
" -> TELESCOPE") :
"");
83 std::vector<peclet::core::Real> w((std::size_t)g.x * g.y * g.z, 1.0);
84 for (
int z = 0; z < g.z; ++z)
85 for (
int y = 0; y < g.y; ++y)
86 for (
int x = 0; x < g.x; ++x) {
89 v = z < g.z / 2 ? 4.0 : 1.0;
91 const double dx = (x + 0.5) / g.x - 0.3, dy = (y + 0.5) / g.y - 0.6,
92 dz = (z + 0.5) / g.z - 0.35;
93 v = 1.0 + 6.0 * std::exp(-(dx * dx + dy * dy + dz * dz) / 0.02);
95 v = x < 13 ? g.x - 13 : 13;
96 w[(std::size_t)x + (std::size_t)y * g.x + (std::size_t)z * g.x * g.y] = v;
103 Kokkos::initialize(
argc, argv);
104 int fail = 0, size = 1, rank = 0;
109 const Grid3 grids[] = {{32, 32, 32}, {48, 32, 40}};
110 const char* names[] = {
"half-z x4",
"bump",
"uniform",
"odd step x=13"};
112 for (
int kind = 0; kind < 4; ++kind) {
114 std::printf(
"grid %dx%dx%d, weights '%s', np=%d\n", g.x, g.y, g.z, names[kind], size);
116 CutcellMG::decomposition((std::size_t)size, g.x, g.y, g.z);
117 const auto blk =
dec.block((std::size_t)rank);
118 const int lnx = (int)blk.size[0],
lny = (
int)blk.size[1],
lnz = (int)blk.size[2];
130 if (!
compare(
"A default partition", s.pressureMgPlan(),
predA, rank))
134 const auto w =
weights(kind, g);
138 const int alignGot = s.rebalanceByWeights(w);
139 const auto built = s.pressureMgPlan();
140 if (!
compare(
"B after rebalanceByWeights", built,
predB, rank))
143 std::printf(
" alignment: rebalanceByWeights %d, predict %d -> %s\n",
alignGot,
alignPred,
148 bool tele =
false,
rep =
false;
149 for (
const Row& r : built) {
151 rep =
rep || r.repartition;
161 std::printf(
"coverage: %d weighted case(s) telescope, %d repartition, %d align > 1\n",
164 std::printf(
"FAIL: the cases no longer exercise what this test gates\n");
170 std::printf(
"%s\n",
fail ?
"FAIL" :
"PASS");