PGO, VS2022

Discussion of chess software programming and technical issues.

Moderator: Ras

chrisw
Posts: 4624
Joined: Tue Apr 03, 2012 4:28 pm
Location: Midi-Pyrénées
Full name: Christopher Whittington

PGO, VS2022

Post by chrisw »

Has anybody got the PGO stuff functional in Visual Studio 2022? I gave it an initial try but couldn't exactly find a way to make progress.

Anybody? Idiot's guide?
Joost Buijs
Posts: 1632
Joined: Thu Jul 16, 2009 10:47 am
Location: Almere, The Netherlands

Re: PGO, VS2022

Post by Joost Buijs »

It should be as simple as:

Build -> Profile Guided Optimization -> Instrument
Build -> Profile Guided Optimization -> Run Instrumented/Optimized Application
Build -> Profile Guided Optimization -> Optimize
Build -> Profile Guided Optimization -> Run Instrumented/Optimized Application

The PGO optimization build should output something like this:

Code: Select all

Build started...
1>------ Build started: Project: Nightmare-v7.93, Configuration: Release x64 ------
1>Merging D:\Nightmare-v7.93\x64\Release\Nightmare-v7.93!1.pgc
1>D:\Nightmare-v7.93\x64\Release\Nightmare-v7.93!1.pgc: Used 11.9% (978488 / 8196096) of total space reserved.  0.0% of the counts were dropped due to overflow.
1>  Reading PGD file 1: D:\Nightmare-v7.93\x64\Release\Nightmare-v7.93.pgd
1>Generating code
1>
1>0 of 0 ( 0.0%) original invalid call sites were matched.
1>0 new call sites were added.
1>15 of 2115 (  0.71%) profiled functions will be compiled for speed, and the rest of the functions will be compiled for size
1>7821 of 10654 inline instances were from dead/cold paths
1>2115 of 2115 functions (100.0%) were optimized using profile data
1>66834578054 of 66834578054 instructions (100.0%) were optimized using profile data
1>Finished generating code
1>Nightmare v7.93.vcxproj -> D:\Nightmare-v7.93\x64\Release\Nightmare-v7.93.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Build started at 8:23 AM and took 03,302 seconds ==========
Be careful when you run your program from the environment with F5 or Ctrl+F5 it always does a normal build and removes PGO, nowadays VS seem to warn about this.

VC PGO was never very good, and I have the impression that when you use a lot of SIMD code in your program it hardly does anything.
When I optimize Nightmare with PGO, the difference is negligible. This is with SMP so dont look at the score or the absolute time, what matters is the nps.

Without PGO:

Code: Select all

info depth 20 score cp 27 time 3714 nodes 77750676 nps 20934484 tbhits 0 pv d2d4 g8f6 c2c4 e7e6 g1f3 d7d5 b1c3 f8b4 d1a4 b8c6 e2e3 e8g8
info depth 21 score cp 27 time 4129 nodes 86413800 nps 20928505 tbhits 0 pv d2d4 g8f6 c2c4 e7e6 g1f3 d7d5 b1c3 f8b4 d1a4 b8c6 e2e3 e8g8
info depth 22 score cp 21 time 4338 nodes 90758720 nps 20921788 tbhits 0 pv d2d4 g8f6 g1f3 e7e6 c2c4 d7d5 b1c3 f8b4 d1a4 b8c6 e2e3 e8g8
info depth 23 score cp 31 time 5582 nodes 116471469 nps 20865544 tbhits 0 pv d2d4 g8f6 c2c4 e7e6 g1f3 d7d5 b1c3 f8b4 c1g5 e8g8 e2e3 h7h6
info depth 24 score cp 31 time 7422 nodes 154339393 nps 20794852 tbhits 0 pv d2d4 g8f6 c2c4 e7e6 g1f3 d7d5 b1c3 c7c5 c1g5 c5d4 f3d4 d5c4
info depth 25 score cp 29 time 11123 nodes 230537544 nps 20726201 tbhits 0 pv d2d4 g8f6 c2c4 e7e6 g1f3 d7d5 b1c3 c7c5 c1g5 c5d4 f3d4 d5c4
With PGO:

