Which is the best compiler for Windows Executables

Discussion of chess software programming and technical issues.

Moderator: Ras

OliverBr
Posts: 794
Joined: Tue Dec 18, 2007 9:38 pm
Location: Munich, Germany
Full name: Dr. Oliver Brausch

Which is the best compiler for Windows Executables

Post by OliverBr »

Hello :)

Which compiler is known to create the fastest engine code for Windows platforms?

I have been using Visual Studio before and my engine underperforms a little with the executable compared to MacOSX or Linux. Thus is would like to try another Windows compiler.

Any tip would be very helpful.
Thank you a lot!
Chess Engine OliThink: http://brausch.org/home/chess
OliThink GitHub:https://github.com/olithink
User avatar
j.t.
Posts: 263
Joined: Wed Jun 16, 2021 2:08 am
Location: Berlin
Full name: Jost Triller

Re: Which is the best compiler for Windows Executables

Post by j.t. »

When I compiled with clang on Windows, the binaries executed with wine on Linux are almost as fast as the native Linux exes.
Joost Buijs
Posts: 1632
Joined: Thu Jul 16, 2009 10:47 am
Location: Almere, The Netherlands

Re: Which is the best compiler for Windows Executables

Post by Joost Buijs »

I use Clang on Windows too, typically executables are approx. 10% faster when compiled with Clang. It won't make the difference between winning or losing a game though.

Each compiler has it's own strength and weaknesses, imo MSVC has better error checking, so I often use both.
User avatar
j.t.
Posts: 263
Joined: Wed Jun 16, 2021 2:08 am
Location: Berlin
Full name: Jost Triller

Re: Which is the best compiler for Windows Executables

Post by j.t. »

Joost Buijs wrote: Sun Jun 04, 2023 5:19 pm Each compiler has it's own strength and weaknesses, imo MSVC has better error checking, so I often use both.
I do the same with GCC and Clang, while they're quite similar, they both have some warnings that the other one doesn't have.
OliverBr
Posts: 794
Joined: Tue Dec 18, 2007 9:38 pm
Location: Munich, Germany
Full name: Dr. Oliver Brausch

Re: Which is the best compiler for Windows Executables

Post by OliverBr »

Joost Buijs wrote: Sun Jun 04, 2023 5:19 pm I use Clang on Windows too, typically executables are approx. 10% faster when compiled with Clang.
Thank you for the tip. I can confirm it: It's almost 10% faster with Clang.
BTW, I had to install Visual Studio, too. Clang wouldn't work without it.

OlIThink 5.10.2 Win64 and MacOSX executables are not available on my chess homepage. 5.10.2 source on the homepage and github.
Chess Engine OliThink: http://brausch.org/home/chess
OliThink GitHub:https://github.com/olithink
MOBMAT
Posts: 396
Joined: Sat Feb 04, 2017 11:57 pm
Location: USA

Re: Which is the best compiler for Windows Executables

Post by MOBMAT »

Did you compile the Visual Studio build with all the optimizations for speed turned on?

that is the /Ox command line option. you can tweak various settings through the GUI.

Also look for functions that can be good candidates for "inline". functions marked with "inline" will be candidates for inlining by the cost/benefit feature of the compiler.
i7-6700K @ 4.00Ghz 32Gb, Win 10 Home, EGTBs on PCI SSD
Benchmark: Stockfish15.1 NNUE x64 bmi2 (nps): 1277K
rickpo
Posts: 2
Joined: Tue Jul 20, 2021 9:20 am
Full name: Rick Powell

Re: Which is the best compiler for Windows Executables

Post by rickpo »

A couple years ago I tried the Intel C++ compiler and got significantly better speed compared to the MS compiler. I was pretty impressed with it. But it didn't come bundled with VisualStudio 2022, so and I haven't tried it since 2022 came out.
User avatar
Ras
Posts: 2695
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Which is the best compiler for Windows Executables

Post by Ras »

rickpo wrote: Tue Jun 06, 2023 6:36 amA couple years ago I tried the Intel C++ compiler and got significantly better speed compared to the MS compiler.
Back then, the Intel compiler deliberately sabotaged performance on AMD CPUs by not checking the supported instruction set, but by checking for specific Intel models. Intel didn't even disclose that until the FTC forced them. It seems this has changed because Intel has moved to Clang, provided you use the correct compiler options, but then the performance advantage it once had on Intel CPUs is also pretty much gone. See also: https://www.agner.org/forum/viewtopic.php?t=6
Rasmus Althoff
https://www.ct800.net
User avatar
Bo Persson
Posts: 256
Joined: Sat Mar 11, 2006 8:31 am
Location: Malmö, Sweden
Full name: Bo Persson

Re: Which is the best compiler for Windows Executables

Post by Bo Persson »

MOBMAT wrote: Mon Jun 05, 2023 7:54 pm Did you compile the Visual Studio build with all the optimizations for speed turned on?

that is the /Ox command line option. you can tweak various settings through the GUI.
Oddly enough, while /Ox specifically enables speed optimizations, the option /O2 also enables other optimizations that can improve execution speed as well. Lately this has been documented as the way to get the most performance out of the compiler.

https://learn.microsoft.com/en-us/cpp/b ... w=msvc-170
MOBMAT
Posts: 396
Joined: Sat Feb 04, 2017 11:57 pm
Location: USA

Re: Which is the best compiler for Windows Executables

Post by MOBMAT »

yes, it also depends on which version of VS you are using. The latest (2022?) has some additional optimizing features.
i7-6700K @ 4.00Ghz 32Gb, Win 10 Home, EGTBs on PCI SSD
Benchmark: Stockfish15.1 NNUE x64 bmi2 (nps): 1277K