Visual Studio 2022: just installed

Discussion of chess software programming and technical issues.

Moderator: Ras

Mergi
Posts: 127
Joined: Sat Aug 21, 2021 9:55 pm
Full name: Jen

Re: Visual Studio 2022: just installed

Post by Mergi »

Mike Sherwin wrote: Wed Dec 08, 2021 5:25 pm Thanks guys! I have gotten it down to only two errors. Those should go away when the bit scans are replaced by __builtin_clzll(bb). But I suspect the compiler took an early out. There are probably many more errors to find. As far as Whole Program Optimization it works now under 2022 and produces a slightly faster executable. Microsoft fixed my bug, lol. Really sorry to see 20% slower performance for Colossus. :cry:
You should take a look at the new C++20 <bit> header - std::countl_zero and std::countr_zero instead of the builtin functions are the way to go. 8-)
Mike Sherwin
Posts: 965
Joined: Fri Aug 21, 2020 1:25 am
Location: Planet Earth, Sol system
Full name: Michael J Sherwin

Re: Visual Studio 2022: just installed

Post by Mike Sherwin »

Mergi wrote: Wed Dec 08, 2021 7:02 pm
Mike Sherwin wrote: Wed Dec 08, 2021 5:25 pm Thanks guys! I have gotten it down to only two errors. Those should go away when the bit scans are replaced by __builtin_clzll(bb). But I suspect the compiler took an early out. There are probably many more errors to find. As far as Whole Program Optimization it works now under 2022 and produces a slightly faster executable. Microsoft fixed my bug, lol. Really sorry to see 20% slower performance for Colossus. :cry:
You should take a look at the new C++20 <bit> header - std::countl_zero and std::countr_zero instead of the builtin functions are the way to go. 8-)
Thanks!
User avatar
emadsen
Posts: 440
Joined: Thu Apr 26, 2012 1:51 am
Location: Oak Park, IL, USA
Full name: Erik Madsen

Re: Visual Studio 2022: just installed

Post by emadsen »

Chessnut1071 wrote: Wed Dec 08, 2021 2:50 pm ????? How did you get bit scan forward working in C#, or, were you using C++? I too am disappointed in VS2022, Perhaps we should all tell Microsoft what we need and ask them to revise immediately, if not sooner.
Bill, what's the disconnect here? We've provided an answer multiple times. Use System.Numerics.BitOperations in .NET 5 or 6. Have you tried that? Do you receive a specific error message?
Erik Madsen | My C# chess engine: https://www.madchess.net
User avatar
silentshark
Posts: 327
Joined: Sat Mar 27, 2010 7:15 pm

Re: Visual Studio 2022: just installed

Post by silentshark »

MartinBryant wrote: Wed Dec 08, 2021 8:46 am
Mike Sherwin wrote: Tue Dec 07, 2021 4:52 am Today I downloaded MSVC 2022 and enabled the clang option. I wrote a little first program just to see if it will work for me. It ran just fine despite the compiler giving 3 diagnostic errors. I really don't want my code littered with false errors. I'm wondering just how many of these type idiosyncrasies there would be in a fully developed chess engine? However, from what I've seen it appears that clang produces faster executables. And that would be compelling if it were not for non chess engine examples running just slightly slower than standard MSVC in many cases. But, also Mar (and I think Gerd) said that clang understands my SISSY bitboard code much better than other top compilers which can make a sizeable difference in n/s. When Bricabrac was compiled with clang there were 1193 actual errors and it would not compile. So where does this leave me? idk, please help!

