Visual Studio 2022: just installed

Discussion of chess software programming and technical issues.

Moderator: Ras

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: Mon Dec 06, 2021 2:36 am
dangi12012 wrote: Sat Dec 04, 2021 6:08 pm
Chessnut1071 wrote: Sat Dec 04, 2021 5:52 pm
dangi12012 wrote: Sat Dec 04, 2021 4:19 pm
silentshark wrote: Sat Dec 04, 2021 3:13 pm Does 2022 produce faster executables (compared with 2019)? what have people found?

Regards,
Tom
The C++ compiler MSVC is the same. The C# compiler Roslyn is the same.
The IDE is new and has new features:
https://docs.microsoft.com/en-us/visual ... ew=vs-2022

But in 1 year or so there will be updates for VS2022 and VS2019 wont get the newest compiler updates anymore.

Also I am old enought to remeber they switched from colored icons in vs2010 to monochrome (which is horrible) icons. It took the whole decade until 2022 that they are all back to colored - and the monochrome is gone thankfully. Its like windows that switches between rounded and square corners every decade or so.

https://docs.microsoft.com/en-us/visual ... ew=vs-2022
Any ideas on how to get BitScanForward working on VS C# 2022? I included System.Numerics in the assembly list; however, I can't seem to get it working and have to rely on a 64 iteration loop which is slow. I think 2022 is Net 7 which I thought included BSF.
You have BSF! :roll: :roll:
Just use .net core and System.Runtime.Intrinsics.X86.Bmi1.X64.TrailingZeroCount(value);
I get the message not available on 7.3, use 9.0 or higher. Are you using VS 2022?
I have been using that instruction since VS 2015.
Are you using .net core? .net 5? or are you using .net framework 4.8?
Use .net 5 since that is the current best pick and compatible with the future too.
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
eduherminio
Posts: 76
Joined: Mon Apr 05, 2021 12:00 am
Full name: Eduardo Caceres

Re: Visual Studio 2022: just installed

Post by eduherminio »

dangi12012 wrote: Mon Dec 06, 2021 2:39 am
I have been using that instruction since VS 2015.
Are you using .net core? .net 5? or are you using .net framework 4.8?
Use .net 5 since that is the current best pick and compatible with the future too.
.NET 5 will only have support for another 5 months.
Go for .NET 6, which is both LTS and the latest and fastest .NET version, if you get to choose. And if you're using Visual Studio, .NET 6 is only supported by VS2022 and not previous versions.
Author of Lynx chess engine (GitHub, Lichess)
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 »

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.
dangi12012
Posts: 1062
Joined: Tue Apr 28, 2020 10:03 pm
Full name: Daniel Infuehr

Re: Visual Studio 2022: just installed

Post by dangi12012 »

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.
For runtime:
I had the experience that MSVC and CLANG produce almost the same speed software. But in other cases clang seems to be a bit faster. Both are better than gcc most of the time in terms of produced binary.

For compiletime:
MSVC has some insane template optimisations. I have a program that needs 10mins to compile with gcc and clang but msvc can do it in 30s. So there is something quadratic vs linear going on with the compiler/linker.

My recommendation:
For debugging and developing in Visual Studio stick with MSVC. It will work and be a good debugging experience.
When you have a finished C++ project you can test out all different compilers and see what settings with which compiler are fastest.
Oh and always try to stick to the standard. Compiler extentions are only that because you get stuck with one compiler and its not portable anymore.
Worlds-fastest-Bitboard-Chess-Movegenerator
Daniel Inführ - Software Developer
User avatar
mvanthoor
Posts: 1784
Joined: Wed Jul 03, 2019 4:42 pm
Location: Netherlands
Full name: Marcel Vanthoor

Re: Visual Studio 2022: just installed

Post by mvanthoor »

Mike Sherwin wrote: Tue Dec 07, 2021 4:52 am I'm wondering just how many of these type idiosyncrasies there would be in a fully developed chess engine?
Why would you get type errors? I've compiled many engines with both Clang and GCC (on Linux) without getting any errors or warnings.
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!
What sort of errors are you getting?
Author of Rustic, an engine written in Rust.
Releases | Code | Docs | Progress | CCRL
User avatar
Ras
Posts: 2696
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Visual Studio 2022: just installed

Post by Ras »

Mike Sherwin wrote: Tue Dec 07, 2021 4:52 amI really don't want my code littered with false errors.
Given that you also experience problems with whole program optimisation, you probably have undefined behaviour in your code, i.e. actual bugs through violating the language standard. C/C++ let you compile code with undefined behaviour, but it just may not do what's intended. That's exactly what compiler warnings are for, as help for the developer. I always compile with -Wall -Wextra and even -Werror so that any warnings are treated like errors, and the program won't build.
Rasmus Althoff
https://www.ct800.net
User avatar
MartinBryant
Posts: 83
Joined: Thu Nov 21, 2013 12:37 am
Location: Manchester, UK
Full name: Martin Bryant

Re: Visual Studio 2022: just installed

Post by MartinBryant »

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!
Chessnut1071
Posts: 313
Joined: Tue Aug 03, 2021 2:41 pm
Full name: Bill Beame

Re: Visual Studio 2022: just installed

Post by Chessnut1071 »

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!
????? 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.
User avatar
MartinBryant
Posts: 83
Joined: Thu Nov 21, 2013 12:37 am
Location: Manchester, UK
Full name: Martin Bryant

Re: Visual Studio 2022: just installed

Post by MartinBryant »

Chessnut1071 wrote: Wed Dec 08, 2021 2:50 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!
????? 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.
Colossus is a mix of C++ and C
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 »

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: