flow 1.4.0
Kokkos cut-cell IBM incompressible Navier-Stokes solver + pnm pore extraction
Loading...
Searching...
No Matches
test_decomposition_policy.cpp
Go to the documentation of this file.
1
32#include <algorithm>
33#include <cstdint>
34#include <cstdio>
35#include <map>
36#include <set>
37#include <string>
38#include <vector>
39
40#include "mac_cutcell_mg.hpp"
41
43using Dec = peclet::core::decomp::BlockDecomposer<3>;
44using peclet::core::Index;
45using peclet::core::IVec;
46
47namespace {
48
49int fails = 0;
50#define CHECK(cond, ...) \
51 do { \
52 if (!(cond)) { \
53 std::printf("FAIL "); \
54 std::printf(__VA_ARGS__); \
55 std::printf("\n"); \
56 ++fails; \
57 } \
58 } while (0)
59
60Index cells(const IVec<3>& s) {
61 return s[0] * s[1] * s[2];
62}
63Index maxCells(const Dec& d) {
64 Index m = 0;
65 for (const auto& s : d.sizes())
66 m = std::max(m, cells(s));
67 return m;
68}
69Index minCells(const Dec& d) {
70 Index m = cells(d.sizes()[0]);
71 for (const auto& s : d.sizes())
72 m = std::min(m, cells(s));
73 return m;
74}
75bool same(const Dec& a, const Dec& b) {
76 if (a.numBlocks() != b.numBlocks() || a.origins() != b.origins() || a.sizes() != b.sizes())
77 return false;
78 std::vector<int> da, db;
79 std::vector<Index> va, vb;
80 a.flattenTree(da, va);
81 b.flattenTree(db, vb);
82 return da == db && va == vb;
83}
84// in-place halvings by block evenness alone (no minimum extent), up to 8: the design's "halvings"
85int evenHalvings(const Dec& d0) {
86 auto can = [](Index e) { return e % 2 == 0 && e / 2 >= 2; };
87 Dec d = d0;
88 int n = 0;
89 for (; n < 8; ++n) {
90 IVec<3> r{1, 1, 1};
91 for (int k = 0; k < 3; ++k)
92 if (can(d.globalSize()[k]))
93 r[k] = 2;
94 if (r == IVec<3>{1, 1, 1})
95 break;
96 bool even = true;
97 for (std::size_t b = 0; b < d.numBlocks(); ++b)
98 for (int k = 0; k < 3; ++k)
99 if (r[k] == 2 && (d.origins()[b][k] % 2 || d.sizes()[b][k] % 2))
100 even = false;
101 if (!even)
102 break;
103 d = d.coarsened(r);
104 }
105 return n;
106}
107// The balance-aware aligned ORB the auto policy's A2 branch builds (mac_cutcell_mg.hpp).
108Dec alignedBalanced(std::size_t np, const IVec<3>& G) {
109 Dec d;
110 d.init(np, G, CutcellMG::coarsenAlignment((int)G[0], (int)G[1], (int)G[2]), IVec<3>{1, 1, 1},
111 peclet::core::decomp::SplitAxis::Balanced);
112 return d;
113}
114// The auto policy WITHOUT the WO-D guard (§13.4(2)): CutcellMG::decomposition(levels 0) as it was
115// at flow dfd62c4, recomputed from the public pieces, so the census can name what the guard
116// reverts.
117Dec unguardedAuto(std::size_t np, const IVec<3>& G) {
118 namespace cdec = peclet::core::decomp;
119 const int gx = (int)G[0], gy = (int)G[1], gz = (int)G[2];
120 const Dec L = CutcellMG::decomposition(np, gx, gy, gz, 1);
121 if (maxCells(L) == minCells(L))
122 return L;
123 const unsigned axL = CutcellMG::splitAxes(L);
124 auto within = [&](const Dec& d) { return (CutcellMG::splitAxes(d) & ~axL) == 0u; };
125 const int dL = CutcellMG::nestDepth(L);
126 const IVec<3> one{1, 1, 1};
127 for (int lv : {5, 4}) {
128 const IVec<3> r = CutcellMG::refineFactor(gx, gy, gz, lv);
129 if (r == one)
130 break;
131 const IVec<3> Gc{G[0] / r[0], G[1] / r[1], G[2] / r[2]};
132 if (cells(Gc) < (Index)np)
133 continue;
134 Dec coarse;
135 coarse.init(np, Gc, one, r, cdec::SplitAxis::Balanced);
136 const Dec C = coarse.refined(r);
137 if (minCells(C) > 0 && (double)maxCells(C) / (double)minCells(C) <= 1.05 && within(C) &&
138 CutcellMG::nestDepth(C) >= dL)
139 return C;
140 }
141 const Dec A2 = alignedBalanced(np, G);
142 if (maxCells(A2) < maxCells(L) && CutcellMG::nestDepth(A2) >= std::min(dL, 3) && within(A2))
143 return A2;
144 return L;
145}
146int nReverted = 0;
147std::vector<std::string> reverted; // names of the configurations the guard reverted
148std::string shapeStr(const Dec& d);
149// (7) WO-D: the guard clause, and a reverted configuration (auto != the unguarded policy) is legacy
150void checkGuard(const Dec& A, const Dec& L, std::size_t np, const IVec<3>& G, const char* name) {
151 const unsigned aA = CutcellMG::splitAxes(A), aL = CutcellMG::splitAxes(L);
152 CHECK(aA == aL || 4 * maxCells(L) * (Index)np >= 5 * cells(G),
153 "%s: (7) auto changes legacy's split axes (auto %u legacy %u) at legacy max/mean < 5/4",
154 name, aA, aL);
155 const Dec U = unguardedAuto(np, G);
156 if (same(U, A))
157 return;
158 ++nReverted;
159 reverted.emplace_back(name);
160 CHECK(same(A, L), "%s: (7) the guard reverted the unguarded choice, but not to legacy", name);
161 std::printf("REVERTED %s: unguarded max/min %.3f axes %u [%s] -> legacy max/mean %.3f axes %u\n",
162 name, (double)maxCells(U) / (double)minCells(U), CutcellMG::splitAxes(U),
163 shapeStr(U).c_str(), (double)(maxCells(L) * (Index)np) / (double)cells(G), aL);
164}
165// auto took a coarse-first candidate (C5/C4): it is neither legacy nor A2
166bool tookCoarseFirst(const Dec& A, const Dec& L, std::size_t np, const IVec<3>& G) {
167 return !same(A, L) && !same(A, alignedBalanced(np, G));
168}
169// In-place coarsenings before the first telescope stage, as CutcellMG::predict forecasts them
170// (initMpi's trigger at min extent 4), capped at 4 as nestDepth is.
171int predictedNestDepth(const IVec<3>& G, std::size_t np, int decompLevels) {
172 const auto rows =
173 CutcellMG::predict((int)G[0], (int)G[1], (int)G[2], (int)np, 8, true, 4, decompLevels);
174 int n = 0;
175 for (const auto& r : rows) {
176 if (r.tele || (r.ratio.x == 1 && r.ratio.y == 1 && r.ratio.z == 1))
177 break;
178 ++n;
179 }
180 return std::min(n, 4);
181}
182// block shape -> count
183std::map<std::array<Index, 3>, int> shapes(const Dec& d) {
184 std::map<std::array<Index, 3>, int> m;
185 for (const auto& s : d.sizes())
186 ++m[{s[0], s[1], s[2]}];
187 return m;
188}
189std::string shapeStr(const Dec& d) {
190 std::string out;
191 char buf[64];
192 for (const auto& [s, n] : shapes(d)) {
193 std::snprintf(buf, sizeof buf, "%s%dx %lldx%lldx%lld", out.empty() ? "" : " + ", n,
194 (long long)s[0], (long long)s[1], (long long)s[2]);
195 out += buf;
196 }
197 return out;
198}
199
200} // namespace
201
202int main() {
203 const std::vector<IVec<3>> grids = {
204 // the design's census set
205 {128, 96, 64},
206 {48, 48, 48},
207 {64, 64, 64},
208 {96, 96, 96},
209 {128, 128, 128},
210 {192, 192, 192},
211 {256, 128, 128},
212 {384, 288, 192},
213 {40, 40, 40},
214 {100, 50, 50},
215 // the grids flow's (tests/kokkos_mpi, tests/regression) and coupling's MPI tests decompose
216 {8, 8, 40},
217 {16, 8, 32},
218 {16, 16, 16},
219 {16, 16, 32},
220 {16, 32, 8},
221 {24, 24, 48},
222 {32, 32, 32},
223 {32, 64, 16},
224 {36, 36, 36},
225 {48, 32, 32},
226 {48, 32, 40},
227 {48, 40, 30},
228 {64, 4, 4},
229 {64, 48, 32},
230 // limiting: no factors of two
231 {30, 30, 30}};
232 const std::vector<std::size_t> nps = {1, 2, 3, 4, 5, 6, 7, 8, 12, 16, 24, 32, 48, 96};
233 int nConf = 0, nChanged = 0, nCoarseFirst = 0;
234 for (const auto& G : grids) {
235 std::vector<std::size_t> list = nps;
236 if (G == IVec<3>{128, 96, 64})
237 list.push_back(192);
238 for (std::size_t np : list) {
239 if ((Index)np > cells(G))
240 continue;
241 ++nConf;
242 const Dec L = CutcellMG::decomposition(np, (int)G[0], (int)G[1], (int)G[2], 1);
243 const Dec A = CutcellMG::decomposition(np, (int)G[0], (int)G[1], (int)G[2]);
244 const Dec A2 = CutcellMG::decomposition(np, (int)G[0], (int)G[1], (int)G[2], 0, 1.05);
245 const bool exL = maxCells(L) == minCells(L);
246 const int dL = CutcellMG::nestDepth(L), dA = CutcellMG::nestDepth(A);
247 char name[64];
248 std::snprintf(name, sizeof name, "%lldx%lldx%lld np %zu", (long long)G[0], (long long)G[1],
249 (long long)G[2], np);
250 CHECK(!exL || same(A, L), "%s: (1) legacy exact but auto differs", name);
251 CHECK(maxCells(A) <= maxCells(L), "%s: (2) maxCells auto %lld > legacy %lld", name,
252 (long long)maxCells(A), (long long)maxCells(L));
253 CHECK(dA >= std::min(dL, 3), "%s: (3) nestDepth auto %d < min(legacy %d, 3)", name, dA, dL);
254 const bool isC = tookCoarseFirst(A, L, np, G);
255 nCoarseFirst += isC ? 1 : 0;
256 CHECK(!isC || dA >= dL, "%s: (3) coarse-first auto nests %d < legacy %d", name, dA, dL);
257 if (np > 1) {
258 const int pA = predictedNestDepth(G, np, 0), pL = predictedNestDepth(G, np, 1);
259 CHECK(dA == pA && dL == pL,
260 "%s: (10) nestDepth auto %d legacy %d != predict's in-place depth auto %d legacy %d",
261 name, dA, dL, pA, pL);
262 }
263 CHECK(same(A, A2), "%s: (6) two calls differ", name);
264 CHECK((CutcellMG::splitAxes(A) & ~CutcellMG::splitAxes(L)) == 0u,
265 "%s: (7) auto cuts an axis legacy leaves whole (auto %u legacy %u)", name,
266 CutcellMG::splitAxes(A), CutcellMG::splitAxes(L));
267 checkGuard(A, L, np, G, name);
268 Index tot = 0;
269 for (const auto& s : A.sizes())
270 tot += cells(s);
271 CHECK(A.numBlocks() == np && tot == cells(G), "%s: auto does not tile", name);
272 if (!same(A, L)) {
273 ++nChanged;
274 std::printf(
275 "CHANGED %s: legacy max/min %.3f depth %d [%s] -> auto max/min %.3f depth %d "
276 "[%s]\n",
277 name, (double)maxCells(L) / (double)minCells(L), dL, shapeStr(L).c_str(),
278 (double)maxCells(A) / (double)minCells(A), dA, shapeStr(A).c_str());
279 }
280 }
281 }
282 std::printf("census: %d configurations, %d changed, %d coarse-first\n", nConf, nChanged,
283 nCoarseFirst);
284 // (7) the §13.4(2) replica set beyond the census: the design grids at np 9, 10, 15, 20
285 for (std::size_t g = 0; g < 10; ++g)
286 for (std::size_t np : {9, 10, 15, 20}) {
287 const IVec<3>& G = grids[g];
288 char name[64];
289 std::snprintf(name, sizeof name, "%lldx%lldx%lld np %zu", (long long)G[0], (long long)G[1],
290 (long long)G[2], np);
291 checkGuard(CutcellMG::decomposition(np, (int)G[0], (int)G[1], (int)G[2]),
292 CutcellMG::decomposition(np, (int)G[0], (int)G[1], (int)G[2], 1), np, G, name);
293 }
294
295 // (4), (5), §9 shapes and the np = 192 limiting case
296 for (std::size_t np : {3, 12, 24, 32, 96, 192}) {
297 const Dec A = CutcellMG::decomposition(np, 128, 96, 64);
298 if (np == 12) // the WO-D guard reverts np 12 to legacy (§13.4(2))
299 CHECK(same(A, CutcellMG::decomposition(np, 128, 96, 64, 1)), "128x96x64 np 12: not legacy");
300 else
301 CHECK(maxCells(A) == minCells(A), "128x96x64 np %zu: (4) not exact (%s)", np,
302 shapeStr(A).c_str());
303 CHECK(evenHalvings(A) >= 4, "128x96x64 np %zu: %d in-place halvings < 4", np, evenHalvings(A));
304 }
305 {
306 const Dec A = CutcellMG::decomposition(4, 48, 48, 48);
307 CHECK(maxCells(A) == minCells(A), "48^3 np 4: (5) not exact (%s)", shapeStr(A).c_str());
308 }
309 // (7) WO-D keeps these on auto: legacy max/mean >= 5/4, so the guard lets them change split axes
310 for (std::size_t np : {3, 5, 7})
311 CHECK(!same(CutcellMG::decomposition(np, 48, 48, 48),
312 CutcellMG::decomposition(np, 48, 48, 48, 1)),
313 "48^3 np %zu: (7) the guard reverted it to legacy (legacy max/mean >= 5/4)", np);
314 using S = std::map<std::array<Index, 3>, int>;
315 const std::pair<std::size_t, S> table[] = {
316 {3, S{{{128, 32, 64}, 1}, {{64, 64, 64}, 2}}},
317 {12, S{{{16, 48, 64}, 4}, {{48, 48, 32}, 8}}}, // legacy's (§13.3(a)): the guard reverts it
318 {24, S{{{32, 16, 64}, 8}, {{32, 32, 32}, 16}}},
319 {192, S{{{16, 16, 16}, 192}}},
320 };
321 for (const auto& [np, want] : table) {
322 const Dec A = CutcellMG::decomposition(np, 128, 96, 64);
323 std::printf("128x96x64 np %zu: auto %s\n", np, shapeStr(A).c_str());
324 const S got = shapes(A);
325 CHECK(got == want, "128x96x64 np %zu: block shapes differ from the design's §9 table", np);
326 }
327 // (8) channel-shaped grids: a legacy partition that keeps y whole keeps it whole
328 for (const auto& G : {IVec<3>{768, 128, 256}, IVec<3>{480, 80, 160}})
329 for (std::size_t np = 2; np <= 32; ++np) {
330 const Dec L = CutcellMG::decomposition(np, (int)G[0], (int)G[1], (int)G[2], 1);
331 const Dec A = CutcellMG::decomposition(np, (int)G[0], (int)G[1], (int)G[2]);
332 const bool yWholeL = (CutcellMG::splitAxes(L) & 2u) == 0u;
333 char name[64];
334 std::snprintf(name, sizeof name, "%lldx%lldx%lld np %zu (channel)", (long long)G[0],
335 (long long)G[1], (long long)G[2], np);
336 checkGuard(A, L, np, G, name);
337 CHECK(!yWholeL || (CutcellMG::splitAxes(A) & 2u) == 0u,
338 "%lldx%lldx%lld np %zu: (8) auto splits y, legacy does not", (long long)G[0],
339 (long long)G[1], (long long)G[2], np);
340 CHECK(maxCells(A) <= maxCells(L), "%lldx%lldx%lld np %zu: (2) maxCells", (long long)G[0],
341 (long long)G[1], (long long)G[2], np);
342 CHECK(CutcellMG::nestDepth(A) >= std::min(CutcellMG::nestDepth(L), 3),
343 "%lldx%lldx%lld np %zu: (3) nestDepth auto %d legacy %d", (long long)G[0],
344 (long long)G[1], (long long)G[2], np, CutcellMG::nestDepth(A), CutcellMG::nestDepth(L));
345 CHECK(!tookCoarseFirst(A, L, np, G) || CutcellMG::nestDepth(A) >= CutcellMG::nestDepth(L),
346 "%lldx%lldx%lld np %zu: (3) coarse-first auto nests %d < legacy %d", (long long)G[0],
347 (long long)G[1], (long long)G[2], np, CutcellMG::nestDepth(A), CutcellMG::nestDepth(L));
348 CHECK(CutcellMG::nestDepth(A) == predictedNestDepth(G, np, 0) &&
349 CutcellMG::nestDepth(L) == predictedNestDepth(G, np, 1),
350 "%lldx%lldx%lld np %zu: (10) nestDepth != predict's in-place depth", (long long)G[0],
351 (long long)G[1], (long long)G[2], np);
352 if (!same(A, L))
353 std::printf(
354 "CHANGED %lldx%lldx%lld np %zu (channel): legacy max/min %.3f depth %d -> auto "
355 "max/min %.3f depth %d\n",
356 (long long)G[0], (long long)G[1], (long long)G[2], np,
357 (double)maxCells(L) / (double)minCells(L), CutcellMG::nestDepth(L),
358 (double)maxCells(A) / (double)minCells(A), CutcellMG::nestDepth(A));
359 }
360 // (9) levels >= 2: the legacy coarse-first search (SplitAxis::Longest), bit for bit. The values
361 // are CutcellMG::fingerprint of CutcellMG::decomposition(np, G, L) built against core fcb3b06 +
362 // flow 91964b7 (the pre-partition trees).
363 struct Golden {
364 IVec<3> g;
365 std::size_t np;
366 int levels;
367 std::uint64_t fp;
368 };
369 const Golden golden[] = {
370 {{384, 384, 384}, 24, 2, 0xc76cada7a9cf6f6full},
371 {{384, 384, 384}, 24, 3, 0xc76cada7a9cf6f6full},
372 {{384, 384, 384}, 24, 4, 0xc76cada7a9cf6f6full},
373 {{384, 384, 384}, 24, 5, 0xc76cada7a9cf6f6full},
374 {{384, 384, 384}, 24, 6, 0xc76cada7a9cf6f6full},
375 {{384, 384, 384}, 24, 7, 0xc76cada7a9cf6f6full},
376 {{384, 384, 384}, 48, 2, 0x56973b1c6f4aa7b7ull},
377 {{384, 384, 384}, 48, 3, 0x56973b1c6f4aa7b7ull},
378 {{384, 384, 384}, 48, 4, 0x56973b1c6f4aa7b7ull},
379 {{384, 384, 384}, 48, 5, 0x56973b1c6f4aa7b7ull},
380 {{384, 384, 384}, 48, 6, 0x56973b1c6f4aa7b7ull},
381 {{384, 384, 384}, 48, 7, 0x56973b1c6f4aa7b7ull},
382 {{384, 384, 384}, 96, 2, 0x8c951d34c8581337ull},
383 {{384, 384, 384}, 96, 3, 0x8c951d34c8581337ull},
384 {{384, 384, 384}, 96, 4, 0x8c951d34c8581337ull},
385 {{384, 384, 384}, 96, 5, 0x8c951d34c8581337ull},
386 {{384, 384, 384}, 96, 6, 0x8c951d34c8581337ull},
387 {{384, 384, 384}, 96, 7, 0x8c951d34c8581337ull},
388 {{384, 384, 384}, 192, 2, 0xe4e414c09bbcdb6cull},
389 {{384, 384, 384}, 192, 3, 0xe4e414c09bbcdb6cull},
390 {{384, 384, 384}, 192, 4, 0xe4e414c09bbcdb6cull},
391 {{384, 384, 384}, 192, 5, 0xe4e414c09bbcdb6cull},
392 {{384, 384, 384}, 192, 6, 0xe4e414c09bbcdb6cull},
393 {{384, 384, 384}, 192, 7, 0xe4e414c09bbcdb6cull},
394 {{384, 384, 384}, 384, 2, 0x0db64c506de5f5c9ull},
395 {{384, 384, 384}, 384, 3, 0x0db64c506de5f5c9ull},
396 {{384, 384, 384}, 384, 4, 0x0db64c506de5f5c9ull},
397 {{384, 384, 384}, 384, 5, 0x0db64c506de5f5c9ull},
398 {{384, 384, 384}, 384, 6, 0x0db64c506de5f5c9ull},
399 {{384, 384, 384}, 384, 7, 0x0db64c506de5f5c9ull},
400 {{384, 384, 384}, 768, 2, 0x2cba956cc53f6297ull},
401 {{384, 384, 384}, 768, 3, 0x2cba956cc53f6297ull},
402 {{384, 384, 384}, 768, 4, 0x2cba956cc53f6297ull},
403 {{384, 384, 384}, 768, 5, 0x2cba956cc53f6297ull},
404 {{384, 384, 384}, 768, 6, 0x2cba956cc53f6297ull},
405 {{384, 384, 384}, 768, 7, 0x2cba956cc53f6297ull},
406 {{384, 384, 384}, 1536, 2, 0x6b2c44fefb80e50cull},
407 {{384, 384, 384}, 1536, 3, 0x6b2c44fefb80e50cull},
408 {{384, 384, 384}, 1536, 4, 0x6b2c44fefb80e50cull},
409 {{384, 384, 384}, 1536, 5, 0x6b2c44fefb80e50cull},
410 {{384, 384, 384}, 1536, 6, 0x6b2c44fefb80e50cull},
411 {{384, 384, 384}, 1536, 7, 0x6b2c44fefb80e50cull},
412 {{400, 400, 400}, 48, 2, 0x54b7dda96e2dd65full},
413 {{400, 400, 400}, 48, 3, 0xf56231788a323f4full},
414 {{400, 400, 400}, 48, 4, 0xf56231788a323f4full},
415 {{400, 400, 400}, 48, 5, 0xf56231788a323f4full},
416 {{400, 400, 400}, 48, 6, 0xf56231788a323f4full},
417 {{400, 400, 400}, 48, 7, 0xf56231788a323f4full},
418 {{400, 400, 400}, 96, 2, 0x352e55a97a9a28efull},
419 {{400, 400, 400}, 96, 3, 0x352e55a97a9a28efull},
420 {{400, 400, 400}, 96, 4, 0x352e55a97a9a28efull},
421 {{400, 400, 400}, 96, 5, 0x352e55a97a9a28efull},
422 {{400, 400, 400}, 96, 6, 0x352e55a97a9a28efull},
423 {{400, 400, 400}, 96, 7, 0x352e55a97a9a28efull},
424 {{400, 400, 400}, 192, 2, 0x0965e39854d7dcb4ull},
425 {{400, 400, 400}, 192, 3, 0x0965e39854d7dcb4ull},
426 {{400, 400, 400}, 192, 4, 0x0965e39854d7dcb4ull},
427 {{400, 400, 400}, 192, 5, 0x0965e39854d7dcb4ull},
428 {{400, 400, 400}, 192, 6, 0x0965e39854d7dcb4ull},
429 {{400, 400, 400}, 192, 7, 0x0965e39854d7dcb4ull},
430 {{400, 400, 400}, 384, 2, 0x27a98983bbceb84dull},
431 {{400, 400, 400}, 384, 3, 0x27a98983bbceb84dull},
432 {{400, 400, 400}, 384, 4, 0x27a98983bbceb84dull},
433 {{400, 400, 400}, 384, 5, 0x27a98983bbceb84dull},
434 {{400, 400, 400}, 384, 6, 0x27a98983bbceb84dull},
435 {{400, 400, 400}, 384, 7, 0x27a98983bbceb84dull},
436 {{377, 240, 503}, 1, 2, 0xe42b457e073921dbull},
437 {{377, 240, 503}, 1, 3, 0xe42b457e073921dbull},
438 {{377, 240, 503}, 1, 4, 0xe42b457e073921dbull},
439 {{377, 240, 503}, 1, 5, 0xe42b457e073921dbull},
440 {{377, 240, 503}, 1, 6, 0xe42b457e073921dbull},
441 {{377, 240, 503}, 1, 7, 0xe42b457e073921dbull},
442 {{754, 240, 503}, 2, 2, 0xe51d0609f3f2fa21ull},
443 {{754, 240, 503}, 2, 3, 0xe51d0609f3f2fa21ull},
444 {{754, 240, 503}, 2, 4, 0xe51d0609f3f2fa21ull},
445 {{754, 240, 503}, 2, 5, 0xe51d0609f3f2fa21ull},
446 {{754, 240, 503}, 2, 6, 0xe51d0609f3f2fa21ull},
447 {{754, 240, 503}, 2, 7, 0xe51d0609f3f2fa21ull},
448 {{1508, 240, 503}, 4, 2, 0xdb90dd30d00501d3ull},
449 {{1508, 240, 503}, 4, 3, 0x6483cea14f6e9f6full},
450 {{1508, 240, 503}, 4, 4, 0x6483cea14f6e9f6full},
451 {{1508, 240, 503}, 4, 5, 0x6483cea14f6e9f6full},
452 {{1508, 240, 503}, 4, 6, 0x6483cea14f6e9f6full},
453 {{1508, 240, 503}, 4, 7, 0x6483cea14f6e9f6full},
454 {{3016, 240, 503}, 8, 2, 0xbb2164ae7892e7f9ull},
455 {{3016, 240, 503}, 8, 3, 0x4c4a3e149bcd28fdull},
456 {{3016, 240, 503}, 8, 4, 0xcfadf268c155a0bdull},
457 {{3016, 240, 503}, 8, 5, 0xcfadf268c155a0bdull},
458 {{3016, 240, 503}, 8, 6, 0xcfadf268c155a0bdull},
459 {{3016, 240, 503}, 8, 7, 0xcfadf268c155a0bdull},
460 {{384, 128, 128}, 2, 2, 0x95d56daae4b3edf8ull},
461 {{384, 128, 128}, 2, 3, 0x95d56daae4b3edf8ull},
462 {{384, 128, 128}, 2, 4, 0x95d56daae4b3edf8ull},
463 {{384, 128, 128}, 2, 5, 0x95d56daae4b3edf8ull},
464 {{384, 128, 128}, 2, 6, 0x95d56daae4b3edf8ull},
465 {{384, 128, 128}, 2, 7, 0x95d56daae4b3edf8ull},
466 {{384, 128, 128}, 4, 2, 0x796d44fff0fc7cbbull},
467 {{384, 128, 128}, 4, 3, 0x796d44fff0fc7cbbull},
468 {{384, 128, 128}, 4, 4, 0x796d44fff0fc7cbbull},
469 {{384, 128, 128}, 4, 5, 0x796d44fff0fc7cbbull},
470 {{384, 128, 128}, 4, 6, 0x796d44fff0fc7cbbull},
471 {{384, 128, 128}, 4, 7, 0x796d44fff0fc7cbbull},
472 {{384, 128, 128}, 8, 2, 0xd76f88eae7c4e594ull},
473 {{384, 128, 128}, 8, 3, 0xd76f88eae7c4e594ull},
474 {{384, 128, 128}, 8, 4, 0xd76f88eae7c4e594ull},
475 {{384, 128, 128}, 8, 5, 0xd76f88eae7c4e594ull},
476 {{384, 128, 128}, 8, 6, 0xd76f88eae7c4e594ull},
477 {{384, 128, 128}, 8, 7, 0xd76f88eae7c4e594ull},
478 {{384, 128, 128}, 16, 2, 0x6cd590d87514e30cull},
479 {{384, 128, 128}, 16, 3, 0x6cd590d87514e30cull},
480 {{384, 128, 128}, 16, 4, 0x6cd590d87514e30cull},
481 {{384, 128, 128}, 16, 5, 0x6cd590d87514e30cull},
482 {{384, 128, 128}, 16, 6, 0x6cd590d87514e30cull},
483 {{384, 128, 128}, 16, 7, 0x6cd590d87514e30cull},
484 {{480, 80, 160}, 16, 2, 0x689bdd6c028b5f1cull},
485 {{480, 80, 160}, 16, 3, 0x689bdd6c028b5f1cull},
486 {{480, 80, 160}, 16, 4, 0x689bdd6c028b5f1cull},
487 {{480, 80, 160}, 16, 5, 0x689bdd6c028b5f1cull},
488 {{480, 80, 160}, 16, 6, 0x689bdd6c028b5f1cull},
489 {{480, 80, 160}, 16, 7, 0x689bdd6c028b5f1cull},
490 };
491 int nGolden = 0;
492 for (const auto& r : golden) {
493 const Dec d = CutcellMG::decomposition(r.np, (int)r.g[0], (int)r.g[1], (int)r.g[2], r.levels);
494 ++nGolden;
495 CHECK(CutcellMG::fingerprint(d) == r.fp,
496 "%lldx%lldx%lld np %zu levels %d: (9) partition differs from the pre-partition one "
497 "(fingerprint %016llx, recorded %016llx)",
498 (long long)r.g[0], (long long)r.g[1], (long long)r.g[2], r.np, r.levels,
499 (unsigned long long)CutcellMG::fingerprint(d), (unsigned long long)r.fp);
500 }
501 std::printf(
502 "levels >= 2: %d (published configuration, levels) rows checked against the pre-partition "
503 "trees\n",
504 nGolden);
505 std::printf("guard (WO-D): %d configurations reverted to legacy\n", nReverted);
506 // (7) the reverted set, exactly (§13.4(2)): guard.py's four, ten small test grids and the one
507 // channel configuration. A guard that is too strict also reverts to legacy, so only the list
508 // catches it.
509 const std::vector<std::string> wantReverted = {
510 "100x50x50 np 10", "100x50x50 np 5", "128x96x64 np 12", "30x30x30 np 3",
511 "30x30x30 np 5", "30x30x30 np 6", "30x30x30 np 7", "36x36x36 np 3",
512 "36x36x36 np 5", "36x36x36 np 6", "384x288x192 np 9", "480x80x160 np 30 (channel)",
513 "48x32x40 np 3", "48x40x30 np 3"};
514 CHECK(nReverted == 14, "(7) the guard reverted %d configurations, want 14", nReverted);
515 std::sort(reverted.begin(), reverted.end());
516 CHECK(reverted == wantReverted, "(7) the reverted set differs from the 14 of §13.4(2)");
517 std::printf(fails ? "decomposition_policy: FAIL (%d)\n" : "decomposition_policy: PASS\n", fails);
518 return fails ? 1 : 0;
519}
flow — portable (Kokkos) geometric multigrid for the cut-cell (variable-openness) pressure Poisson.
int m
Definition post.py:35
one(n, rho_ratio, mu_ratio, stress, steps, adv, dtf, grav=False, sigma="none")
dict rows
Definition summarize.py:38
static constexpr int G
#define CHECK(cond,...)
peclet::core::decomp::BlockDecomposer< 3 > Dec
static constexpr double U
static int fails
static bool same(double a, double b)