BMI2 vs AVX2 (Stockfish versions)

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

Moderators: hgm, Dann Corbit, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Post Reply
Patishi
Posts: 20
Joined: Fri Sep 04, 2020 7:20 pm
Full name: Assaf Patishi

BMI2 vs AVX2 (Stockfish versions)

Post by Patishi » Wed Jan 06, 2021 8: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.

voffka
Posts: 186
Joined: Sat Jun 30, 2018 8:58 pm
Location: Ukraine
Full name: Volodymyr Shcherbyna
Contact:

Re: BMI2 vs AVX2 (Stockfish versions)

Post by voffka » Thu Jan 07, 2021 12:54 am

Best way is to run stockfish bench on each of the provided exe and then choose the one with the fastest NPS.

Geonerd
Posts: 77
Joined: Fri Mar 10, 2017 12:44 am

Re: BMI2 vs AVX2 (Stockfish versions)

Post by Geonerd » Thu Jan 07, 2021 1:49 am

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: 330
Joined: Mon Jun 07, 2010 1:13 am
Location: Holland, Michigan
Full name: Martin Wyngaarden

Re: BMI2 vs AVX2 (Stockfish versions)

Post by gaard » Thu Jan 07, 2021 2:36 am

Patishi wrote:
Wed Jan 06, 2021 8: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: 4647
Joined: Thu Mar 09, 2006 5:34 am
Location: Pen Argyl, Pennsylvania

Re: BMI2 vs AVX2 (Stockfish versions)

Post by MikeB » Thu Jan 07, 2021 2:54 am

Patishi wrote:
Wed Jan 06, 2021 8: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: 369
Joined: Sun Mar 17, 2019 11:00 am
Full name: Henk Drost

Re: BMI2 vs AVX2 (Stockfish versions)

Post by Raphexon » Thu Jan 07, 2021 7:50 am

MikeB wrote:
Thu Jan 07, 2021 2:54 am
Patishi wrote:
Wed Jan 06, 2021 8: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: 4922
Joined: Thu Mar 09, 2006 8:40 am
Full name: Vincent Lejeune

Re: BMI2 vs AVX2 (Stockfish versions)

Post by Vinvin » Thu Jan 07, 2021 12:50 pm

Raphexon wrote:
Thu Jan 07, 2021 7:50 am
MikeB wrote:
Thu Jan 07, 2021 2:54 am
Patishi wrote:
Wed Jan 06, 2021 8: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 7:20 pm
Full name: Assaf Patishi

Re: BMI2 vs AVX2 (Stockfish versions)

Post by Patishi » Thu Jan 07, 2021 6: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.

Dann Corbit
Posts: 12040
Joined: Wed Mar 08, 2006 7:57 pm
Location: Redmond, WA USA
Contact:

Re: BMI2 vs AVX2 (Stockfish versions)

Post by Dann Corbit » Thu Jan 07, 2021 7:13 pm

Patishi wrote:
Thu Jan 07, 2021 6: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.

Post Reply