107int main(
int argc,
char** argv) {
108 MPI_Init(&argc, &argv);
109 Kokkos::initialize(argc, argv);
111 MPI_Comm_rank(MPI_COMM_WORLD, &g_rank);
112 MPI_Comm_size(MPI_COMM_WORLD, &size);
115 const C3 grids[] = {{192, 192, 192}, {256, 192, 128}, {2048, 64, 64}};
116 for (
const C3&
G : grids) {
117 const std::vector<C3> ref = singleRankDims(
G);
121 mg.initMpi(
G.x,
G.y,
G.z, 0, MPI_COMM_WORLD);
122 const auto built = builtOnRoot(mg);
123 printPlan(
"built", built);
124 bool dimsOk = built.size() == ref.size();
125 for (std::size_t L = 0; dimsOk && L < ref.size(); ++L)
126 dimsOk =
same(built[L].global, ref[L]);
127 expect(dimsOk,
"T1 %dx%dx%d telescope ON: D %d == single-rank D, every level's global dims",
128 G.x,
G.y,
G.z, (
int)built.size());
129 const auto pred = CutcellMG::predict(
G.x,
G.y,
G.z, size, 0,
true);
130 printPlan(
"predict", pred);
131 expect(planEqual(pred, built),
"T1 %dx%dx%d predict(levels=0, telescope) == built (D %d)",
132 G.x,
G.y,
G.z, (
int)pred.size());
133 const auto p1 = CutcellMG::predict(
G.x,
G.y,
G.z, 1, 0,
true);
134 bool p1Ok = p1.size() == ref.size();
135 for (std::size_t L = 0; p1Ok && L < ref.size(); ++L)
136 p1Ok =
same(p1[L].global, ref[L]);
137 expect(p1Ok,
"T2 %dx%dx%d predict(levels=0, np=1) == single-rank init",
G.x,
G.y,
G.z);
145 const Big bigs[] = {{{512, 512, 256}, 6, {16, 16, 8}}, {{1024, 1024, 512}, 7, {16, 16, 8}}};
146 for (
const Big& b : bigs) {
147 const auto p = CutcellMG::predict(b.G.x, b.G.y, b.G.z, 1, 0,
true);
148 expect((
int)p.size() == b.D &&
same(p.back().global, b.bottom),
149 "T2 %dx%dx%d predict(levels=0): D %d, bottom 16x16x8", b.G.x, b.G.y, b.G.z,
153 for (
const int np : {4, 32}) {
154 const auto q = CutcellMG::predict(b.G.x, b.G.y, b.G.z, np, 0,
true);
155 bool qOk = q.size() == p.size();
156 for (std::size_t L = 0; qOk && L < p.size(); ++L)
157 qOk =
same(q[L].global, p[L].global);
158 expect(qOk,
"T2 %dx%dx%d predict(levels=0, np=%d): every level's global dims == np 1's",
159 b.G.x, b.G.y, b.G.z, np);
164 const C3 G{40, 40, 40};
165 const std::vector<C3> ref = singleRankDims(
G);
169 const auto dec0 = CutcellMG::decomposition((std::size_t)size,
G.x,
G.y,
G.z, 2);
170 mg.initMpi(
G.x,
G.y,
G.z, 0, MPI_COMM_WORLD, &dec0);
171 const auto built = builtOnRoot(mg);
172 printPlan(
"built (telescope OFF)", built);
173 expect(built.size() <= ref.size(),
"T3 40^3 telescope OFF np %d: D %d <= single-rank D %d",
174 size, (
int)built.size(), (
int)ref.size());
176 expect(built.size() < ref.size(),
"T3 40^3 telescope OFF np 8: blocked, D %d < %d",
177 (
int)built.size(), (
int)ref.size());
178 const auto pred = CutcellMG::predict(
G.x,
G.y,
G.z, size, 0,
false, 4, 2);
179 expect(planEqual(pred, built),
"T3 40^3 predict(levels=0, telescope=false) == built (D %d)",
185 std::printf(
"mg_depth_policy_mpi np %d: %s (%d failures)\n", size, g_fail ?
"FAIL" :
"PASS",
187 int f = g_fail, all = 0;
188 MPI_Allreduce(&f, &all, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD);