This is an old revision of the document!
Table of Contents
The number of magic squares of order six counted up to rotations and reflections.
- nms6.txt
17 753 889 189 701 384 304
This result is consistent with stochastic estimates 1.7745(16)·1019[1] and 1.775392(12)·1019[2].
Using hundreds of GPUs at cloud resource rental services, it took about six months to complete the counting, Though the number and models of GPUs used at a moment were varying from time to time, the total computation time amounts to about 80,000 hours of GeForce RTX-4090.
Because of the extraordinary volume of the calculation, it is not easy to deny a possibility the result is contaminated by accidental errors. I have done moderate cross-check trying to exclude such errors and am in the course of a full cross-check. I would appreciate confirmations or disputes by others.
- K. Pinn and C. Wieczerkowski, Number of Magic Squares From Parallel Tempering Monte Calrlo, International Journal of Modern Physics C, 9 April 1998.
Subsets and subtotals
Since the number is too huge to count in one task, the whole task is divided into many small sub-tasks. Counts for the sub-tasks are available.
- List of subsubtotals (234MBytes .gz)
Codes
Strategies in counting magic squares
- Counts magic squares of an order 3..6 up to M-transformations.
- Runs at a typical speed of 2.5G counts/sec on Nvidia GeForce RTX-4090 for order 6.
- Nvidia GPU of Pascal architecture (sm_60) or newer is assumed.
- Multi GPU systems are supported. Be cautious, however, when you use a multi-4090 system .
- Compiling and linking:
nvcc -O3 -arch=sm_60 -maxrregcount=40 -Wno-deprecated-declarations ms.cu -lcrypto- If you don't need md5 checksums, add
-DnoMD5and drop-Wno-deprecated-declarationsand-lcrypto.
- For orders less than 6, specify the order by a compiler option
-DN=order. - The executable takes 0, 2, or 4 parameters. The 1st and the 3rd parameters are just place holders.
./a.out
counts all magic squares./a.out dummy representative_magic_series_in_hex
counts magic squares whose representative magic series is equal to a given hex number../a.out dummy1 representative_magic_series_in_hex dummy2 2nd_largest_magic_series_in_hex
counts magic squares whose representative magic series and the 2nd magic series parallel to the representative are as specified.- The code doesn't check the validity of parameters given by users. Invalid parameters will result in a wrong answer or a runtime error.
Non-CUDA code in C using pthread
- Compiling and linking:
gcc -O3 -DNTH=number_of_threads ms.c -lpthread -lcrypto - Options
-DnoMD5and-DN=orderhave the same effects as in the Cuda code. - Much slower than the CUDA code, but easier to read.
