Current state of compiler differences STOCKFISH

Discussion of chess software programming and technical issues.

Moderator: Ras

Fulvio
Posts: 395
Joined: Fri Aug 12, 2016 8:43 pm

Re: Current state of compiler differences STOCKFISH

Post by Fulvio »

I use this to compile the Stockfish-AVX2 with msvc:

Code: Select all

 cl /std:c++17 /DNDEBUG /DUSE_POPCNT /DUSE_AVX2 /DUSE_SSE41 /DUSE_SSSE3 /DUSE_SSE2  /GS- /MT /O2 /Oi /Ot /Oy /GL /EHsc *.cpp nnue/*.cpp nnue/features/*.cpp syzygy/*.cpp /link /LTCG /STACK:reserve=8388608 /OUT:stockfish.exe advapi32.lib
Anyone have something better?
Karlo Bala
Posts: 373
Joined: Wed Mar 22, 2006 10:17 am
Location: Novi Sad, Serbia
Full name: Karlo Balla

Re: Current state of compiler differences STOCKFISH

Post by Karlo Bala »

Fulvio wrote: Mon Dec 06, 2021 9:48 pm I use this to compile the Stockfish-AVX2 with msvc:

Code: Select all

 cl /std:c++17 /DNDEBUG /DUSE_POPCNT /DUSE_AVX2 /DUSE_SSE41 /DUSE_SSSE3 /DUSE_SSE2  /GS- /MT /O2 /Oi /Ot /Oy /GL /EHsc *.cpp nnue/*.cpp nnue/features/*.cpp syzygy/*.cpp /link /LTCG /STACK:reserve=8388608 /OUT:stockfish.exe advapi32.lib
Anyone have something better?
Using MSVC compiler with the PGO can be up to 30% faster than without.
Best Regards,
Karlo Balla Jr.
Fulvio
Posts: 395
Joined: Fri Aug 12, 2016 8:43 pm

Re: Current state of compiler differences STOCKFISH

Post by Fulvio »

Karlo Bala wrote: Mon Dec 06, 2021 10:20 pm Using MSVC compiler with the PGO can be up to 30% faster than without.
Cool!
I got ~6% improvement.
I added to the cl command /GENPROFILE
then run "stockfish.exe bench"
and then recompiled replacing /GENPROFILE with /USEPROFILE
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Current state of compiler differences STOCKFISH

Post by dangi12012 »

Karlo Bala wrote: Mon Dec 06, 2021 10:20 pm
Fulvio wrote: Mon Dec 06, 2021 9:48 pm I use this to compile the Stockfish-AVX2 with msvc:

Code: Select all

 cl /std:c++17 /DNDEBUG /DUSE_POPCNT /DUSE_AVX2 /DUSE_SSE41 /DUSE_SSSE3 /DUSE_SSE2  /GS- /MT /O2 /Oi /Ot /Oy /GL /EHsc *.cpp nnue/*.cpp nnue/features/*.cpp syzygy/*.cpp /link /LTCG /STACK:reserve=8388608 /OUT:stockfish.exe advapi32.lib
Anyone have something better?
Using MSVC compiler with the PGO can be up to 30% faster than without.
But even with +30% its still slower?
Also its like overclocking. You can turn on PGO for clang and gcc as well. But its a lot harder to setup correctly compared to a normal compile.
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
Karlo Bala
Posts: 373
Joined: Wed Mar 22, 2006 10:17 am
Location: Novi Sad, Serbia
Full name: Karlo Balla

Re: Current state of compiler differences STOCKFISH

Post by Karlo Bala »

Fulvio wrote: Mon Dec 06, 2021 10:37 pm
Karlo Bala wrote: Mon Dec 06, 2021 10:20 pm Using MSVC compiler with the PGO can be up to 30% faster than without.
Cool!
I got ~6% improvement.
I added to the cl command /GENPROFILE
then run "stockfish.exe bench"
and then recompiled replacing /GENPROFILE with /USEPROFILE
Well, not much :(

Can you upload somewhere the entire solution, I would like to give it a try (and something to compare with).
Best Regards,
Karlo Balla Jr.
Sopel
Posts: 391
Joined: Tue Oct 08, 2019 11:39 pm
Full name: Tomasz Sobczyk

Re: Current state of compiler differences STOCKFISH

Post by Sopel »

dangi12012 wrote: Tue Dec 07, 2021 12:55 am
Karlo Bala wrote: Mon Dec 06, 2021 10:20 pm
Fulvio wrote: Mon Dec 06, 2021 9:48 pm I use this to compile the Stockfish-AVX2 with msvc:

Code: Select all

 cl /std:c++17 /DNDEBUG /DUSE_POPCNT /DUSE_AVX2 /DUSE_SSE41 /DUSE_SSSE3 /DUSE_SSE2  /GS- /MT /O2 /Oi /Ot /Oy /GL /EHsc *.cpp nnue/*.cpp nnue/features/*.cpp syzygy/*.cpp /link /LTCG /STACK:reserve=8388608 /OUT:stockfish.exe advapi32.lib
Anyone have something better?
Using MSVC compiler with the PGO can be up to 30% faster than without.
But even with +30% its still slower?
Also its like overclocking. You can turn on PGO for clang and gcc as well. But its a lot harder to setup correctly compared to a normal compile.
It's literally profile-build instead of build. Just says how terribly useless your measurements are.
dangi12012 wrote:No one wants to touch anything you have posted. That proves you now have negative reputations since everyone knows already you are a forum troll.

Maybe you copied your stockfish commits from someone else too?
I will look into that.
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Current state of compiler differences STOCKFISH

Post by dangi12012 »

Karlo Bala wrote: Tue Dec 07, 2021 12:59 am
Fulvio wrote: Mon Dec 06, 2021 10:37 pm
Karlo Bala wrote: Mon Dec 06, 2021 10:20 pm Using MSVC compiler with the PGO can be up to 30% faster than without.
Cool!
I got ~6% improvement.
I added to the cl command /GENPROFILE
then run "stockfish.exe bench"
and then recompiled replacing /GENPROFILE with /USEPROFILE
Well, not much :(

Can you upload somewhere the entire solution, I would like to give it a try (and something to compare with).
Yes sure https://1drv.ms/u/s!AoDIyNlDG2QTg8YSjED ... Q?e=wRReGm
You can just copy the sln and the vcxproj file from there. Not more is needed.

BMI2+EVX2 is enabled via settings in the vcxproj.
Share with us if you have some news :)
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
Fulvio
Posts: 395
Joined: Fri Aug 12, 2016 8:43 pm

Re: Current state of compiler differences STOCKFISH

Post by Fulvio »

Karlo Bala wrote: Tue Dec 07, 2021 12:59 am Can you upload somewhere the entire solution, I would like to give it a try (and something to compare with).
I compiled it directly from the command prompt (x64 Native Tools Command Prompt for VS 2022).
I downloaded Stockfish's source code into a directory "stockfish".
I downloaded the net ( https://tests.stockfishchess.org/api/nn ... 602d6.nnue ) into the directory "stockfish/src".
I opened the VS2022 command prompt and cd into "stockfish/src" and compiled it with:

Code: Select all

cl /std:c++17 /DNDEBUG /DUSE_POPCNT /DUSE_AVX2 /DUSE_SSE41 /DUSE_SSSE3 /DUSE_SSE2  /GS- /MT /O2 /Oi /Ot /Oy /GL /EHsc *.cpp nnue/*.cpp nnue/features/*.cpp syzygy/*.cpp /link /GENPROFILE /LTCG /STACK:reserve=8388608 /OUT:stockfish.exe advapi32.lib

stockfish.exe bench

cl /std:c++17 /DNDEBUG /DUSE_POPCNT /DUSE_AVX2 /DUSE_SSE41 /DUSE_SSSE3 /DUSE_SSE2  /GS- /MT /O2 /Oi /Ot /Oy /GL /EHsc *.cpp nnue/*.cpp nnue/features/*.cpp syzygy/*.cpp /link /USEPROFILE /LTCG /STACK:reserve=8388608 /OUT:stockfish.exe advapi32.lib
Fulvio
Posts: 395
Joined: Fri Aug 12, 2016 8:43 pm

Re: Current state of compiler differences STOCKFISH

Post by Fulvio »

dangi12012 wrote: Tue Dec 07, 2021 2:23 am BMI2+EVX2 is enabled via settings in the vcxproj.
Share with us if you have some news :)
I get a ~25% slower executable using that vcxproj
AndrewGrant
Posts: 1945
Joined: Tue Apr 19, 2016 6:08 am
Location: U.S.A
Full name: Andrew Grant

Re: Current state of compiler differences STOCKFISH

Post by AndrewGrant »

Fulvio wrote: Tue Dec 07, 2021 8:22 am
dangi12012 wrote: Tue Dec 07, 2021 2:23 am BMI2+EVX2 is enabled via settings in the vcxproj.
Share with us if you have some news :)
I get a ~25% slower executable using that vcxproj
You happen to have a Ryzen by chance? PEXT could produce that level of slowdown. I notice your original compilation does not include BMI2.