Look Up vs Shift on INTEL vs AMD

Discussion of chess software programming and technical issues.

Moderator: Ras

Mike Sherwin
Posts: 965
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Look Up vs Shift on INTEL vs AMD

Post by Mike Sherwin »

Are CPU's Getting Faster? (2009 AMD Phenom II vs 2018 Intel i7 8750H - Phenom 2 Benchmark)
https://www.youtube.com/watch?v=Rp6_bfZ4nuE&t=0
In the video quite a few benchmarks were performed comparing an older AMD CPU to a more modern INTEL CPU. And the older AMD CPU won some of the benchmarks. In the shifting benchmark the older AMD CPU ran circles around the newer INTEL CPU. I do not know if that has changed for the latest generation. The benchmark source is downloadable.

So the question is for the following code snippets.
AMD

Code: Select all

s32 GenMoves(Thread* t) {
  u64 fromSquares;
  u08 fs;

  fromSquares = pieceSquareBits[stm];

  do {
	fs = std::countr_zero(fromSquares);
	fromSquares ^= 1ull << fs;
	...
vs
INTEL

Code: Select all

s32 GenMoves(Thread* t) {
  u64 fromSquares;
  u08 fs;

  fromSquares = pieceSquareBits[stm];

  do {
	fs = std::countr_zero(fromSquares);
	fromSquares ^= bit[fs];
	...
I do not have the latest generation INTEL CPU. So if someone has both latest generation INTEL and AMD CPUs could they test this? Thanks! :D
Mike Sherwin
Posts: 965
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: Look Up vs Shift on INTEL vs AMD

Post by Mike Sherwin »

Zero, Zilch, Zip, None, Nil, nought, nothing, nada, scratch, diddly-squat, bupkis, bugger-all, goose egg, bagatelle, nonissue :?:
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Look Up vs Shift on INTEL vs AMD

Post by dangi12012 »

Mike Sherwin wrote: Fri Mar 04, 2022 6:26 pm Zero, Zilch, Zip, None, Nil, nought, nothing, nada, scratch, diddly-squat, bupkis, bugger-all, goose egg, bagatelle, nonissue :?:
Suggestion: You have to write a self contained file that prints the numbers you are interested in.
Ideally just share a link there: https://godbolt.org/

I have latest ryzen and mergi has a latest intel.
Then this can be answered for the current architectures amd/intel. Make sure to use volatile or store the results - or the compiler will compile everything away.

What it wont tell you is how this behaves inside a complex machinery of code - where you have other cache pressure or register shortages and the winner could change.
I will help with sharing AMD results.
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
Mike Sherwin
Posts: 965
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: Look Up vs Shift on INTEL vs AMD

Post by Mike Sherwin »

dangi12012 wrote: Fri Mar 04, 2022 7:05 pm
Mike Sherwin wrote: Fri Mar 04, 2022 6:26 pm Zero, Zilch, Zip, None, Nil, nought, nothing, nada, scratch, diddly-squat, bupkis, bugger-all, goose egg, bagatelle, nonissue :?:
Suggestion: You have to write a self contained file that prints the numbers you are interested in.
Ideally just share a link there: https://godbolt.org/

I have latest ryzen and mergi has a latest intel.
Then this can be answered for the current architectures amd/intel. Make sure to use volatile or store the results - or the compiler will compile everything away.

What it wont tell you is how this behaves inside a complex machinery of code - where you have other cache pressure or register shortages and the winner could change.
I will help with sharing AMD results.
Thanks for answering and for AMD test. I think that this is something needed to be known for bitboard engine authors. If that differential in performance still exist today then authors might want to compile different versions, one for INTEL and one for AMD.