From d0f311a6dc9478de5202f861d7b4502c266c9005 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sun, 22 Nov 2026 17:09:58 +0100 Subject: Update benchmarks and comment --- benchmarks/benchmarks.md | 125 ++++++++++++++--------- benchmarks/img/17moves1thread.png | Bin 125200 -> 125398 bytes benchmarks/img/17movesallsolutions16threads.png | Bin 0 -> 102082 bytes benchmarks/img/18moves1thread.png | Bin 125893 -> 125863 bytes benchmarks/img/18movesallsolutions16threads.png | Bin 0 -> 111102 bytes benchmarks/img/19moves1thread.png | Bin 131787 -> 131732 bytes benchmarks/img/19movesallsolutions16threads.png | Bin 0 -> 115928 bytes benchmarks/img/20moves1thread.png | Bin 121054 -> 120506 bytes benchmarks/img/20movesallsolutions16threads.png | Bin 0 -> 128612 bytes benchmarks/img/egg_16_threads_speedup_factor.png | Bin 82970 -> 85239 bytes benchmarks/img/egg_4_threads_speedup_factor.png | Bin 84399 -> 84136 bytes benchmarks/plot-benchmarks.py | 77 +++++++++++--- benchmarks/results_egg.py | 45 ++++---- benchmarks/run-egg-benchmarks.sh | 26 +++-- benchmarks/tables_16_threads.md | 24 ++--- benchmarks/tables_1_thread.md | 24 ++--- benchmarks/tables_4_threads.md | 22 ++-- benchmarks/tables_all_solutions.md | 17 +++ 18 files changed, 233 insertions(+), 127 deletions(-) create mode 100644 benchmarks/img/17movesallsolutions16threads.png create mode 100644 benchmarks/img/18movesallsolutions16threads.png create mode 100644 benchmarks/img/19movesallsolutions16threads.png create mode 100644 benchmarks/img/20movesallsolutions16threads.png (limited to 'benchmarks') diff --git a/benchmarks/benchmarks.md b/benchmarks/benchmarks.md index 4f36cac..d6ec328 100644 --- a/benchmarks/benchmarks.md +++ b/benchmarks/benchmarks.md @@ -4,16 +4,16 @@ This page contains some benchmarks for some of the possible configurations of the H48 optimal solver. For comparison we also include similar measurements for two other optimal solvers: -* Andrew Skalski's [vcube](https://github.com/Voltara/vcube), which - is a truly impressive implementation of Tomas Rokicki's +* Andrew Skalski's [vcube](https://github.com/Voltara/vcube) (commit + 9f5bc2c), which is a truly impressive implementation of Tomas Rokicki's [nxopt](https://github.com/rokicki/cube20src/blob/master/nxopt.md) that has been taken as a reference throughout the development of H48. This solver also uses an A* search, but the search is supported by different pruning tables. * Arhan Chaudhary's - [egg-solver](https://github.com/ArhanChaudhary/egg-solver), which - is an AI-generated implementation of the H48 method with - highly-optimized microthreading. + [egg-solver](https://github.com/ArhanChaudhary/egg-solver) (commit + c3eb909), which is an AI-generated implementation of the H48 method + with highly-optimized microthreading. Similar benchmarks can be found: @@ -25,7 +25,7 @@ Similar benchmarks can be found: * In Enrico Tenuti's [thesis](https://github.com/enricotenuti/h48thesis), also using an old implementation of H48, but including more data and nice plots. -* In [the documentation page](https://egg-solver/arhan.sh/docs/index.html) +* In [the documentation page](https://egg-solver.arhan.sh/docs/index.html) for egg-solver. ## Setting @@ -85,21 +85,21 @@ Time per cube (in seconds, lower is better). |Solver|Size|17 moves|18 moves|19 moves|20 moves|Superflip| |:-----|:---|-------:|-------:|-------:|-------:|--------:| |vcube 212 |58.2 GiB| 0.11| 0.75| 3.43| 27.28| 19.30| -|egg h11 |58.0 GiB| 0.01| 0.06| 0.24| 2.16| 0.14| +|egg h11 |58.0 GiB| 0.01| 0.06| 0.24| 2.14| 0.14| |H48 h11 |56.5 GiB| 0.08| 0.43| 1.86| 12.20| 15.39| |vcube 404 |31.8 GiB| 0.23| 1.24| 6.10| 59.33| 268.26| -|egg h10 |29.0 GiB| 0.02| 0.10| 0.47| 4.00| 0.23| +|egg h10 |29.0 GiB| 0.02| 0.10| 0.46| 3.96| 0.24| |H48 h10 |28.3 GiB| 0.13| 0.69| 3.37| 23.15| 38.00| |vcube 308 |21.2 GiB| 0.17| 1.02| 6.20| 58.70| 604.35| -|egg h9 |14.5 GiB| 0.03| 0.19| 0.91| | | +|egg h9 |14.5 GiB| 0.03| 0.21| 0.98| | | |H48 h9 |14.1 GiB| 0.22| 1.43| 6.56| | | |vcube 208 | 7.3 GiB| 0.56| 4.36| 20.58| | | -|egg h8 | 7.2 GiB| 0.07| 0.39| 1.82| | | +|egg h8 | 7.2 GiB| 0.06| 0.36| 1.69| | | |H48 h8 | 7.1 GiB| 0.46| 3.43| 14.18| | | -|egg h7 | 3.6 GiB| 0.11| 0.81| 4.35| | | +|egg h7 | 3.6 GiB| 0.10| 0.74| 3.88| | | |H48 h7 | 3.5 GiB| 0.63| 4.84| 23.31| | | |vcube 112 | 2.4 GiB| 0.96| 9.29| 40.52| | | -|egg h6 | 1.8 GiB| 0.20| 1.53| 8.19| | | +|egg h6 | 1.8 GiB| 0.21| 1.60| 8.62| | | |H48 h6 | 1.8 GiB| 1.26| 9.51| 47.14| | | Time per cube adjusted for table size (in seconds \* GiB, lower is better). @@ -107,21 +107,21 @@ Time per cube adjusted for table size (in seconds \* GiB, lower is better). |Solver|Size|17 moves|18 moves|19 moves|20 moves|Superflip| |:-----|:---|-------:|-------:|-------:|-------:|--------:| |vcube 212 |58.2 GiB| 6.43| 43.80| 199.38| 1587.43| 1122.73| -|egg h11 |58.0 GiB| 0.55| 3.31| 13.99| 125.17| 8.04| +|egg h11 |58.0 GiB| 0.55| 3.32| 13.97| 124.06| 7.93| |H48 h11 |56.5 GiB| 4.56| 24.55| 104.96| 689.22| 869.37| |vcube 404 |31.8 GiB| 7.40| 39.47| 194.01| 1887.94| 8535.87| -|egg h10 |29.0 GiB| 0.50| 2.90| 13.69| 115.88| 6.80| +|egg h10 |29.0 GiB| 0.48| 2.85| 13.48| 114.83| 7.08| |H48 h10 |28.3 GiB| 3.62| 19.45| 95.15| 654.05| 1073.69| |vcube 308 |21.2 GiB| 3.51| 21.71| 131.50| 1245.26| 12819.94| -|egg h9 |14.5 GiB| 0.47| 2.74| 13.19| | | +|egg h9 |14.5 GiB| 0.50| 3.00| 14.22| | | |H48 h9 |14.1 GiB| 3.11| 20.18| 92.68| | | |vcube 208 | 7.3 GiB| 4.08| 31.74| 149.68| | | -|egg h8 | 7.2 GiB| 0.48| 2.82| 13.16| | | +|egg h8 | 7.2 GiB| 0.45| 2.63| 12.27| | | |H48 h8 | 7.1 GiB| 3.23| 24.26| 100.15| | | -|egg h7 | 3.6 GiB| 0.39| 2.94| 15.77| | | +|egg h7 | 3.6 GiB| 0.36| 2.69| 14.05| | | |H48 h7 | 3.5 GiB| 2.22| 17.12| 82.35| | | |vcube 112 | 2.4 GiB| 2.33| 22.53| 98.23| | | -|egg h6 | 1.8 GiB| 0.36| 2.76| 14.83| | | +|egg h6 | 1.8 GiB| 0.37| 2.89| 15.62| | | |H48 h6 | 1.8 GiB| 2.24| 16.80| 83.33| | | @@ -131,9 +131,10 @@ Time per cube adjusted for table size (in seconds \* GiB, lower is better). As we can see, egg-solver is the clear winner, consistently beating H48 by -factors of 5.3x-8.8x for 17-19 moves scrambles, comparing tables of similar +factors of 5x-9x for all sets of scrambles, comparing tables of similar size. Moreover, egg-solver is more than 100 times faster when solving the -superflip configuration. +superflip configuration, likely due to better expoitation of symmetries, +including inverse positions. Adjusting for table size, H48 is generally faster than vcube. The gap between the two solvers is larger for scrambles with longer optimal solutions. @@ -144,8 +145,9 @@ The same benchmark as before is repeated using 4 and 16 threads (recall that the CPU used for these tests has 8 physical cores and 16 virtual threads). -For the reasons mentioned above, we will only compare H48 and egg-solver -in this section. +For the reasons mentioned above, in this section we will only compare H48 +and egg-solver; for the latter with enable per-cube parallelization using +the `-c 1` option.
Results: Single solution, 4 threads @@ -156,32 +158,32 @@ Time per cube (in seconds, lower is better). |:-----|:---|-------:|-------:|-------:|-------:|--------:| |egg h11 |58.0 GiB| 0.00| 0.01| 0.06| 0.55| 0.03| |H48 h11 |56.5 GiB| 0.03| 0.13| 0.50| 3.24| 4.17| -|egg h10 |29.0 GiB| 0.00| 0.03| 0.12| 1.05| 0.09| +|egg h10 |29.0 GiB| 0.00| 0.02| 0.12| 1.02| 0.09| |H48 h10 |28.3 GiB| 0.05| 0.18| 0.90| 6.21| 9.85| -|egg h9 |14.5 GiB| 0.01| 0.05| 0.23| | | +|egg h9 |14.5 GiB| 0.01| 0.05| 0.25| | | |H48 h9 |14.1 GiB| 0.07| 0.39| 1.73| 12.50| 18.97| -|egg h8 | 7.2 GiB| 0.02| 0.10| 0.48| | | +|egg h8 | 7.2 GiB| 0.02| 0.09| 0.43| | | |H48 h8 | 7.1 GiB| 0.13| 0.91| 3.71| | | -|egg h7 | 3.6 GiB| 0.03| 0.21| 1.11| | | +|egg h7 | 3.6 GiB| 0.03| 0.19| 1.08| | | |H48 h7 | 3.5 GiB| 0.18| 1.29| 6.19| | | -|egg h6 | 1.8 GiB| 0.05| 0.39| 2.11| | | +|egg h6 | 1.8 GiB| 0.05| 0.39| 2.23| | | |H48 h6 | 1.8 GiB| 0.34| 2.48| 12.33| | | Speed-up factor (higher is better). |Solver|Size|17 moves|18 moves|19 moves|20 moves|Superflip| |:-----|:---|-------:|-------:|-------:|-------:|--------:| -|egg h11 |58.0 GiB| 3.77| 3.90| 3.89| 3.93| 5.42| +|egg h11 |58.0 GiB| 3.57| 3.85| 3.72| 3.90| 5.41| |H48 h11 |56.5 GiB| 2.51| 3.44| 3.75| 3.77| 3.69| -|egg h10 |29.0 GiB| 3.88| 3.77| 3.98| 3.81| 2.72| +|egg h10 |29.0 GiB| 3.68| 4.03| 3.92| 3.89| 2.78| |H48 h10 |28.3 GiB| 2.79| 3.91| 3.75| 3.73| 3.86| -|egg h9 |14.5 GiB| 3.90| 3.87| 3.88| | | +|egg h9 |14.5 GiB| 3.80| 4.20| 3.91| | | |H48 h9 |14.1 GiB| 3.18| 3.66| 3.79| | | -|egg h8 | 7.2 GiB| 3.87| 3.91| 3.81| | | +|egg h8 | 7.2 GiB| 3.81| 4.01| 3.91| | | |H48 h8 | 7.1 GiB| 3.48| 3.78| 3.82| | | -|egg h7 | 3.6 GiB| 3.87| 3.87| 3.93| | | +|egg h7 | 3.6 GiB| 3.81| 3.88| 3.59| | | |H48 h7 | 3.5 GiB| 3.43| 3.75| 3.77| | | -|egg h6 | 1.8 GiB| 3.98| 3.90| 3.87| | | +|egg h6 | 1.8 GiB| 3.93| 4.09| 3.87| | | |H48 h6 | 1.8 GiB| 3.73| 3.84| 3.82| | | @@ -196,34 +198,34 @@ Time per cube (in seconds, lower is better). |Solver|Size|17 moves|18 moves|19 moves|20 moves|Superflip| |:-----|:---|-------:|-------:|-------:|-------:|--------:| -|egg h11 |58.0 GiB| 0.00| 0.01| 0.03| 0.27| 0.02| +|egg h11 |58.0 GiB| 0.00| 0.01| 0.03| 0.28| 0.02| |H48 h11 |56.5 GiB| 0.02| 0.06| 0.21| 1.16| 1.84| -|egg h10 |29.0 GiB| 0.00| 0.02| 0.09| 0.77| 0.04| +|egg h10 |29.0 GiB| 0.00| 0.01| 0.06| 0.50| 0.03| |H48 h10 |28.3 GiB| 0.03| 0.08| 0.34| 2.24| 4.21| -|egg h9 |14.5 GiB| 0.01| 0.04| 0.17| | | +|egg h9 |14.5 GiB| 0.00| 0.02| 0.11| | | |H48 h9 |14.1 GiB| 0.03| 0.14| 0.64| 4.43| 8.04| -|egg h8 | 7.2 GiB| 0.01| 0.07| 0.33| | | +|egg h8 | 7.2 GiB| 0.01| 0.04| 0.21| | | |H48 h8 | 7.1 GiB| 0.06| 0.30| 1.36| | | -|egg h7 | 3.6 GiB| 0.02| 0.15| 0.79| | | +|egg h7 | 3.6 GiB| 0.01| 0.09| 0.53| | | |H48 h7 | 3.5 GiB| 0.08| 0.41| 2.20| | | -|egg h6 | 1.8 GiB| 0.04| 0.28| 1.53| | | +|egg h6 | 1.8 GiB| 0.02| 0.18| 0.97| | | |H48 h6 | 1.8 GiB| 0.13| 0.77| 4.37| | | Speed-up factor (higher is better). |Solver|Size|17 moves|18 moves|19 moves|20 moves|Superflip| |:-----|:---|-------:|-------:|-------:|-------:|--------:| -|egg h11 |58.0 GiB| 5.56| 8.03| 8.00| 8.05| 8.45| +|egg h11 |58.0 GiB| 6.27| 7.35| 7.59| 7.76| 7.61| |H48 h11 |56.5 GiB| 3.73| 7.32| 8.87| 10.54| 8.35| -|egg h10 |29.0 GiB| 5.63| 5.58| 5.53| 5.18| 6.05| +|egg h10 |29.0 GiB| 6.86| 8.10| 8.02| 7.92| 7.13| |H48 h10 |28.3 GiB| 4.76| 8.60| 9.84| 10.34| 9.03| -|egg h9 |14.5 GiB| 5.46| 5.32| 5.35| | | +|egg h9 |14.5 GiB| 7.84| 9.10| 8.56| | | |H48 h9 |14.1 GiB| 6.34| 10.07| 10.19| | | -|egg h8 | 7.2 GiB| 5.49| 5.50| 5.53| | | +|egg h8 | 7.2 GiB| 7.71| 8.36| 8.04| | | |H48 h8 | 7.1 GiB| 7.51| 11.36| 10.43| | | -|egg h7 | 3.6 GiB| 5.33| 5.38| 5.48| | | +|egg h7 | 3.6 GiB| 8.00| 8.15| 7.32| | | |H48 h7 | 3.5 GiB| 8.21| 11.75| 10.61| | | -|egg h6 | 1.8 GiB| 5.51| 5.42| 5.35| | | +|egg h6 | 1.8 GiB| 8.62| 8.96| 8.89| | | |H48 h6 | 1.8 GiB| 9.38| 12.31| 10.80| | | @@ -237,15 +239,17 @@ getting close to the 4x theoretical maximum speedup in slower cases speedup for the superflip, likely due to single-scramble variance, i.e. the thread that found the solution stopped earlier. -In the 16 threads benchmark shows that, although the virtual threads -help push H48 beyond the 8x theoretical speedup that would be provided -by the 8 cores, it is nowhere near a 16x speedup. egg-solver seems -stuck around 5.5x speedup. +The 16 threads benchmark shows that, although the virtual threads help +push H48 beyond the 8x theoretical speedup that would be provided by the +8 cores, it is nowhere near a 16x speedup. Moreover, egg-solver does not +seem to take advantage of the CPU's hyperthreading, likely because its +own custom micro-threading is based on the same principle and it saturates +any possible speedup that hyperthreading could provide. ### All solutions Finally, we ran a test on finding *all* optimal solutions which, as -far as I know, is a use case not supported by vcube or egg-solver. +far as I know, is a use case only supported by H48 and egg-solver. For convenience, this test is only run on 16 threads. @@ -255,26 +259,46 @@ Time per cube (in seconds, lower is better). |Solver|Size|17 moves|18 moves|19 moves|20 moves|Superflip| |:-----|:---|-------:|-------:|-------:|-------:|--------:| +|egg h11 |58.0 GiB| 0.00| 0.05| 0.54| 5.08| 15.38| |H48 h11 |56.5 GiB| 0.04| 0.24| 1.88| 3.88| 1.86| +|egg h10 |29.0 GiB| 0.01| 0.09| 1.00| 9.42| 31.05| |H48 h10 |28.3 GiB| 0.05| 0.39| 3.51| 7.54| 4.29| +|egg h9 |14.5 GiB| 0.01| 0.17| 1.97| | | |H48 h9 |14.1 GiB| 0.08| 0.73| 6.92| | | +|egg h8 | 7.2 GiB| 0.03| 0.31| 3.49| | | |H48 h8 | 7.1 GiB| 0.16| 1.54| 14.78| | | +|egg h7 | 3.6 GiB| 0.04| 0.57| 6.38| | | |H48 h7 | 3.5 GiB| 0.22| 2.37| 25.35| | | +|egg h6 | 1.8 GiB| 0.10| 1.27| 14.93| | | |H48 h6 | 1.8 GiB| 0.40| 4.58| 50.17| | | Time per cube adjusted for table size (in seconds \* GiB, lower is better). |Solver|Size|17 moves|18 moves|19 moves|20 moves|Superflip| |:-----|:---|-------:|-------:|-------:|-------:|--------:| +|egg h11 |58.0 GiB| 0.25| 2.88| 31.12| 294.67| 892.07| |H48 h11 |56.5 GiB| 2.00| 13.40| 106.21| 219.43| 105.10| +|egg h10 |29.0 GiB| 0.22| 2.58| 28.89| 273.08| 900.34| |H48 h10 |28.3 GiB| 1.45| 11.13| 99.17| 212.94| 121.20| +|egg h9 |14.5 GiB| 0.21| 2.51| 28.49| | | |H48 h9 |14.1 GiB| 1.13| 10.25| 97.80| | | +|egg h8 | 7.2 GiB| 0.18| 2.25| 25.30| | | |H48 h8 | 7.1 GiB| 1.10| 10.85| 104.41| | | +|egg h7 | 3.6 GiB| 0.16| 2.05| 23.11| | | |H48 h7 | 3.5 GiB| 0.79| 8.38| 89.57| | | +|egg h6 | 1.8 GiB| 0.18| 2.29| 27.06| | | |H48 h6 | 1.8 GiB| 0.71| 8.10| 88.68| | | + + + + +
+For all-solutions egg-solver's advantage reduces to 3x-4x, and for +20 moves scrambles it appears to be even slower than H48. + ## Other notes * To repeat the benchmarks for H48, use `./benchmarks/run-h48-benchmarks.sh`. @@ -291,6 +315,7 @@ Time per cube adjusted for table size (in seconds \* GiB, lower is better). them. Both apporaches have pros and cons: vcube's approch has less overhead in coordination between the threads, but often some threads may be left without work when there are no more cubes left to solve. + egg-solver supports both modes via the `-c` option. * Per-cube parallelization means that H48 will always be faster than vcube when solving a single cube. * vcube only supports x86 processors (Intel, AMD), while H48 runs on any diff --git a/benchmarks/img/17moves1thread.png b/benchmarks/img/17moves1thread.png index 1ade3f3..c5a4db0 100644 Binary files a/benchmarks/img/17moves1thread.png and b/benchmarks/img/17moves1thread.png differ diff --git a/benchmarks/img/17movesallsolutions16threads.png b/benchmarks/img/17movesallsolutions16threads.png new file mode 100644 index 0000000..b28595f Binary files /dev/null and b/benchmarks/img/17movesallsolutions16threads.png differ diff --git a/benchmarks/img/18moves1thread.png b/benchmarks/img/18moves1thread.png index 0281d4f..71e41cc 100644 Binary files a/benchmarks/img/18moves1thread.png and b/benchmarks/img/18moves1thread.png differ diff --git a/benchmarks/img/18movesallsolutions16threads.png b/benchmarks/img/18movesallsolutions16threads.png new file mode 100644 index 0000000..d7b4779 Binary files /dev/null and b/benchmarks/img/18movesallsolutions16threads.png differ diff --git a/benchmarks/img/19moves1thread.png b/benchmarks/img/19moves1thread.png index 17c0d46..b70eb9e 100644 Binary files a/benchmarks/img/19moves1thread.png and b/benchmarks/img/19moves1thread.png differ diff --git a/benchmarks/img/19movesallsolutions16threads.png b/benchmarks/img/19movesallsolutions16threads.png new file mode 100644 index 0000000..ba0ebea Binary files /dev/null and b/benchmarks/img/19movesallsolutions16threads.png differ diff --git a/benchmarks/img/20moves1thread.png b/benchmarks/img/20moves1thread.png index 7ed910f..6f058a0 100644 Binary files a/benchmarks/img/20moves1thread.png and b/benchmarks/img/20moves1thread.png differ diff --git a/benchmarks/img/20movesallsolutions16threads.png b/benchmarks/img/20movesallsolutions16threads.png new file mode 100644 index 0000000..6058304 Binary files /dev/null and b/benchmarks/img/20movesallsolutions16threads.png differ diff --git a/benchmarks/img/egg_16_threads_speedup_factor.png b/benchmarks/img/egg_16_threads_speedup_factor.png index 3c4a81b..4977092 100644 Binary files a/benchmarks/img/egg_16_threads_speedup_factor.png and b/benchmarks/img/egg_16_threads_speedup_factor.png differ diff --git a/benchmarks/img/egg_4_threads_speedup_factor.png b/benchmarks/img/egg_4_threads_speedup_factor.png index a00746a..648ce55 100644 Binary files a/benchmarks/img/egg_4_threads_speedup_factor.png and b/benchmarks/img/egg_4_threads_speedup_factor.png differ diff --git a/benchmarks/plot-benchmarks.py b/benchmarks/plot-benchmarks.py index dfd1f90..e72e13b 100644 --- a/benchmarks/plot-benchmarks.py +++ b/benchmarks/plot-benchmarks.py @@ -185,9 +185,9 @@ with open(benchmarks_4_threads, "w") as f: ) f.write("\n") f.write( - '\n' - '\n' - ) + '\n' + '\n' + ) f.write("\n") f.write("\n") @@ -223,9 +223,9 @@ with open(benchmarks_16_threads, "w") as f: ) f.write("\n") f.write( - '\n' - '\n' - ) + '\n' + '\n' + ) f.write("\n") f.write("\n") @@ -241,14 +241,35 @@ with open(benchmarks_all_solutions, "w") as f: f.write("\n") f.write("Time per cube (in seconds, lower is better).\n") f.write("\n") - print_table(f, results_h48.h48_all_solutions, None, None, False, False) + print_table( + f, + results_h48.h48_all_solutions, + None, + results_egg.egg_all_solutions, + False, + False, + ) f.write("\n") f.write( "Time per cube adjusted for table size " "(in seconds \\* GiB, lower is better).\n" ) f.write("\n") - print_table(f, results_h48.h48_all_solutions, None, None, True, False) + print_table( + f, + results_h48.h48_all_solutions, + None, + results_egg.egg_all_solutions, + True, + False + ) + f.write("\n") + f.write( + '\n' + '\n' + '\n' + '\n' + ) f.write("\n") f.write("\n") @@ -256,20 +277,33 @@ with open(benchmarks_all_solutions, "w") as f: def plot_comparison(title, hd, vd, ed, key): d = 1 if key == "superflip" else 25 - h48x = [sizes_h48[m]/(2**30) for m in hd.keys() if key in hd[m]] - vcubex = [sizes_vcube[m]/(2**30) for m in vd.keys() if key in vd[m]] - eggx = [sizes_egg[m]/(2**30) for m in ed.keys() if key in ed[m]] - h48y = [d[key] for _, d in hd.items() if key in d] - vcubey = [d[key] for _, d in vd.items() if key in d] - eggy = [d[key] for _, d in ed.items() if key in d] plt.clf() plt.title(title) plt.xlabel("Table size (GiB)") plt.ylabel("Time to solve (s / cube)") - plt.plot(h48x, h48y, "o--", label = "H48") - plt.plot(vcubex, vcubey, "o--", label = "vcube") - plt.plot(eggx, eggy, "o--", label = "egg") + + if hd is not None: + h48x = [ + sizes_h48[m]/(2**30) for m in hd.keys() if key in hd[m] + ] + h48y = [d[key] for _, d in hd.items() if key in d] + plt.plot(h48x, h48y, "o--", label = "H48") + + if vd is not None: + vcubex = [ + sizes_vcube[m]/(2**30) for m in vd.keys() if key in vd[m] + ] + vcubey = [d[key] for _, d in vd.items() if key in d] + plt.plot(vcubex, vcubey, "o--", label = "vcube") + + if ed is not None: + eggx = [ + sizes_egg[m]/(2**30) for m in ed.keys() if key in ed[m] + ] + eggy = [d[key] for _, d in ed.items() if key in d] + plt.plot(eggx, eggy, "o--", label = "egg") + plt.legend(loc = "right") filename = title.replace(" ", "").replace(",", "") + ".png" plt.savefig(benchmarks_img_dir / filename, dpi=300) @@ -278,8 +312,17 @@ def plot_comparison(title, hd, vd, ed, key): rh = results_h48.h48_single_thread rv = results_vcube.vcube_single_thread re = results_egg.egg_single_thread +rhall = results_h48.h48_all_solutions +reall = results_egg.egg_all_solutions for m in [17, 18, 19, 20]: plot_comparison(f"{m} moves 1 thread", rh, rv, re, m) + plot_comparison( + f"{m} moves all solutions, 16 threads", + rhall, + None, + reall, + m, + ) def plot_multithread_scatter(title, slow, fast): plt.clf() diff --git a/benchmarks/results_egg.py b/benchmarks/results_egg.py index 3018cf4..57251f2 100644 --- a/benchmarks/results_egg.py +++ b/benchmarks/results_egg.py @@ -1,27 +1,36 @@ egg_single_thread = { - 6: {17: 5.032832, 18: 38.135722, 19: 204.652846}, - 7: {17: 2.669533, 18: 20.281338, 19: 108.782419}, - 8: {17: 1.651355, 18: 9.714498, 19: 45.383547}, - 9: {17: 0.803654, 18: 4.725768, 19: 22.741144}, - 10: {17: 0.429919, 18: 2.498317, 19: 11.803061, 20: 99.918920, "superflip": 0.234443}, - 11: {17: 0.237963, 18: 1.428538, 19: 6.031292, 20: 53.963847, "superflip": 0.138605}, + 6: {17: 5.139311, 18: 39.910660, 19: 215.513895}, + 7: {17: 2.504008, 18: 18.529593, 19: 96.897878}, + 8: {17: 1.549367, 18: 9.064201, 19: 42.325193}, + 9: {17: 0.858265, 18: 5.172505, 19: 24.518997}, + 10: {17: 0.417568, 18: 2.459152, 19: 11.623105, 20: 99.011990, "superflip": 0.244296}, + 11: {17: 0.238193, 18: 1.432498, 19: 6.021714, 20: 53.487854, "superflip": 0.136739}, } egg_4_threads = { - 6: {17: 1.265374, 18: 9.782992, 19: 52.818767}, - 7: {17: 0.688996, 18: 5.239901, 19: 27.651903}, - 8: {17: 0.426688, 18: 2.487043, 19: 11.904544}, - 9: {17: 0.206107, 18: 1.220541, 19: 5.867951}, - 10: {17: 0.110690, 18: 0.662000, 19: 2.965403, 20: 26.244233, "superflip": 0.086182}, - 11: {17: 0.063179, 18: 0.366318, 19: 1.552111, 20: 13.738317, "superflip": 0.025594}, + 6: {17: 1.306705, 18: 9.759825, 19: 55.629836}, + 7: {17: 0.656651, 18: 4.781186, 19: 26.968132}, + 8: {17: 0.406570, 18: 2.262452, 19: 10.828606}, + 9: {17: 0.225972, 18: 1.230342, 19: 6.270499}, + 10: {17: 0.113393, 18: 0.610004, 19: 2.963694, 20: 25.467137, "superflip": 0.087832}, + 11: {17: 0.066650, 18: 0.372158, 19: 1.617824, 20: 13.699318, "superflip": 0.025293}, } egg_16_threads = { - 6: {17: 0.913331, 18: 7.036477, 19: 38.217758}, - 7: {17: 0.501139, 18: 3.771112, 19: 19.841116}, - 8: {17: 0.301029, 18: 1.764851, 19: 8.205679}, - 9: {17: 0.147238, 18: 0.887650, 19: 4.249228}, - 10: {17: 0.076401, 18: 0.447673, 19: 2.135498, 20: 19.303369, "superflip": 0.038754}, - 11: {17: 0.042768, 18: 0.177966, 19: 0.754095, 20: 6.700410, "superflip": 0.016397}, + 6: {17: 0.596467, 18: 4.455692, 19: 24.234698}, + 7: {17: 0.313078, 18: 2.272664, 19: 13.245863}, + 8: {17: 0.200848, 18: 1.084005, 19: 5.266139}, + 9: {17: 0.109538, 18: 0.568547, 19: 2.863034}, + 10: {17: 0.060911, 18: 0.303420, 19: 1.449804, 20: 12.498059, "superflip": 0.034263}, + 11: {17: 0.037969, 18: 0.194775, 19: 0.793440, 20: 6.893702, "superflip": 0.017957}, +} + +egg_all_solutions = { + 6: {17: 2.448883, 18: 31.628611, 19: 373.309154}, + 7: {17: 1.096209, 18: 14.131642, 19: 159.427805}, + 8: {17: 0.636421, 18: 7.748630, 19: 87.271360}, + 9: {17: 0.353850, 18: 4.327602, 19: 49.125814}, + 10: {17: 0.187192, 18: 2.222200, 19: 24.909298, 20: 235.468196, "superflip": 31.053940}, + 11: {17: 0.107630, 18: 1.242064, 19: 13.417236, 20: 127.044933, "superflip": 15.384209}, } diff --git a/benchmarks/run-egg-benchmarks.sh b/benchmarks/run-egg-benchmarks.sh index d29db27..f5e7c32 100755 --- a/benchmarks/run-egg-benchmarks.sh +++ b/benchmarks/run-egg-benchmarks.sh @@ -1,30 +1,41 @@ +# egg-solver built with: +# cargo build --release --locked +# mkdir -p tables +# target/release/gen $i auto tables/h$i # i from 0 to 11 +# target/release/bench tables/h$i tune # i from 0 to 11 + scr="../nissy-core/benchmarks/scrambles" out="../nissy-core/benchmarks/results_egg.py" get_solve_time() { - ./target/release/solve -t "$1" --table "tables/h$2" <"$3" \ + if [ -n "$4" ]; then + solve_all="./target/release/solve --all-optimal" + else + solve_all="./target/release/solve" + fi + $solve_all -t "$1" -c 1 --table "tables/h$2" <"$3" \ | tail -1 | sed 's/.*cubes wall //; s/ wall.*//' } do_all() { - echo "doing all $1 $2" t=$1 name=$2 + printf '%s = {\n' "$name" >> "$out" for i in 6 7 8 9 10 11 ; do echo "Doing 17 moves for h$i with $t threads..." - t17="$(get_solve_time $t $i "$scr/scrambles-17.txt")" + t17="$(get_solve_time $t $i "$scr/scrambles-17.txt" "$3")" echo "Doing 18 moves for h$i with $t threads..." - t18="$(get_solve_time $t $i "$scr/scrambles-18.txt")" + t18="$(get_solve_time $t $i "$scr/scrambles-18.txt" "$3")" echo "Doing 19 moves for h$i with $t threads..." - t19="$(get_solve_time $t $i "$scr/scrambles-19.txt")" + t19="$(get_solve_time $t $i "$scr/scrambles-19.txt" "$3")" printf '\t%s: {17: %s, 18: %s, 19: %s' $i $t17 $t18 $t19 >> "$out" if [ "$i" -ge 10 ]; then echo "Doing 20 moves for h$i with $t threads..." - t20="$(get_solve_time $t $i "$scr/scrambles-20.txt")" + t20="$(get_solve_time $t $i "$scr/scrambles-20.txt" "$3")" printf ', 20: %s' $t20 >> "$out" echo "Doing superflip moves for h$i with $t threads..." - tsf="$(get_solve_time $t $i "$scr/superflip.txt")" + tsf="$(get_solve_time $t $i "$scr/superflip.txt" "$3")" printf ', "superflip": %s},\n' $tsf >> "$out" else printf '},\n' >> "$out" @@ -38,3 +49,4 @@ printf '' > "$out" do_all 1 "egg_single_thread" do_all 4 "egg_4_threads" do_all 16 "egg_16_threads" +do_all 16 "egg_all_solutions" "all" diff --git a/benchmarks/tables_16_threads.md b/benchmarks/tables_16_threads.md index ab5f03a..a2735c1 100644 --- a/benchmarks/tables_16_threads.md +++ b/benchmarks/tables_16_threads.md @@ -5,34 +5,34 @@ Time per cube (in seconds, lower is better). |Solver|Size|17 moves|18 moves|19 moves|20 moves|Superflip| |:-----|:---|-------:|-------:|-------:|-------:|--------:| -|egg h11 |58.0 GiB| 0.00| 0.01| 0.03| 0.27| 0.02| +|egg h11 |58.0 GiB| 0.00| 0.01| 0.03| 0.28| 0.02| |H48 h11 |56.5 GiB| 0.02| 0.06| 0.21| 1.16| 1.84| -|egg h10 |29.0 GiB| 0.00| 0.02| 0.09| 0.77| 0.04| +|egg h10 |29.0 GiB| 0.00| 0.01| 0.06| 0.50| 0.03| |H48 h10 |28.3 GiB| 0.03| 0.08| 0.34| 2.24| 4.21| -|egg h9 |14.5 GiB| 0.01| 0.04| 0.17| | | +|egg h9 |14.5 GiB| 0.00| 0.02| 0.11| | | |H48 h9 |14.1 GiB| 0.03| 0.14| 0.64| 4.43| 8.04| -|egg h8 | 7.2 GiB| 0.01| 0.07| 0.33| | | +|egg h8 | 7.2 GiB| 0.01| 0.04| 0.21| | | |H48 h8 | 7.1 GiB| 0.06| 0.30| 1.36| | | -|egg h7 | 3.6 GiB| 0.02| 0.15| 0.79| | | +|egg h7 | 3.6 GiB| 0.01| 0.09| 0.53| | | |H48 h7 | 3.5 GiB| 0.08| 0.41| 2.20| | | -|egg h6 | 1.8 GiB| 0.04| 0.28| 1.53| | | +|egg h6 | 1.8 GiB| 0.02| 0.18| 0.97| | | |H48 h6 | 1.8 GiB| 0.13| 0.77| 4.37| | | Speed-up factor (higher is better). |Solver|Size|17 moves|18 moves|19 moves|20 moves|Superflip| |:-----|:---|-------:|-------:|-------:|-------:|--------:| -|egg h11 |58.0 GiB| 5.56| 8.03| 8.00| 8.05| 8.45| +|egg h11 |58.0 GiB| 6.27| 7.35| 7.59| 7.76| 7.61| |H48 h11 |56.5 GiB| 3.73| 7.32| 8.87| 10.54| 8.35| -|egg h10 |29.0 GiB| 5.63| 5.58| 5.53| 5.18| 6.05| +|egg h10 |29.0 GiB| 6.86| 8.10| 8.02| 7.92| 7.13| |H48 h10 |28.3 GiB| 4.76| 8.60| 9.84| 10.34| 9.03| -|egg h9 |14.5 GiB| 5.46| 5.32| 5.35| | | +|egg h9 |14.5 GiB| 7.84| 9.10| 8.56| | | |H48 h9 |14.1 GiB| 6.34| 10.07| 10.19| | | -|egg h8 | 7.2 GiB| 5.49| 5.50| 5.53| | | +|egg h8 | 7.2 GiB| 7.71| 8.36| 8.04| | | |H48 h8 | 7.1 GiB| 7.51| 11.36| 10.43| | | -|egg h7 | 3.6 GiB| 5.33| 5.38| 5.48| | | +|egg h7 | 3.6 GiB| 8.00| 8.15| 7.32| | | |H48 h7 | 3.5 GiB| 8.21| 11.75| 10.61| | | -|egg h6 | 1.8 GiB| 5.51| 5.42| 5.35| | | +|egg h6 | 1.8 GiB| 8.62| 8.96| 8.89| | | |H48 h6 | 1.8 GiB| 9.38| 12.31| 10.80| | | diff --git a/benchmarks/tables_1_thread.md b/benchmarks/tables_1_thread.md index bf2e0ab..1f2d7b0 100644 --- a/benchmarks/tables_1_thread.md +++ b/benchmarks/tables_1_thread.md @@ -6,21 +6,21 @@ Time per cube (in seconds, lower is better). |Solver|Size|17 moves|18 moves|19 moves|20 moves|Superflip| |:-----|:---|-------:|-------:|-------:|-------:|--------:| |vcube 212 |58.2 GiB| 0.11| 0.75| 3.43| 27.28| 19.30| -|egg h11 |58.0 GiB| 0.01| 0.06| 0.24| 2.16| 0.14| +|egg h11 |58.0 GiB| 0.01| 0.06| 0.24| 2.14| 0.14| |H48 h11 |56.5 GiB| 0.08| 0.43| 1.86| 12.20| 15.39| |vcube 404 |31.8 GiB| 0.23| 1.24| 6.10| 59.33| 268.26| -|egg h10 |29.0 GiB| 0.02| 0.10| 0.47| 4.00| 0.23| +|egg h10 |29.0 GiB| 0.02| 0.10| 0.46| 3.96| 0.24| |H48 h10 |28.3 GiB| 0.13| 0.69| 3.37| 23.15| 38.00| |vcube 308 |21.2 GiB| 0.17| 1.02| 6.20| 58.70| 604.35| -|egg h9 |14.5 GiB| 0.03| 0.19| 0.91| | | +|egg h9 |14.5 GiB| 0.03| 0.21| 0.98| | | |H48 h9 |14.1 GiB| 0.22| 1.43| 6.56| | | |vcube 208 | 7.3 GiB| 0.56| 4.36| 20.58| | | -|egg h8 | 7.2 GiB| 0.07| 0.39| 1.82| | | +|egg h8 | 7.2 GiB| 0.06| 0.36| 1.69| | | |H48 h8 | 7.1 GiB| 0.46| 3.43| 14.18| | | -|egg h7 | 3.6 GiB| 0.11| 0.81| 4.35| | | +|egg h7 | 3.6 GiB| 0.10| 0.74| 3.88| | | |H48 h7 | 3.5 GiB| 0.63| 4.84| 23.31| | | |vcube 112 | 2.4 GiB| 0.96| 9.29| 40.52| | | -|egg h6 | 1.8 GiB| 0.20| 1.53| 8.19| | | +|egg h6 | 1.8 GiB| 0.21| 1.60| 8.62| | | |H48 h6 | 1.8 GiB| 1.26| 9.51| 47.14| | | Time per cube adjusted for table size (in seconds \* GiB, lower is better). @@ -28,21 +28,21 @@ Time per cube adjusted for table size (in seconds \* GiB, lower is better). |Solver|Size|17 moves|18 moves|19 moves|20 moves|Superflip| |:-----|:---|-------:|-------:|-------:|-------:|--------:| |vcube 212 |58.2 GiB| 6.43| 43.80| 199.38| 1587.43| 1122.73| -|egg h11 |58.0 GiB| 0.55| 3.31| 13.99| 125.17| 8.04| +|egg h11 |58.0 GiB| 0.55| 3.32| 13.97| 124.06| 7.93| |H48 h11 |56.5 GiB| 4.56| 24.55| 104.96| 689.22| 869.37| |vcube 404 |31.8 GiB| 7.40| 39.47| 194.01| 1887.94| 8535.87| -|egg h10 |29.0 GiB| 0.50| 2.90| 13.69| 115.88| 6.80| +|egg h10 |29.0 GiB| 0.48| 2.85| 13.48| 114.83| 7.08| |H48 h10 |28.3 GiB| 3.62| 19.45| 95.15| 654.05| 1073.69| |vcube 308 |21.2 GiB| 3.51| 21.71| 131.50| 1245.26| 12819.94| -|egg h9 |14.5 GiB| 0.47| 2.74| 13.19| | | +|egg h9 |14.5 GiB| 0.50| 3.00| 14.22| | | |H48 h9 |14.1 GiB| 3.11| 20.18| 92.68| | | |vcube 208 | 7.3 GiB| 4.08| 31.74| 149.68| | | -|egg h8 | 7.2 GiB| 0.48| 2.82| 13.16| | | +|egg h8 | 7.2 GiB| 0.45| 2.63| 12.27| | | |H48 h8 | 7.1 GiB| 3.23| 24.26| 100.15| | | -|egg h7 | 3.6 GiB| 0.39| 2.94| 15.77| | | +|egg h7 | 3.6 GiB| 0.36| 2.69| 14.05| | | |H48 h7 | 3.5 GiB| 2.22| 17.12| 82.35| | | |vcube 112 | 2.4 GiB| 2.33| 22.53| 98.23| | | -|egg h6 | 1.8 GiB| 0.36| 2.76| 14.83| | | +|egg h6 | 1.8 GiB| 0.37| 2.89| 15.62| | | |H48 h6 | 1.8 GiB| 2.24| 16.80| 83.33| | | diff --git a/benchmarks/tables_4_threads.md b/benchmarks/tables_4_threads.md index b1bf9c5..2ca4a39 100644 --- a/benchmarks/tables_4_threads.md +++ b/benchmarks/tables_4_threads.md @@ -7,32 +7,32 @@ Time per cube (in seconds, lower is better). |:-----|:---|-------:|-------:|-------:|-------:|--------:| |egg h11 |58.0 GiB| 0.00| 0.01| 0.06| 0.55| 0.03| |H48 h11 |56.5 GiB| 0.03| 0.13| 0.50| 3.24| 4.17| -|egg h10 |29.0 GiB| 0.00| 0.03| 0.12| 1.05| 0.09| +|egg h10 |29.0 GiB| 0.00| 0.02| 0.12| 1.02| 0.09| |H48 h10 |28.3 GiB| 0.05| 0.18| 0.90| 6.21| 9.85| -|egg h9 |14.5 GiB| 0.01| 0.05| 0.23| | | +|egg h9 |14.5 GiB| 0.01| 0.05| 0.25| | | |H48 h9 |14.1 GiB| 0.07| 0.39| 1.73| 12.50| 18.97| -|egg h8 | 7.2 GiB| 0.02| 0.10| 0.48| | | +|egg h8 | 7.2 GiB| 0.02| 0.09| 0.43| | | |H48 h8 | 7.1 GiB| 0.13| 0.91| 3.71| | | -|egg h7 | 3.6 GiB| 0.03| 0.21| 1.11| | | +|egg h7 | 3.6 GiB| 0.03| 0.19| 1.08| | | |H48 h7 | 3.5 GiB| 0.18| 1.29| 6.19| | | -|egg h6 | 1.8 GiB| 0.05| 0.39| 2.11| | | +|egg h6 | 1.8 GiB| 0.05| 0.39| 2.23| | | |H48 h6 | 1.8 GiB| 0.34| 2.48| 12.33| | | Speed-up factor (higher is better). |Solver|Size|17 moves|18 moves|19 moves|20 moves|Superflip| |:-----|:---|-------:|-------:|-------:|-------:|--------:| -|egg h11 |58.0 GiB| 3.77| 3.90| 3.89| 3.93| 5.42| +|egg h11 |58.0 GiB| 3.57| 3.85| 3.72| 3.90| 5.41| |H48 h11 |56.5 GiB| 2.51| 3.44| 3.75| 3.77| 3.69| -|egg h10 |29.0 GiB| 3.88| 3.77| 3.98| 3.81| 2.72| +|egg h10 |29.0 GiB| 3.68| 4.03| 3.92| 3.89| 2.78| |H48 h10 |28.3 GiB| 2.79| 3.91| 3.75| 3.73| 3.86| -|egg h9 |14.5 GiB| 3.90| 3.87| 3.88| | | +|egg h9 |14.5 GiB| 3.80| 4.20| 3.91| | | |H48 h9 |14.1 GiB| 3.18| 3.66| 3.79| | | -|egg h8 | 7.2 GiB| 3.87| 3.91| 3.81| | | +|egg h8 | 7.2 GiB| 3.81| 4.01| 3.91| | | |H48 h8 | 7.1 GiB| 3.48| 3.78| 3.82| | | -|egg h7 | 3.6 GiB| 3.87| 3.87| 3.93| | | +|egg h7 | 3.6 GiB| 3.81| 3.88| 3.59| | | |H48 h7 | 3.5 GiB| 3.43| 3.75| 3.77| | | -|egg h6 | 1.8 GiB| 3.98| 3.90| 3.87| | | +|egg h6 | 1.8 GiB| 3.93| 4.09| 3.87| | | |H48 h6 | 1.8 GiB| 3.73| 3.84| 3.82| | | diff --git a/benchmarks/tables_all_solutions.md b/benchmarks/tables_all_solutions.md index 6535b60..e9923e7 100644 --- a/benchmarks/tables_all_solutions.md +++ b/benchmarks/tables_all_solutions.md @@ -5,22 +5,39 @@ Time per cube (in seconds, lower is better). |Solver|Size|17 moves|18 moves|19 moves|20 moves|Superflip| |:-----|:---|-------:|-------:|-------:|-------:|--------:| +|egg h11 |58.0 GiB| 0.00| 0.05| 0.54| 5.08| 15.38| |H48 h11 |56.5 GiB| 0.04| 0.24| 1.88| 3.88| 1.86| +|egg h10 |29.0 GiB| 0.01| 0.09| 1.00| 9.42| 31.05| |H48 h10 |28.3 GiB| 0.05| 0.39| 3.51| 7.54| 4.29| +|egg h9 |14.5 GiB| 0.01| 0.17| 1.97| | | |H48 h9 |14.1 GiB| 0.08| 0.73| 6.92| | | +|egg h8 | 7.2 GiB| 0.03| 0.31| 3.49| | | |H48 h8 | 7.1 GiB| 0.16| 1.54| 14.78| | | +|egg h7 | 3.6 GiB| 0.04| 0.57| 6.38| | | |H48 h7 | 3.5 GiB| 0.22| 2.37| 25.35| | | +|egg h6 | 1.8 GiB| 0.10| 1.27| 14.93| | | |H48 h6 | 1.8 GiB| 0.40| 4.58| 50.17| | | Time per cube adjusted for table size (in seconds \* GiB, lower is better). |Solver|Size|17 moves|18 moves|19 moves|20 moves|Superflip| |:-----|:---|-------:|-------:|-------:|-------:|--------:| +|egg h11 |58.0 GiB| 0.25| 2.88| 31.12| 294.67| 892.07| |H48 h11 |56.5 GiB| 2.00| 13.40| 106.21| 219.43| 105.10| +|egg h10 |29.0 GiB| 0.22| 2.58| 28.89| 273.08| 900.34| |H48 h10 |28.3 GiB| 1.45| 11.13| 99.17| 212.94| 121.20| +|egg h9 |14.5 GiB| 0.21| 2.51| 28.49| | | |H48 h9 |14.1 GiB| 1.13| 10.25| 97.80| | | +|egg h8 | 7.2 GiB| 0.18| 2.25| 25.30| | | |H48 h8 | 7.1 GiB| 1.10| 10.85| 104.41| | | +|egg h7 | 3.6 GiB| 0.16| 2.05| 23.11| | | |H48 h7 | 3.5 GiB| 0.79| 8.38| 89.57| | | +|egg h6 | 1.8 GiB| 0.18| 2.29| 27.06| | | |H48 h6 | 1.8 GiB| 0.71| 8.10| 88.68| | | + + + + + -- cgit v1.3