203 const std::vector<IVec<3>> grids = {
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})
238 for (std::size_t np : list) {
239 if ((Index)np > cells(
G))
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);
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);
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);
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);
269 for (
const auto& s : A.sizes())
271 CHECK(A.numBlocks() == np && tot == cells(
G),
"%s: auto does not tile", name);
275 "CHANGED %s: legacy max/min %.3f depth %d [%s] -> auto max/min %.3f depth %d "
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());
282 std::printf(
"census: %d configurations, %d changed, %d coarse-first\n", nConf, nChanged,
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];
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);
296 for (std::size_t np : {3, 12, 24, 32, 96, 192}) {
297 const Dec A = CutcellMG::decomposition(np, 128, 96, 64);
299 CHECK(
same(A, CutcellMG::decomposition(np, 128, 96, 64, 1)),
"128x96x64 np 12: not legacy");
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));
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());
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}}},
318 {24, S{{{32, 16, 64}, 8}, {{32, 32, 32}, 16}}},
319 {192, S{{{16, 16, 16}, 192}}},
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);
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;
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);
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));
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},
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);
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);
502 "levels >= 2: %d (published configuration, levels) rows checked against the pre-partition "
505 std::printf(
"guard (WO-D): %d configurations reverted to legacy\n", nReverted);
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;