AVX 512

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

Moderator: Ras

Werewolf
Posts: 2082
Joined: Thu Sep 18, 2008 10:24 pm
Full name: Carl Bicknell

AVX 512

Post by Werewolf »

Can SF use this?

It's incoming on Emerald Rapids.
Jouni
Posts: 3830
Joined: Wed Mar 08, 2006 8:15 pm
Full name: Jouni Uski

Re: AVX 512

Post by Jouni »

Of course. In prerelease:
stockfish-windows-x86-64-avx512.zip :)
Jouni
User avatar
Eelco de Groot
Posts: 4698
Joined: Sun Mar 12, 2006 2:40 am
Full name:   Eelco de Groot

Re: AVX 512

Post by Eelco de Groot »

There is every chance your Xeon processor, if you have that, already supports AVX 512 if you have a Xeon from 2016 onwards. But Intel tried to do without it on Alder Lake processors, for mysterious reasons. A strange war started between Motherboard builders that enabled the Alder Lake AVX code again on their motherboards, with Intel then counteracting that. I just read that, don't know anything more about it. But if you have an Alder Lake CPU then it depends on version numbers and motherboard if you can use it.

https://www.tomshardware.com/news/how-t ... ve-avx-512

More about AVX 512:

https://en.wikipedia.org/wiki/AVX-512
Debugging is twice as hard as writing the code in the first
place. Therefore, if you write the code as cleverly as possible, you
are, by definition, not smart enough to debug it.
-- Brian W. Kernighan
Werewolf
Posts: 2082
Joined: Thu Sep 18, 2008 10:24 pm
Full name: Carl Bicknell

Re: AVX 512

Post by Werewolf »

Jouni wrote: Sat Jan 06, 2024 11:05 pm Of course. In prerelease:
stockfish-windows-x86-64-avx512.zip :)
Wonderful. Do you have any estimate of speed up this gives?
Werewolf
Posts: 2082
Joined: Thu Sep 18, 2008 10:24 pm
Full name: Carl Bicknell

Re: AVX 512

Post by Werewolf »

Eelco de Groot wrote: Sat Jan 06, 2024 11:31 pm There is every chance your Xeon processor, if you have that, already supports AVX 512 if you have a Xeon from 2016 onwards. But Intel tried to do without it on Alder Lake processors, for mysterious reasons. A strange war started between Motherboard builders that enabled the Alder Lake AVX code again on their motherboards, with Intel then counteracting that. I just read that, don't know anything more about it. But if you have an Alder Lake CPU then it depends on version numbers and motherboard if you can use it.

https://www.tomshardware.com/news/how-t ... ve-avx-512

More about AVX 512:

https://en.wikipedia.org/wiki/AVX-512
My last Xeon was a 2697 Ivy Bridge. ☹️
Jouni
Posts: 3830
Joined: Wed Mar 08, 2006 8:15 pm
Full name: Jouni Uski

Re: AVX 512

Post by Jouni »

Speedup estimate 0 to 2% only :( . Ipman has some values for Ryzens.
Jouni
petero2
Posts: 734
Joined: Mon Apr 19, 2010 7:07 pm
Location: Sweden
Full name: Peter Osterlund

Re: AVX 512

Post by petero2 »

On my Ryzen 9 (zen4) I get no speedup for Stockfish from using AVX-512. I compiled myself from current git, using architectures x86-64-bmi2, x86-64-vnni512 and x86-64-avx512. The bmi2 version (which implies AVX-2) was actually faster than the AVX-512 versions. I compiled like this:

make -j16 build COMP=clang ARCH=x86-64-vnni512

I also tried gcc, which similar result.

Maybe other compiler flags are needed, but at least "perf top" shows that AVX-512 registers are used for the AVX-512 compiled versions. It just does not run any faster.

When I try the same thing using Texel, I get around 8% speedup from AVX-512 + VNNI.

I find this surprising, since Stockfish uses much larger nets than Texel does, so I would have thought it had more opportunities to utilize AVX-512 instructions.

My system is Ubuntu 22.04 with gcc 11.4.0 and clang 14.0.0.
Magnum
Posts: 195
Joined: Thu Feb 04, 2021 10:24 pm
Full name: Arnold Magnum

Re: AVX 512

Post by Magnum »

petero2 wrote: Sun Jan 07, 2024 1:36 pm On my Ryzen 9 (zen4) I get no speedup for Stockfish from using AVX-512. I compiled myself from current git, using architectures x86-64-bmi2, x86-64-vnni512 and x86-64-avx512. The bmi2 version (which implies AVX-2) was actually faster than the AVX-512 versions. I compiled like this:

make -j16 build COMP=clang ARCH=x86-64-vnni512

I also tried gcc, which similar result.

Maybe other compiler flags are needed, but at least "perf top" shows that AVX-512 registers are used for the AVX-512 compiled versions. It just does not run any faster.

When I try the same thing using Texel, I get around 8% speedup from AVX-512 + VNNI.

I find this surprising, since Stockfish uses much larger nets than Texel does, so I would have thought it had more opportunities to utilize AVX-512 instructions.

My system is Ubuntu 22.04 with gcc 11.4.0 and clang 14.0.0.
Why do you use j16?

Try:

make -j profile-build COMP=clang ARCH=apple-silicon

and then:

./stockfish compiler

or try:

make -j profile-build ARCH=x86-64-vnni512 COMP=clang CXX=clang++

and then:

strip Stockfish.exe
Magnum
Posts: 195
Joined: Thu Feb 04, 2021 10:24 pm
Full name: Arnold Magnum

Re: AVX 512

Post by Magnum »

Jouni wrote: Sun Jan 07, 2024 8:15 am Speedup estimate 0 to 2% only :( . Ipman has some values for Ryzens.
If you want a speed up, buy a MacBook Pro M3 MAX. :D
Last speed up, after the single improvement from Stockfish developers, was nearly +76% on Apple devices with ARM chips. :lol:
Werewolf
Posts: 2082
Joined: Thu Sep 18, 2008 10:24 pm
Full name: Carl Bicknell

Re: AVX 512

Post by Werewolf »

Magnum wrote: Mon Jan 08, 2024 4:25 pm
Jouni wrote: Sun Jan 07, 2024 8:15 am Speedup estimate 0 to 2% only :( . Ipman has some values for Ryzens.
If you want a speed up, buy a MacBook Pro M3 MAX. :D
Last speed up, after the single improvement from Stockfish developers, was nearly +76% on Apple devices with ARM chips. :lol:
And get a very poor choice of software. Running Windows on Parallels doesn't help as it doesn't even support AVX2, let alone AVX512.