Side note: In MSVC 2019 I had to turn off Whole Program Optimization because every so many games it would flake out and become buggy. In MSVC 2022 Whole Program Optimization works just fine.
I also tried VS2022 recently, hoping that the Clang compiler might be a quick win.
Although Colossus compiled first time the Clang executable was over 20% slower than the MSVC one :(
YMMV!
Just having a look at this now.. What's a good set of optimise-for-speed flags for clang? Can I do PGO like I do with MSVC?
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Visual Studio 2022: just installed

Post by dangi12012 »

silentshark wrote: Wed Dec 08, 2021 7:38 pm
MartinBryant wrote: Wed Dec 08, 2021 8:46 am
Mike Sherwin wrote: Tue Dec 07, 2021 4:52 am Today I downloaded MSVC 2022 and enabled the clang option. I wrote a little first program just to see if it will work for me. It ran just fine despite the compiler giving 3 diagnostic errors. I really don't want my code littered with false errors. I'm wondering just how many of these type idiosyncrasies there would be in a fully developed chess engine? However, from what I've seen it appears that clang produces faster executables. And that would be compelling if it were not for non chess engine examples running just slightly slower than standard MSVC in many cases. But, also Mar (and I think Gerd) said that clang understands my SISSY bitboard code much better than other top compilers which can make a sizeable difference in n/s. When Bricabrac was compiled with clang there were 1193 actual errors and it would not compile. So where does this leave me? idk, please help!

Side note: In MSVC 2019 I had to turn off Whole Program Optimization because every so many games it would flake out and become buggy. In MSVC 2022 Whole Program Optimization works just fine.
I also tried VS2022 recently, hoping that the Clang compiler might be a quick win.
Although Colossus compiled first time the Clang executable was over 20% slower than the MSVC one :(
YMMV!
Just having a look at this now.. What's a good set of optimise-for-speed flags for clang? Can I do PGO like I do with MSVC?
Yes of course. Clang seems to create better code some of the time than MSVC. For your own machine its easy to compile fast code
clang++ -flto -O3 -march=native -funroll-loops -std=c++20 -fprofile-generate
clang++ -flto -O3 -march=native -funroll-loops -std=c++20 -fprofile-use


https://stackoverflow.com/questions/144 ... d-o3-ofast
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
User avatar
silentshark
Posts: 327
Joined: Sat Mar 27, 2010 7:15 pm

Re: Visual Studio 2022: just installed

Post by silentshark »

dangi12012 wrote: Wed Dec 08, 2021 7:47 pm
silentshark wrote: Wed Dec 08, 2021 7:38 pm
MartinBryant wrote: Wed Dec 08, 2021 8:46 am
Mike Sherwin wrote: Tue Dec 07, 2021 4:52 am Today I downloaded MSVC 2022 and enabled the clang option. I wrote a little first program just to see if it will work for me. It ran just fine despite the compiler giving 3 diagnostic errors. I really don't want my code littered with false errors. I'm wondering just how many of these type idiosyncrasies there would be in a fully developed chess engine? However, from what I've seen it appears that clang produces faster executables. And that would be compelling if it were not for non chess engine examples running just slightly slower than standard MSVC in many cases. But, also Mar (and I think Gerd) said that clang understands my SISSY bitboard code much better than other top compilers which can make a sizeable difference in n/s. When Bricabrac was compiled with clang there were 1193 actual errors and it would not compile. So where does this leave me? idk, please help!

Side note: In MSVC 2019 I had to turn off Whole Program Optimization because every so many games it would flake out and become buggy. In MSVC 2022 Whole Program Optimization works just fine.
I also tried VS2022 recently, hoping that the Clang compiler might be a quick win.
Although Colossus compiled first time the Clang executable was over 20% slower than the MSVC one :(
YMMV!
Just having a look at this now.. What's a good set of optimise-for-speed flags for clang? Can I do PGO like I do with MSVC?
Yes of course. Clang seems to create better code some of the time than MSVC. For your own machine its easy to compile fast code
clang++ -flto -O3 -march=native -funroll-loops -std=c++20 -fprofile-generate
clang++ -flto -O3 -march=native -funroll-loops -std=c++20 -fprofile-use


https://stackoverflow.com/questions/144 ... d-o3-ofast
Thanks, I will give that a try. First attempt allows my to create the .exe for profiling, but on the second compile gives the error

error: Could not read profile default.profdata: no such file or directory

Hmmmm...
AndrewGrant
Posts: 1957
Joined: Tue Apr 19, 2016 6:08 am
Location: U.S.A
Full name: Andrew Grant

Re: Visual Studio 2022: just installed

Post by AndrewGrant »

silentshark wrote: Wed Dec 08, 2021 8:12 pm
dangi12012 wrote: Wed Dec 08, 2021 7:47 pm
silentshark wrote: Wed Dec 08, 2021 7:38 pm
MartinBryant wrote: Wed Dec 08, 2021 8:46 am
Mike Sherwin wrote: Tue Dec 07, 2021 4:52 am Today I downloaded MSVC 2022 and enabled the clang option. I wrote a little first program just to see if it will work for me. It ran just fine despite the compiler giving 3 diagnostic errors. I really don't want my code littered with false errors. I'm wondering just how many of these type idiosyncrasies there would be in a fully developed chess engine? However, from what I've seen it appears that clang produces faster executables. And that would be compelling if it were not for non chess engine examples running just slightly slower than standard MSVC in many cases. But, also Mar (and I think Gerd) said that clang understands my SISSY bitboard code much better than other top compilers which can make a sizeable difference in n/s. When Bricabrac was compiled with clang there were 1193 actual errors and it would not compile. So where does this leave me? idk, please help!

Side note: In MSVC 2019 I had to turn off Whole Program Optimization because every so many games it would flake out and become buggy. In MSVC 2022 Whole Program Optimization works just fine.
I also tried VS2022 recently, hoping that the Clang compiler might be a quick win.
Although Colossus compiled first time the Clang executable was over 20% slower than the MSVC one :(
YMMV!
Just having a look at this now.. What's a good set of optimise-for-speed flags for clang? Can I do PGO like I do with MSVC?
Yes of course. Clang seems to create better code some of the time than MSVC. For your own machine its easy to compile fast code
clang++ -flto -O3 -march=native -funroll-loops -std=c++20 -fprofile-generate
clang++ -flto -O3 -march=native -funroll-loops -std=c++20 -fprofile-use


https://stackoverflow.com/questions/144 ... d-o3-ofast
Thanks, I will give that a try. First attempt allows my to create the .exe for profiling, but on the second compile gives the error

error: Could not read profile default.profdata: no such file or directory

Hmmmm...
Clang requires additional arguments than fprofile-use and fprofile-generate.
Example: https://github.com/TerjeKir/weiss/blob/ ... le#L37-L46
User avatar
silentshark
Posts: 327
Joined: Sat Mar 27, 2010 7:15 pm

Re: Visual Studio 2022: just installed

Post by silentshark »

AndrewGrant wrote: Wed Dec 08, 2021 8:19 pm
silentshark wrote: Wed Dec 08, 2021 8:12 pm
dangi12012 wrote: Wed Dec 08, 2021 7:47 pm
silentshark wrote: Wed Dec 08, 2021 7:38 pm
MartinBryant wrote: Wed Dec 08, 2021 8:46 am
Mike Sherwin wrote: Tue Dec 07, 2021 4:52 am Today I downloaded MSVC 2022 and enabled the clang option. I wrote a little first program just to see if it will work for me. It ran just fine despite the compiler giving 3 diagnostic errors. I really don't want my code littered with false errors. I'm wondering just how many of these type idiosyncrasies there would be in a fully developed chess engine? However, from what I've seen it appears that clang produces faster executables. And that would be compelling if it were not for non chess engine examples running just slightly slower than standard MSVC in many cases. But, also Mar (and I think Gerd) said that clang understands my SISSY bitboard code much better than other top compilers which can make a sizeable difference in n/s. When Bricabrac was compiled with clang there were 1193 actual errors and it would not compile. So where does this leave me? idk, please help!

Side note: In MSVC 2019 I had to turn off Whole Program Optimization because every so many games it would flake out and become buggy. In MSVC 2022 Whole Program Optimization works just fine.
I also tried VS2022 recently, hoping that the Clang compiler might be a quick win.
Although Colossus compiled first time the Clang executable was over 20% slower than the MSVC one :(
YMMV!
Just having a look at this now.. What's a good set of optimise-for-speed flags for clang? Can I do PGO like I do with MSVC?
Yes of course. Clang seems to create better code some of the time than MSVC. For your own machine its easy to compile fast code
clang++ -flto -O3 -march=native -funroll-loops -std=c++20 -fprofile-generate
clang++ -flto -O3 -march=native -funroll-loops -std=c++20 -fprofile-use


https://stackoverflow.com/questions/144 ... d-o3-ofast
Thanks, I will give that a try. First attempt allows my to create the .exe for profiling, but on the second compile gives the error

error: Could not read profile default.profdata: no such file or directory

Hmmmm...
Clang requires additional arguments than fprofile-use and fprofile-generate.
Example: https://github.com/TerjeKir/weiss/blob/ ... le#L37-L46
Thanks. Also found this was a good pointer - https://clang.llvm.org/docs/UsersManual ... timization
Chessnut1071
Posts: 313
Joined: Tue Aug 03, 2021 2:41 pm
Full name: Bill Beame

Re: Visual Studio 2022: just installed

Post by Chessnut1071 »

emadsen wrote: Wed Dec 08, 2021 7:10 pm
Chessnut1071 wrote: Wed Dec 08, 2021 2:50 pm ????? How did you get bit scan forward working in C#, or, were you using C++? I too am disappointed in VS2022, Perhaps we should all tell Microsoft what we need and ask them to revise immediately, if not sooner.
Bill, what's the disconnect here? We've provided an answer multiple times. Use System.Numerics.BitOperations in .NET 5 or 6. Have you tried that? Do you receive a specific error message?
CSO2034, BitOperations does not exist in the namespace System,Numerics
I'm just getting used to this new VS, using VS2022 N3t 7.3. I have a work around that's a 64-cycle loop which works but way too slow for what I need.
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Visual Studio 2022: just installed

Post by dangi12012 »

Chessnut1071 wrote: Thu Dec 09, 2021 5:25 am
emadsen wrote: Wed Dec 08, 2021 7:10 pm
Chessnut1071 wrote: Wed Dec 08, 2021 2:50 pm ????? How did you get bit scan forward working in C#, or, were you using C++? I too am disappointed in VS2022, Perhaps we should all tell Microsoft what we need and ask them to revise immediately, if not sooner.
Bill, what's the disconnect here? We've provided an answer multiple times. Use System.Numerics.BitOperations in .NET 5 or 6. Have you tried that? Do you receive a specific error message?
CSO2034, BitOperations does not exist in the namespace System,Numerics
I'm just getting used to this new VS, using VS2022 N3t 7.3. I have a work around that's a 64-cycle loop which works but way too slow for what I need.
They do not exist? Microsoft does not lie. HERE FOR YOU :)
https://docs.microsoft.com/en-us/dotnet ... ew=net-6.0
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer