17 753 889 197 660 635 632
YouTube video explaining the method to achieve the enumeration. manuscript presentation slides
This number has been confirmed by completing the enumeration twice using hundreds of GPUs provided at cloud resource rental services. Though the number and models of GPUs used varied over time, the initial enumeration took about 80,000 hours of GeForce RTX-4090 and the second enumeration with an improved code took about 54,000 hours.
As the result of the second enumeration, the initial result 17 753 889 189 701 384 304 obtained in July 2023 was found to be incorrect. More details of the errors are in the next section.
The result is consistent with stochastic estimates 1.8(2)・1019[1], 1.7745(16)·1019[2], 1.775392(12)·1019[3] and 1.77543(73)·1019[4].
More than a thousand of instances of GPU server were used in the enumeration and some of them were unfortunately faulty and produced wrong results. To find and correct such errors, every subtotal was calculated at least twice and extra counting was done to determine the correct answer when a mismatch happened. There were following two cases where the initial result was incorrect.
During the thorough double-check, it was discovered that a portion of the results generated by an instance was incorrect. The instance ran with two RTX-4090s for 60 hours and generated 3,771 sub-subtotals. Out of those sub-subtotals, 12 were incorrect and all incorrect results were generated by only one of the two RTX-4090s. It is unlikely that these errors are due to logical flaws or coding mistakes. Hardware failures are suspected.
As the result of the correction, the number increased by 960(40×24).
Another erroneous instance was found. It ran with an RTX-4090 for about one month and produced about 19,000 sub-subtotals. Out of those sub-subtotals, 6 were incorrect. All of the incorrect results were produced in the last one hour of the lifetime of the instance. After the erroneous behavior, the GPU of the instance became unusable with an error message of “invalid memory access”.
As the result of the correction, the number increased by 7 959 250 368 (331 635 432 x24).
Since the number is too huge to count in a single task, the entire task is divided into numerous small sub-tasks. Counts for the sub-tasks are available.
Strategies in counting magic squares
CUDA code (corrected on 2023.11.28 and updated on 2024.05.04)
nvcc -O3 -arch=sm_60 -maxrregcount=40 -Wno-deprecated-declarations ms.cu -lcrypto -DnoMD5 and drop -Wno-deprecated-declarations and -lcrypto.-DN=order../a.out./a.out dummy representative_magic_series_in_hex ./a.out dummy1 representative_magic_series_in_hex dummy2 2nd_largest_magic_series_in_hex Non-CUDA code in C using pthread (updated on 2023.09.18)
gcc -O3 -DNTH=number_of_threads ms.c -lpthread -lcrypto-DnoMD5 and -DN=order have the same effects as in the Cuda code.The latest code used in the second enumeration counted semi-magic squares besides magic squares and produced the same result as discovered by a very different approach of A. Ripatti[5]. This match is considered as a cross verification of the counting method and of computing resources used in the calculation. All subtotals of semi-magic (including magic) squares are available.
I would like to thank Walter Trump for his discussion, suggestion, and encouragement. He reviewed my method and verified a part of my result using his own code. He suggested me to count semi-magic squares in the second enumeration and encouraged me to complete my work. Visit his website Notes on Magic Squares and Cubes, which is a good summary of magic square related topics.