Code: Select all

info depth 20 score cp 18 time 1476 nodes 31723042 nps 21492575 tbhits 0 pv g1f3 g8f6 d2d4 d7d5 c2c4 e7e6 b1c3 f8b4 d1a4 b8c6 e2e3 e8g8
info depth 21 score cp 18 time 1867 nodes 40297401 nps 21584039 tbhits 0 pv g1f3 g8f6 d2d4 d7d5 c2c4 e7e6 b1c3 f8b4 d1a4 b8c6 e2e3 e8g8
info depth 22 score cp 18 time 2453 nodes 52868434 nps 21552561 tbhits 0 pv g1f3 g8f6 d2d4 d7d5 c2c4 e7e6 b1c3 f8b4 d1a4 b8c6 e2e3 e8g8
info depth 23 score cp 23 time 6432 nodes 136784649 nps 21266270 tbhits 0 pv d2d4 g8f6 c2c4 e7e6 g1f3 d7d5 g2g3 f8b4 c1d2 a7a5 f1g2 d5c4
info depth 24 score cp 27 time 9632 nodes 204115332 nps 21191375 tbhits 0 pv d2d4 g8f6 c2c4 e7e6 g1f3 d7d5 b1c3 c7c5 c1g5 d5c4 e2e3 c5d4
info depth 25 score cp 25 time 12039 nodes 254792623 nps 21163935 tbhits 0 pv d2d4 d7d5 c2c4 e7e6 b1c3 g8f6 g1f3 c7c5 c1g5 c5d4 f3d4 d5c4
My conclusion is that it is not worthwhile to spend time on PGO, at least I never use it.
chrisw
Posts: 4624
Joined: Tue Apr 03, 2012 4:28 pm
Location: Midi-Pyrénées
Full name: Christopher Whittington

Re: PGO, VS2022

Post by chrisw »

Doesn't appear on the build menu:

Build -> Profile Guided Optimization -> Instrument

should there be something installed, or some prior action?
User avatar
Rebel
Posts: 7299
Joined: Thu Aug 18, 2011 12:04 pm
Full name: Ed Schröder

Re: PGO, VS2022

Post by Rebel »

Joost Buijs wrote: Sun Apr 23, 2023 8:28 amMy conclusion is that it is not worthwhile to spend time on PGO, at least I never use it.
Is Intel still superior, now also with SIMD?
90% of coding is debugging, the other 10% is writing bugs.
Joost Buijs
Posts: 1632
Joined: Thu Jul 16, 2009 10:47 am
Location: Almere, The Netherlands

Re: PGO, VS2022

Post by Joost Buijs »

chrisw wrote: Sun Apr 23, 2023 4:15 pm Doesn't appear on the build menu:

Build -> Profile Guided Optimization -> Instrument

should there be something installed, or some prior action?
Aha, I think the problem is that you use VS 2022 Community Edition, that one doesn't support PGO. I use VS 2022 Professional.
Maybe it is possible to use PGO by means of cmd-line parameters with the Community Edition, I never tried.
Last edited by Joost Buijs on Mon Apr 24, 2023 8:40 am, edited 1 time in total.
Joost Buijs
Posts: 1632
Joined: Thu Jul 16, 2009 10:47 am
Location: Almere, The Netherlands

Re: PGO, VS2022

Post by Joost Buijs »

Rebel wrote: Sun Apr 23, 2023 11:17 pm
Joost Buijs wrote: Sun Apr 23, 2023 8:28 amMy conclusion is that it is not worthwhile to spend time on PGO, at least I never use it.
Is Intel still superior, now also with SIMD?
I really don't know, both my development machines are getting rather old (Intel 10th gen and AMD Zen2). I'm thinking about building a new machine with either an Intel Emerald Rapids or an AMD Zen4 Threadripper, I probably have to wait for another year until these processors arrive.
User avatar
Rebel
Posts: 7299
Joined: Thu Aug 18, 2011 12:04 pm
Full name: Ed Schröder

