BMI2 vs AVX2 (Stockfish versions)

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

Patishi
Posts: 20
Joined: Fri Sep 04, 2020 9:20 pm
Full name: Assaf Patishi

BMI2 vs AVX2 (Stockfish versions)

Post by Patishi »

Hi everybody,
Is there a difference between the two? Is one instruction set faster than the other?
My CPU (10900k) supports both of them.

Thx.
voffka
Posts: 288
Joined: Sat Jun 30, 2018 10:58 pm
Location: Ukraine
Full name: Volodymyr Shcherbyna

Re: BMI2 vs AVX2 (Stockfish versions)

Post by voffka »

Best way is to run stockfish bench on each of the provided exe and then choose the one with the fastest NPS.
Geonerd
Posts: 79
Joined: Fri Mar 10, 2017 1:44 am

Re: BMI2 vs AVX2 (Stockfish versions)

Post by Geonerd »

Yup. Configure your GUI to display NPS and run both executables on a given position.

You might also try some of the SF Dev compiles at https://abrok.eu/stockfish/ There has been a fair bit of code optimization since SF-12 was released.
gaard
Posts: 447
Joined: Mon Jun 07, 2010 3:13 am
Location: Holland, MI
Full name: Martin W

Re: BMI2 vs AVX2 (Stockfish versions)

Post by gaard »

Patishi wrote: Wed Jan 06, 2021 9:10 pm Hi everybody,
Is there a difference between the two? Is one instruction set faster than the other?
My CPU (10900k) supports both of them.

Thx.
I have a an i7-9750H and the AVX2 compile is approximately 3% slower for this CPU, after testing by running the benchmark 30+ times for each compile and comparing the medians and minimums using bench, with a depth of 18+. Maybe more samples are needed, but in any case, the difference is negligible in my case and seems to favor BMI2.

Edit: This was using recent dev builds from the past two week from abrok.eu
User avatar
MikeB
Posts: 4889
Joined: Thu Mar 09, 2006 6:34 am
Location: Pen Argyl, Pennsylvania

Re: BMI2 vs AVX2 (Stockfish versions)

Post by MikeB »

Patishi wrote: Wed Jan 06, 2021 9:10 pm Hi everybody,
Is there a difference between the two? Is one instruction set faster than the other?
My CPU (10900k) supports both of them.

Thx.
Generally speaking, Intel processors that support bmi2 are faster with BMI2. Current AMD processors support bmi2, but are generally faster with AVX2.

YMMV, usually not too hard to decipher, if it is hard to decipher, it is probably not that important.
Image
Raphexon
Posts: 476
Joined: Sun Mar 17, 2019 12:00 pm
Full name: Henk Drost

Re: BMI2 vs AVX2 (Stockfish versions)

Post by Raphexon »

MikeB wrote: Thu Jan 07, 2021 3:54 am
Patishi wrote: Wed Jan 06, 2021 9:10 pm Hi everybody,
Is there a difference between the two? Is one instruction set faster than the other?
My CPU (10900k) supports both of them.

Thx.
Generally speaking, Intel processors that support bmi2 are faster with BMI2. Current AMD processors support bmi2, but are generally faster with AVX2.

YMMV, usually not too hard to decipher, if it is hard to decipher, it is probably not that important.
Current (Zen3) AMD should be faster with BMI2 now that that PEXT is no longer microcoded.

Zen1/2 had microcoded PEXT which meant that what took 1 cycle for a modern Intel CPU took multiple for Zen.
Vinvin
Posts: 5228
Joined: Thu Mar 09, 2006 9:40 am
Full name: Vincent Lejeune

Re: BMI2 vs AVX2 (Stockfish versions)

Post by Vinvin »

Raphexon wrote: Thu Jan 07, 2021 8:50 am
MikeB wrote: Thu Jan 07, 2021 3:54 am
Patishi wrote: Wed Jan 06, 2021 9:10 pm Hi everybody,
Is there a difference between the two? Is one instruction set faster than the other?
My CPU (10900k) supports both of them.

Thx.
Generally speaking, Intel processors that support bmi2 are faster with BMI2. Current AMD processors support bmi2, but are generally faster with AVX2.

YMMV, usually not too hard to decipher, if it is hard to decipher, it is probably not that important.
Current (Zen3) AMD should be faster with BMI2 now that that PEXT is no longer microcoded.

Zen1/2 had microcoded PEXT which meant that what took 1 cycle for a modern Intel CPU took multiple for Zen.
Here are the instruction comparison between Zen 2 with Zen 3

https://www.anandtech.com/show/16214/am ... x-tested/6

Code: Select all

		Zen2 			Zen 3
PDEP/PEXT 	300 cycle latency	3 cycle latency
		250 cycles per 1 	1 per clock
Patishi
Posts: 20
Joined: Fri Sep 04, 2020 9:20 pm
Full name: Assaf Patishi

Re: BMI2 vs AVX2 (Stockfish versions)

Post by Patishi »

Interesting replies guys, thx.
I personally use Dragon (formerly: Komodo) and it actually comes only with AVX2 version (despite Komodo 14 came with both), I wonder why.
Dann Corbit
Posts: 12537
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

Re: BMI2 vs AVX2 (Stockfish versions)

Post by Dann Corbit »

Patishi wrote: Thu Jan 07, 2021 7:17 pm Interesting replies guys, thx.
I personally use Dragon (formerly: Komodo) and it actually comes only with AVX2 version (despite Komodo 14 came with both), I wonder why.
Probably testing.
If I have 4 binaries produced, it takes four times as long to test as if I have 1.
So the count of executables produced will be a function of hardware and time needed to complete the testing cycle.

Where I work, we support a huge number of targets.
We have a large server room packed with servers with many hundreds of virtual machines.
It takes two weeks to complete one test cycle.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.