A perft() benchmark

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

syzygy
Posts: 5566
Joined: Tue Feb 28, 2012 11:56 pm

Re: A perft() benchmark

Post by syzygy »

My dedicated perft with a single thread on my i7-3930K clocked at 4.2Ghz, no hashing, no bulk counting:

Code: Select all

perft[ 1] =           20 (  0:00.000)
perft[ 2] =          400 (  0:00.000)
perft[ 3] =         8902 (  0:00.000)
perft[ 4] =       197281 (  0:00.006)
perft[ 5] =      4865609 (  0:00.079)
perft[ 6] =    119060324 (  0:01.971)
perft[ 7] =   3195901860 (  0:54.397)
perft[ 8] =  84998978956 ( 23:44.442)
Using bulk counting at penultimate nodes (generating all legal moves but not making them), no hashing:

Code: Select all

perft[ 1] =           20 (  0:00.000)
perft[ 2] =          400 (  0:00.000)
perft[ 3] =         8902 (  0:00.000)
perft[ 4] =       197281 (  0:00.000)
perft[ 5] =      4865609 (  0:00.013)
perft[ 6] =    119060324 (  0:00.348)
perft[ 7] =   3195901860 (  0:09.040)
perft[ 8] =  84998978956 (  4:07.138)
Just counting the legal moves but not generating them, no hashing:

Code: Select all

perft[ 1] =           20 (  0:00.000)
perft[ 2] =          400 (  0:00.000)
perft[ 3] =         8902 (  0:00.000)
perft[ 4] =       197281 (  0:00.000)
perft[ 5] =      4865609 (  0:00.007)
perft[ 6] =    119060324 (  0:00.195)
perft[ 7] =   3195901860 (  0:04.996)
perft[ 8] =  84998978956 (  2:14.811)
User avatar
sje
Posts: 4675
Joined: Mon Mar 13, 2006 7:43 pm

And by a 400 MHz PowerPC G3 iMac (32 bit CPU)

Post by sje »

Code: Select all

4k3/8/8/8/8/8/8/2B1K1N1 w - - 0 1

CountStTran(0): 1   Time: 5e-06   Frequency: 200000   Period: 5e-06
CountStTran(1): 15   Time: 0.000167   Frequency: 89820.4   Period: 1.11333e-05
CountStTran(2): 70   Time: 0.012437   Frequency: 5628.37   Period: 0.000177671
CountStTran(3): 1126   Time: 0.000737   Frequency: 1.52782e+06   Period: 6.54529e-07
CountStTran(4): 7069   Time: 0.007967   Frequency: 887285   Period: 1.12703e-06
CountStTran(5): 121591   Time: 0.03251   Frequency: 3.74011e+06   Period: 2.67372e-07
CountStTran(6): 728515   Time: 0.20943   Frequency: 3.47856e+06   Period: 2.87475e-07
CountStTran(7): 13010270   Time: 0.656827   Frequency: 1.98078e+07   Period: 5.04853e-08
CountStTran(8): 78914750   Time: 2.35843   Frequency: 3.34607e+07   Period: 2.98858e-08
CountStTran(9): 1448351327   Time: 4.85191   Frequency: 2.98512e+08   Period: 3.34995e-09
CountStTran(10): 8583115076   Time: 14.4801   Frequency: 5.92751e+08   Period: 1.68705e-09
CountStTran(11): 160513009138   Time: 25.2405   Frequency: 6.35934e+09   Period: 1.57249e-10
CountStTran(12): 947545558390   Time: 59.0957   Frequency: 1.60341e+10   Period: 6.23672e-11
CountStTran(13): 17969131498488   Time: 88.5454   Frequency: 2.02937e+11   Period: 4.92764e-12
CountStTran(14): 104926329378972   Time: 179.406   Frequency: 5.84856e+11   Period: 1.70982e-12
CountStTran(15): 2010152142207489   Time: 244.06   Frequency: 8.2363e+12   Period: 1.21414e-13
CountStTran(16): 11686896891512132   Time: 446.874   Frequency: 2.61525e+13   Period: 3.82372e-14
CountStTran(17): 225612503091560845   Time: 586.991   Frequency: 3.84354e+14   Period: 2.60177e-15
CountStTran(18): 1303979974064296836   Time: 1009.92   Frequency: 1.29117e+15   Period: 7.74489e-16
CountStTran(19): 6870327054505601489   Time: 1634.03   Frequency: 4.20453e+15   Period: 2.37839e-16
ankan
Posts: 77
Joined: Sun Apr 21, 2013 3:29 pm
Full name: Ankan Banerjee

Re: A perft() benchmark

Post by ankan »

k7/8/8/8/8/8/8/7K w - - 0 1

Code: Select all

GPU Perft 1: 3,   Time taken: 1.6736e-005 seconds, nps: 179254

GPU Perft 2: 9,   Time taken: 0.000101344 seconds, nps: 88806

GPU Perft 3: 54,   Time taken: 0.000139136 seconds, nps: 388109

GPU Perft 4: 324,   Time taken: 0.000271936 seconds, nps: 1191456

GPU Perft 5: 1890,   Time taken: 0.000374208 seconds, nps: 5050666

GPU Perft 6: 11024,   Time taken: 0.000495904 seconds, nps: 22230109

GPU Perft 7: 71758,   Time taken: 0.00056976 seconds, nps: 125944251

GPU Perft 8: 466210,   Time taken: 0.000748768 seconds, nps: 622636140

GPU Perft 9: 3083208,   Time taken: 0.002164 seconds, nps: 1424772620

GPU Perft 10: 20296614,   Time taken: 0.0112038 seconds, nps: 1811581768

GPU Perft 11: 137688284,   Time taken: 0.0717821 seconds, nps: 1918143629

GPU Perft 12: 928817526,   Time taken: 0.473202 seconds, nps: 1962835056

k7/8/8/8/8/8/8/2B1K1N1 w - - 0 1

Code: Select all

GPU Perft 1: 15,   Time taken: 2.08e-005 seconds, nps: 721153

GPU Perft 2: 43,   Time taken: 0.000125824 seconds, nps: 341747

GPU Perft 3: 686,   Time taken: 0.00017872 seconds, nps: 3838406

GPU Perft 4: 3959,   Time taken: 0.0004032 seconds, nps: 9818948

GPU Perft 5: 67777,   Time taken: 0.00075392 seconds, nps: 89899456

GPU Perft 6: 364461,   Time taken: 0.000769984 seconds, nps: 473335805

GPU Perft 7: 6510273,   Time taken: 0.00176938 seconds, nps: 3679417407

GPU Perft 8: 38575135,   Time taken: 0.0174782 seconds, nps: 2207037841

GPU Perft 9: 711141935,   Time taken: 0.123105 seconds, nps: 5776692709


4k3/8/8/8/8/8/8/2B1K1N1 w - - 0 1

Code: Select all

GPU Perft 1: 15,   Time taken: 1.9264e-005 seconds, nps: 778654

GPU Perft 2: 70,   Time taken: 0.000115968 seconds, nps: 603614

GPU Perft 3: 1126,   Time taken: 0.00016336 seconds, nps: 6892752

GPU Perft 4: 7069,   Time taken: 0.00037104 seconds, nps: 19051854

GPU Perft 5: 121591,   Time taken: 0.000713504 seconds, nps: 170413897

GPU Perft 6: 728515,   Time taken: 0.000814688 seconds, nps: 894225735

GPU Perft 7: 13010270,   Time taken: 0.00299888 seconds, nps: 4338376458

GPU Perft 8: 78914750,   Time taken: 0.0306436 seconds, nps: 2575240050

GPU Perft 9: 1448351327,   Time taken: 0.230341 seconds, nps: 6287868820

GPU Perft 10: 8583115076,   Time taken: 3.16129 seconds, nps: 2715063902

GPU Perft 11: 160513009138,   Time taken: 24.2933 seconds, nps: 6607299428
User avatar
Ajedrecista
Posts: 1971
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

Re: KBNk ---> perft(20) result.

Post by Ajedrecista »