Re: PGO, VS2022

Post by Rebel »

Joost Buijs wrote: Mon Apr 24, 2023 8:28 am
Rebel wrote: Sun Apr 23, 2023 11:17 pm
Joost Buijs wrote: Sun Apr 23, 2023 8:28 amMy conclusion is that it is not worthwhile to spend time on PGO, at least I never use it.
Is Intel still superior, now also with SIMD?
I really don't know, both my development machines are getting rather old (Intel 10th gen and AMD Zen2). I'm thinking about building a new machine with either an Intel Emerald Rapids or an AMD Zen4 Threadripper, I probably have to wait for another year until these processors arrive.
Sorry, my question was if the Intel compiler is still superior to VS.
90% of coding is debugging, the other 10% is writing bugs.
Joost Buijs
Posts: 1632
Joined: Thu Jul 16, 2009 10:47 am
Location: Almere, The Netherlands

Re: PGO, VS2022

Post by Joost Buijs »

Rebel wrote: Mon Apr 24, 2023 8:58 am
Joost Buijs wrote: Mon Apr 24, 2023 8:28 am
Rebel wrote: Sun Apr 23, 2023 11:17 pm
Joost Buijs wrote: Sun Apr 23, 2023 8:28 amMy conclusion is that it is not worthwhile to spend time on PGO, at least I never use it.
Is Intel still superior, now also with SIMD?
I really don't know, both my development machines are getting rather old (Intel 10th gen and AMD Zen2). I'm thinking about building a new machine with either an Intel Emerald Rapids or an AMD Zen4 Threadripper, I probably have to wait for another year until these processors arrive.
Sorry, my question was if the Intel compiler is still superior to VS.
If you compare MSVC with the old Intel compiler they are very close in performance. The new Intel compiler (oneAPI) is based on Clang, Clang optimizes somewhat better, vectorization is a lot better.
chrisw
Posts: 4624
Joined: Tue Apr 03, 2012 4:28 pm
Location: Midi-Pyrénées
Full name: Christopher Whittington

Re: PGO, VS2022

Post by chrisw »

Joost Buijs wrote: Mon Apr 24, 2023 8:19 am
chrisw wrote: Sun Apr 23, 2023 4:15 pm Doesn't appear on the build menu:

Build -> Profile Guided Optimization -> Instrument

should there be something installed, or some prior action?
Aha, I think the problem is that you use VS 2022 Community Edition, that one doesn't support PGO. I use VS 2022 Professional.
Maybe it is possible to use PGO by means of cmd-line parameters with the Community Edition, I never tried.
Oh, that's annoying. I'm an avoider of paying Microsoft anything at all. The docs don't say anything about versions and PGO, but their steps are a lot more complex than the ones you described:

https://learn.microsoft.com/en-us/cpp/b ... w=msvc-170
Joost Buijs
Posts: 1632
Joined: Thu Jul 16, 2009 10:47 am
Location: Almere, The Netherlands

Re: PGO, VS2022

Post by Joost Buijs »

chrisw wrote: Mon Apr 24, 2023 4:09 pm
Joost Buijs wrote: Mon Apr 24, 2023 8:19 am
chrisw wrote: Sun Apr 23, 2023 4:15 pm Doesn't appear on the build menu:

Build -> Profile Guided Optimization -> Instrument

should there be something installed, or some prior action?
Aha, I think the problem is that you use VS 2022 Community Edition, that one doesn't support PGO. I use VS 2022 Professional.
Maybe it is possible to use PGO by means of cmd-line parameters with the Community Edition, I never tried.
Oh, that's annoying. I'm an avoider of paying Microsoft anything at all. The docs don't say anything about versions and PGO, but their steps are a lot more complex than the ones you described:

https://learn.microsoft.com/en-us/cpp/b ... w=msvc-170
I mailed you at your yahoo address with a possible solution.

This forum is hardly usable, each time I'm logged off after a few seconds, I wonder when they will solve these problems.