magic bitboard perft

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
xr_a_y
Posts: 1871
Joined: Sat Nov 25, 2017 2:28 pm
Location: France

Re: magic bitboard perft

Post by xr_a_y »

Without bulk counting, nor hash, mperft runs perft 7 in 101 secondes with make it in the same speed category as what is discuss on the other thread (http://talkchess.com/forum3/viewtopic.p ... 20#p838238)
User avatar
mvanthoor
Posts: 1784
Joined: Wed Jul 03, 2019 4:42 pm
Location: Netherlands
Full name: Marcel Vanthoor

Re: magic bitboard perft

Post by mvanthoor »

xr_a_y wrote: Sat Apr 11, 2020 9:25 pm Without bulk counting, nor hash, mperft runs perft 7 in 101 secondes with make it in the same speed category as what is discuss on the other thread (http://talkchess.com/forum3/viewtopic.p ... 20#p838238)
That doesn't seem to be especially fast. At this point, Rustic runs perft 7 at 88-90 seconds (at a speed of 35.6 million leaves/s on average; 88 seconds for the GNU toolchain compile, 90 seconds for the MSVC toolchain) on a i7-6700K, without bulk counting, without hash, but WITH incremental updates of Zobrist key, piece list, and material count.

I think I'm going to do as I said; copy Rustic to a new repository and strip everything regarding piece lists and material from it. (Actually, I'll remove everything that's not strictly necessary for perft, and create my own perft tool.) I'll keep the Zobrist hash so I can add the hash table back in. Then I'll be able to compare "RPerft", "MPerft" and "QPerft" on the same system.
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL
User avatar
leanchess
Posts: 176
Joined: Sun Dec 08, 2019 8:16 pm
Full name: Dmitry Shechtman

Re: magic bitboard perft

Post by leanchess »

If you're measuring pure perft performance, you might also add "pperft" to that list, a parallelised version of my implementation. The result is still about 1M leaves off, but it does 12 seconds (without hashing or bulk counting) on my hyperthreaded laptop.
NaltaP312
Posts: 56
Joined: Wed Oct 29, 2008 1:06 pm
Full name: Marc Paule

Re: magic bitboard perft

Post by NaltaP312 »

Hi,
a good example without Hash is xiphos code:
if you want the best perft try xiphos or cfish.
xiphos perft 6 = 119060324 for 1176ms nps 101155755 and perft 7 in 30 seconds.
cfish perft 6 = 119060324 for 2128ms nps 55949400
may be sungorus is better to or near xiphos but there is no perft function.

under linux material teclast f6 intel apollo lake processor 2.2ghz
Regards
Naltap
User avatar
leanchess
Posts: 176
Joined: Sun Dec 08, 2019 8:16 pm
Full name: Dmitry Shechtman

Re: magic bitboard perft

Post by leanchess »

NaltaP312 wrote: Sun Apr 12, 2020 8:57 am if you want the best perft try xiphos or cfish.
xiphos perft 6 = 119060324 for 1176ms nps 101155755 and perft 7 in 30 seconds.
cfish perft 6 = 119060324 for 2128ms nps 55949400
How can cfish be the best with these timings? Even my broken single-threaded perft does 80000000 nps.
abulmo2
Posts: 433
Joined: Fri Dec 16, 2016 11:04 am
Location: France
Full name: Richard Delorme

Re: magic bitboard perft

Post by abulmo2 »

xr_a_y wrote: Sat Apr 11, 2020 8:31 pm both compile with -O3 -march=native -DNDEBUG
Please, use the makefile. You missed a few optimizations (popcount, gcc intrinsics, etc.)
Richard Delorme
User avatar
leanchess
Posts: 176
Joined: Sun Dec 08, 2019 8:16 pm
Full name: Dmitry Shechtman

Re: magic bitboard perft

Post by leanchess »

@abulmo2 Very impressive implementation, clean and readable code.

Now, I'm trying to add parallelism. As a first step I just copied the div loop from main() and pasted it into a function as follows:

Code: Select all

uint64_t pperft(Board *board, HashTable *hashtable, int depth, bool bulk, bool capture) {
	Move move;
	MoveArray ma[1];
	unsigned long long count, total = 0;
	movearray_generate(ma, board, !capture);
	while ((move = movearray_next(ma)) != 0) {
		board_update(board, move);
			count = depth <= 1 ? 1 : perft(board, hashtable, depth - 1, bulk, !capture);
			total += count;
		board_restore(board, move);
	}
	return total;
}
Calling it instead of perft() works fine, but only as long as there is no hashing. As soon as I run it with hashing enabled, the results are all wrong starting at perft(4). Could you please tell me why?
NaltaP312
Posts: 56
Joined: Wed Oct 29, 2008 1:06 pm
Full name: Marc Paule

Re: magic bitboard perft

Post by NaltaP312 »

With Mperft i have
Magic Perft (c) version 1.0 Richard Delorme - 2020
Bitboard move generation based on magic bitboards
Perft setting: no hashing; no bulk counting;
a b c d e f g h
8 r n b q k b n r 8
7 p p p p p p p p 7
6 . . . . . . . . 6
5 . . . . . . . . 5
4 . . . . . . . . 4
3 . . . . . . . . 3
2 P P P P P P P P 2
1 R N B Q K B N R 1
a b c d e f g h
w, KQkq
perft 1
perft 6 : 119060324 leaves in 8.813 s 13509858 leaves/s
@leanchess: @ second perft 6 is not so bad on my configuration:
techlast f7 with
CPU Clock speed – Quad Core 1.1GHz up to 2.2GHz CPU clock
Chipset – Intel Celeron N3450, 64-bit Processor
abulmo2
Posts: 433
Joined: Fri Dec 16, 2016 11:04 am
Location: France
Full name: Richard Delorme

Re: magic bitboard perft

Post by abulmo2 »

leanchess wrote: Sat Apr 11, 2020 2:25 pm
mvanthoor wrote: Sat Apr 11, 2020 2:15 pm Thanks :) I'll have to test this... a claim that it is twice as fast as QPerft (so 50% of time taken) and even 90% faster than QPerft is... dangerous. QPerft has been the benchmark for a LONG time if I remember correctly.
There is an old thread somewhere around here where another implementation is confirmed to be at least x3 faster than qperft.
In any case, this one does perft(7) in about 12 seconds on my machine (with bulk counting, of course).
I do not claim to have the fastest implementation. gperft by Paul Byrne is faster, for example.
Richard Delorme
NaltaP312
Posts: 56
Joined: Wed Oct 29, 2008 1:06 pm
Full name: Marc Paule

Re: magic bitboard perft

Post by NaltaP312 »

Yes i have done comparaison just to compare, sorry if this is take for other things.
i don't found gperft for linux on google, if you have a link i will take it
Thanks