Hello:
Ajedrecista wrote:

Code: Select all

perft(20) = 1,285,783,583,762,534,722 + 4*[2^(-64)] = 75,072,759,878,600,741,186
I made a mistake in the copy and paste: it is not 2^(-64) but 2^(64). The result is well calculated. Here is the correction:

Code: Select all

perft(20) = 1,285,783,583,762,534,722 + 4*[2^(64)] = 75,072,759,878,600,741,186
I am quite sure of this result, but of course independent corroboration would be fine. Are you here, Paul? :wink:

Regards from Spain.

Ajedrecista.
ibid
Posts: 89
Joined: Mon Jun 13, 2011 12:09 pm

Re: KBNk ---> perft(20) result.

Post by ibid »

Ajedrecista wrote:

Code: Select all

perft(20) = 1,285,783,583,762,534,722 + 4*[2^(64)] = 75,072,759,878,600,741,186
I am quite sure of this result, but of course independent corroboration would be fine. Are you here, Paul?
I don't have anything that can handle over 64 bits on hand right now, but...

Code: Select all

gperft 1.0 by Paul Byrne
Depth is 20.

k-------
--------
--------
--------  w - -
--------
--------
--------
--B-K-N-

Ne2        5,413,637,977,425,633,758
Nf3        7,943,137,449,825,604,502
Nh3        5,179,627,520,227,528,635
Bb2        7,381,849,532,908,251,042
Bd2        4,308,176,281,282,487,428
Ba3        3,789,314,683,705,030,887
Be3        2,998,731,023,870,432,062
Bf4        3,123,318,871,803,074,928
Bg5        5,178,532,290,991,801,515
Bh6        4,542,810,120,280,543,237
Kd1        4,009,569,653,362,539,651
Kf1        4,299,702,185,286,081,370
Kd2        4,047,788,944,120,303,364
Ke2        6,100,661,826,137,759,280
Kf2        6,755,901,517,373,669,527
TOTAL      1,285,783,583,762,534,722
9.269 seconds
The numbers for the divide are all safely under 64 bits and do indeed add up to 75,072,759,878,600,741,186.

gperft is a pretty conventional program with hash tables and such... the unique positions approach on the other hand would only be limited by the memory requirements for very high bit integers since the number of unique positions is quite limited here. I am not curious enough to see perft(1000) to code it though. :)

-paul
ibid
Posts: 89
Joined: Mon Jun 13, 2011 12:09 pm

Re: A perft() benchmark

Post by ibid »

syzygy wrote:My dedicated perft with a single thread on my i7-3930K clocked at 4.2Ghz
[...]
Just counting the legal moves but not generating them, no hashing:

Code: Select all

perft[ 1] =           20 (  0:00.000)
perft[ 2] =          400 (  0:00.000)
perft[ 3] =         8902 (  0:00.000)
perft[ 4] =       197281 (  0:00.000)
perft[ 5] =      4865609 (  0:00.007)
perft[ 6] =    119060324 (  0:00.195)
perft[ 7] =   3195901860 (  0:04.996)
perft[ 8] =  84998978956 (  2:14.811)
That is quite impressive! I know the fast cpu accounts for some of the difference, but that is a good bit quicker than I can manage.

-paul
ibid
Posts: 89
Joined: Mon Jun 13, 2011 12:09 pm

Re: A perft() benchmark

Post by ibid »

A couple of other positions -- I am impatient so these were done with 6 cores and 6 GB of hash table:

wild8 for lots of captures and a larger branching factor:
[d]rnbqkbnr/8/8/pppppppp/PPPPPPPP/8/8/RNBQKBNR w KQkq -

Code: Select all

 1                   41    0.000
 2                1,668    0.000
 3               68,883    0.000
 4            2,821,232    0.006
 5          116,772,850    0.058
 6        4,797,868,823    0.609
 7      198,696,469,550    9.852
 8    8,174,474,864,714  153.196
 9  338,396,048,995,491 2968.295
and wild5 for lots of promotions:
[d]RNBKQBNR/PPPPPPPP/8/8/8/8/pppppppp/rnbkqbnr w - -

