PGO improvement for Stockfish?

Discussion of chess software programming and technical issues.

Moderator: Ras

zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: PGO improvement for Stockfish?

Post by zullil »

zullil wrote:
Krgp wrote:
zullil wrote:
I'm just building with the following shell script instead of make:

Code: Select all

rm stockfish *.gcda

g++-4.7 -Wall -Wcast-qual -fno-exceptions -fno-rtti -ansi -pedantic -Wno-long-long -Wextra -Wshadow\
        -DNDEBUG -O3 -DIS_64BIT -DUSE_BSFQ -DUSE_POPCNT -fprofile-arcs -o stockfish *.cpp -lpthread

./stockfish bench 32 1 1 default time >> /dev/null

rm ucioption.gcda

g++-4.7 -Wall -Wcast-qual -fno-exceptions -fno-rtti -ansi -pedantic -Wno-long-long -Wextra -Wshadow\
        -DNDEBUG -O3 -DIS_64BIT -DUSE_BSFQ -DUSE_POPCNT -fbranch-probabilities -o stockfish *.cpp -lpthread
I am also doing similar (however I use Brice's batch file after various modifications - and do get additional 3% speed gain) at the moment ... a slight difference being I can afford to use -march=native ... so no need for other flags ... also I had initially thought 'cpuz' is being used for just determining basic architecture ... however the .txt file generated is quite similar to the output of gcc -c -Q -march=native --help=target ... so I suspected it's being used to get profile data (however could read it in the script itself) ... anyway thanks for your shell script ... will try it out and post feedback ...

I'll try using -march=native with 4.7.3, but with 4.8 it actually yielded slower code.
Including -march=native again yielded slower code. However, with 4.7.3, including -flto in the final compilation yielded a clear speed-up. Here's the modified script:

Code: Select all

rm stockfish *.gcda

g++-4.7 -Wall -Wcast-qual -fno-exceptions -fno-rtti -ansi -pedantic -Wno-long-long -Wextra -Wshadow\
        -DNDEBUG -O3 -DIS_64BIT -DUSE_BSFQ -DUSE_POPCNT -fprofile-arcs -o stockfish *.cpp -lpthread

./stockfish bench 32 1 1 default time >> /dev/null

rm ucioption.gcda

g++-4.7 -Wall -Wcast-qual -fno-exceptions -fno-rtti -ansi -pedantic -Wno-long-long -Wextra -Wshadow\
        -DNDEBUG -O3 -DIS_64BIT -DUSE_BSFQ -DUSE_POPCNT -fbranch-probabilities -flto -o stockfish *.cpp -lpthread -flto
Krgp
Posts: 20
Joined: Mon Nov 04, 2013 6:18 am

Re: PGO improvement for Stockfish?

Post by Krgp »

zullil wrote:Including -march=native again yielded slower code. However, with 4.7.3, including -flto in the final compilation yielded a clear speed-up. Here's the modified script:

Code: Select all

rm stockfish *.gcda

g++-4.7 -Wall -Wcast-qual -fno-exceptions -fno-rtti -ansi -pedantic -Wno-long-long -Wextra -Wshadow\
        -DNDEBUG -O3 -DIS_64BIT -DUSE_BSFQ -DUSE_POPCNT -fprofile-arcs -o stockfish *.cpp -lpthread

./stockfish bench 32 1 1 default time >> /dev/null

rm ucioption.gcda

g++-4.7 -Wall -Wcast-qual -fno-exceptions -fno-rtti -ansi -pedantic -Wno-long-long -Wextra -Wshadow\
        -DNDEBUG -O3 -DIS_64BIT -DUSE_BSFQ -DUSE_POPCNT -fbranch-probabilities -flto -o stockfish *.cpp -lpthread -flto
-lpthread -flto gives me slow build again ... I have to use -march=native - else I get compilation error ... as I have reported, I have to incorporate your script into windows batch-file (by Brice in BYO) ... I am not able to run your scripts independently for two reasons

(1) I am on windows (8.1 pro 64) & (2) I am complete newbie so I don't know how to run your script ...

Can you please make a 'batch file' ... with instructions where to keep it & run? (my gcc is at C:\MinGW\mingw64)
KP
zullil
Posts: 6442
Joined: Tue Jan 09, 2007 12:31 am
Location: PA USA
Full name: Louis Zulli

Re: PGO improvement for Stockfish?

Post by zullil »

Krgp wrote:
zullil wrote:Including -march=native again yielded slower code. However, with 4.7.3, including -flto in the final compilation yielded a clear speed-up. Here's the modified script:

Code: Select all

rm stockfish *.gcda

g++-4.7 -Wall -Wcast-qual -fno-exceptions -fno-rtti -ansi -pedantic -Wno-long-long -Wextra -Wshadow\
        -DNDEBUG -O3 -DIS_64BIT -DUSE_BSFQ -DUSE_POPCNT -fprofile-arcs -o stockfish *.cpp -lpthread

./stockfish bench 32 1 1 default time >> /dev/null

rm ucioption.gcda

g++-4.7 -Wall -Wcast-qual -fno-exceptions -fno-rtti -ansi -pedantic -Wno-long-long -Wextra -Wshadow\
        -DNDEBUG -O3 -DIS_64BIT -DUSE_BSFQ -DUSE_POPCNT -fbranch-probabilities -flto -o stockfish *.cpp -lpthread -flto
-lpthread -flto gives me slow build again ... I have to use -march=native - else I get compilation error ... as I have reported, I have to incorporate your script into windows batch-file (by Brice in BYO) ... I am not able to run your scripts independently for two reasons

(1) I am on windows (8.1 pro 64) & (2) I am complete newbie so I don't know how to run your script ...

Can you please make a 'batch file' ... with instructions where to keep it & run? (my gcc is at C:\MinGW\mingw64)
We're in two different worlds!

Don't think you want -lpthread if you're using mingw. Simply omit that.

Have no idea about Windows or batch files. Maybe someone who is "multilingual" can translate my script for you.