Code: Select all

 1                     4    0.000
 2                    16    0.000
 3                   176    0.000
 4                 1,936    0.000
 5                22,428    0.000
 6               255,135    0.000
 7             3,830,854    0.002
 8            57,392,030    0.015
 9           983,907,388    0.120
10        16,863,104,086    1.079
11       337,294,265,604    9.263
12     6,765,550,514,435   86.897
13   153,154,247,599,787  957.231
-paul
User avatar
Ajedrecista
Posts: 1971
Joined: Wed Jul 13, 2011 9:04 pm
Location: Madrid, Spain.

Re: KBNk ---> perft(20) result.

Post by Ajedrecista »

Hi Paul:
ibid wrote:
Ajedrecista wrote:

Code: Select all

perft(20) = 1,285,783,583,762,534,722 + 4*[2^(64)] = 75,072,759,878,600,741,186
I am quite sure of this result, but of course independent corroboration would be fine. Are you here, Paul?
I don't have anything that can handle over 64 bits on hand right now, but...

Code: Select all

gperft 1.0 by Paul Byrne
Depth is 20.

k-------
--------
--------
--------  w - -
--------
--------
--------
--B-K-N-

Ne2        5,413,637,977,425,633,758
Nf3        7,943,137,449,825,604,502
Nh3        5,179,627,520,227,528,635
Bb2        7,381,849,532,908,251,042
Bd2        4,308,176,281,282,487,428
Ba3        3,789,314,683,705,030,887
Be3        2,998,731,023,870,432,062
Bf4        3,123,318,871,803,074,928
Bg5        5,178,532,290,991,801,515
Bh6        4,542,810,120,280,543,237
Kd1        4,009,569,653,362,539,651
Kf1        4,299,702,185,286,081,370
Kd2        4,047,788,944,120,303,364
Ke2        6,100,661,826,137,759,280
Kf2        6,755,901,517,373,669,527
TOTAL      1,285,783,583,762,534,722
9.269 seconds
The numbers for the divide are all safely under 64 bits and do indeed add up to 75,072,759,878,600,741,186.

gperft is a pretty conventional program with hash tables and such... the unique positions approach on the other hand would only be limited by the memory requirements for very high bit integers since the number of unique positions is quite limited here. I am not curious enough to see perft(1000) to code it though. :)

-paul
Thanks for your reply. I think that the output of JetChess was exactly the same than gperft output, but I did not want to directly sum all the fifteen draft 19 results just in case of possible overflows in some of them.

gperft is insanely fast. I wait impatiently for its release. :)

Regards from Spain.

Ajedrecista.
ibid
Posts: 89
Joined: Mon Jun 13, 2011 12:09 pm

Re: KBNk ---> perft(20) result.

Post by ibid »

Ajedrecista wrote:gperft is insanely fast. I wait impatiently for its release. :)
I think I am going to be disappointing you here... I did manage to get it compiled for 32 bit windows, but on a couple of test positions it took almost three times longer than the 64 bit version. So I am not planning on releasing anything but the 64 bit one at this point...

-paul
syzygy
Posts: 5566
Joined: Tue Feb 28, 2012 11:56 pm

Re: A perft() benchmark

Post by syzygy »

ibid wrote:
syzygy wrote:My dedicated perft with a single thread on my i7-3930K clocked at 4.2Ghz
[...]
Just counting the legal moves but not generating them, no hashing:

Code: Select all

perft[ 1] =           20 (  0:00.000)
perft[ 2] =          400 (  0:00.000)
perft[ 3] =         8902 (  0:00.000)
perft[ 4] =       197281 (  0:00.000)
perft[ 5] =      4865609 (  0:00.007)
perft[ 6] =    119060324 (  0:00.195)
perft[ 7] =   3195901860 (  0:04.996)
perft[ 8] =  84998978956 (  2:14.811)
That is quite impressive! I know the fast cpu accounts for some of the difference, but that is a good bit quicker than I can manage.
Do you also count moves with popcnt instead of serialising the bitboard into moves?