It's been 15+ years since I delved into this so curious how things are now. Do different compilers produce better/faster executables than others nowadays? I remember years ago, I often would use the Intel icc compile over gcc for that very reason. Granted your source is where the best improvements can be made, but if one compiler or another yields an extra 5-10% speed that would be good to know. If so what are the best per OS and architecture?
Microsoft better than cygwin in Windows for x86? Are there ARM specific compilers that are better than gcc-arm for Linux?
Compiler Speed Nowadays
Moderators: hgm, Rebel, chrisw
-
- Posts: 1342
- Joined: Wed Mar 08, 2006 9:41 pm
- Location: Morgantown, WV, USA
-
- Posts: 12541
- Joined: Wed Mar 08, 2006 8:57 pm
- Location: Redmond, WA USA
Re: Compiler Speed Nowadays
I use Mingw gcc and g++ with profile guided optimization and microsoft visual studio c and c++
Optimization options are very important. For recent AMD cpus, avx2 optimization is pure magic.
But it varies a lot from program to program.
I think that a few percent of speed difference is not as important as your familiarity with the tool set.
If you use code::blocks with msys2, there is really not much difference from microsoft's compiler.
A tool set that is comfortable for you to use is much more important than a tiny linear speedup.
If you should achieve a 4% boost, the next iteration of the other compiler might ourstrip it.
Since you need to spend a lot of money to get the MS professional version of the compiler (with profiler and other special tools) that is something to consider as well.
Optimization options are very important. For recent AMD cpus, avx2 optimization is pure magic.
But it varies a lot from program to program.
I think that a few percent of speed difference is not as important as your familiarity with the tool set.
If you use code::blocks with msys2, there is really not much difference from microsoft's compiler.
A tool set that is comfortable for you to use is much more important than a tiny linear speedup.
If you should achieve a 4% boost, the next iteration of the other compiler might ourstrip it.
Since you need to spend a lot of money to get the MS professional version of the compiler (with profiler and other special tools) that is something to consider as well.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
-
- Posts: 1563
- Joined: Thu Jul 16, 2009 10:47 am
- Location: Almere, The Netherlands
Re: Compiler Speed Nowadays
I'm developing under Windows with Visual Studio and use 3 compilers: MSVC 14.2, CClang 10/11 and the new Intel oneAPI C++ compiler.
On average there is not much difference between the 3 compilers, when I target one of these new Intel >= cascade-lake processors the Intel compiler clearly wins, for AMD procesors the Intel compiler is a no go.
The difference between MSVC and CLang is very small, I have the impression that CLang is somewhat better at vectorizing tiny loops, but on my chess engine as a whole the speed difference is negligible.
So for Intel processors it is best use the Intel compiler, for AMD processors use MSVC or CLang. I never tried GCC though, when I look at benchmarks on the internet there doesn't seem to be much difference in performance between GCC and CLang, one of the reasons I never tried.
On average there is not much difference between the 3 compilers, when I target one of these new Intel >= cascade-lake processors the Intel compiler clearly wins, for AMD procesors the Intel compiler is a no go.
The difference between MSVC and CLang is very small, I have the impression that CLang is somewhat better at vectorizing tiny loops, but on my chess engine as a whole the speed difference is negligible.
So for Intel processors it is best use the Intel compiler, for AMD processors use MSVC or CLang. I never tried GCC though, when I look at benchmarks on the internet there doesn't seem to be much difference in performance between GCC and CLang, one of the reasons I never tried.
-
- Posts: 12541
- Joined: Wed Mar 08, 2006 8:57 pm
- Location: Redmond, WA USA
Re: Compiler Speed Nowadays
Clang has the best diagnostics. It's every bit as good as using lint.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
-
- Posts: 1784
- Joined: Wed Jul 03, 2019 4:42 pm
- Location: Netherlands
- Full name: Marcel Vanthoor
Re: Compiler Speed Nowadays
In my case, with regard to development tools, I refuse to use anything that is paid or not cross platform. I don't want to write an engine that needs a huge code change to run on Linux or the Mac (even though I'll probably never have a Mac), and I don't want to change editors if I should ever switch from Windows to Linux for development work.
Therefore I use GCC and Clang, for C/C++ when compiling engines written in those languages (and then I pick the fastest binaries), and Rust for my own projects. (rustc + gnu linker is basically the same as Clang, but with Rust instead of C as a programming language.)
Therefore I use GCC and Clang, for C/C++ when compiling engines written in those languages (and then I pick the fastest binaries), and Rust for my own projects. (rustc + gnu linker is basically the same as Clang, but with Rust instead of C as a programming language.)
-
- Posts: 1563
- Joined: Thu Jul 16, 2009 10:47 am
- Location: Almere, The Netherlands
Re: Compiler Speed Nowadays
I don't care much about development software being cross platform or not. I try to keep most things in my sources cross-platform by using the C++ libraries and headers, this works for most things except for some things like socket IO.mvanthoor wrote: ↑Mon Dec 28, 2020 4:50 pm In my case, with regard to development tools, I refuse to use anything that is paid or not cross platform. I don't want to write an engine that needs a huge code change to run on Linux or the Mac (even though I'll probably never have a Mac), and I don't want to change editors if I should ever switch from Windows to Linux for development work.
Therefore I use GCC and Clang, for C/C++ when compiling engines written in those languages (and then I pick the fastest binaries), and Rust for my own projects. (rustc + gnu linker is basically the same as Clang, but with Rust instead of C as a programming language.)
To be honest I have the feeling that development tools under Linux are so cumbersome compared to Visual Studio that I don't want to step away from it. When I really like a piece of software I'm always willing to pay for it, I don't want everything for free.
-
- Posts: 481
- Joined: Tue Jul 03, 2018 10:19 am
- Full name: Folkert van Heusden
Re: Compiler Speed Nowadays
I have that feeling with visual studio: "you can do everything with it!" "oh, no you can't do that, maybe if you buy x" "oh and you can't do that, oh and you can't script around it". "haha and of course you can't use vi/emacs as your editor, the build-in notepad is perfect!".Joost Buijs wrote: ↑Tue Dec 29, 2020 5:43 pm To be honest I have the feeling that development tools under Linux are so cumbersome compared to Visual Studio that I don't want to step away from it. When I really like a piece of software I'm always willing to pay for it, I don't want everything for free.
-
- Posts: 300
- Joined: Mon Apr 30, 2018 11:51 pm
Re: Compiler Speed Nowadays
As a Linux user who sometimes has to use Visual Studio, I can assure you, the feeling is mutualJoost Buijs wrote: ↑Tue Dec 29, 2020 5:43 pm To be honest I have the feeling that development tools under Linux are so cumbersome compared to Visual Studio that I don't want to step away from it.
-
- Posts: 2559
- Joined: Fri Nov 26, 2010 2:00 pm
- Location: Czech Republic
- Full name: Martin Sedlak
Re: Compiler Speed Nowadays
The only thing I'm missing on Linux is a good C/C++ IDE.
VS (despite the insane amount of bugs) is so far the best IDE out there. Tried CodeBlocks, CLion, QtCreator, XCode on Mac, nothing comes even close.
The most important part (for me) is actually debugging, this is where VS is exceptional. natvis (pretty printing custom types) + conditional breakpoints, watches that actually work and so on.
Try debugging in CodeBlocks for example - a nightmare.
Of course IDE != vim+gdb, as some masochists would think
So if someone has actually a suggestion about a good C++ IDE for Linux, I'm all ears.
I really like Linux a lot - compiler toolchain is awesome, with sanitizers that actually work, unix shell and kernel, no "case agnostic" fs and more and more...
the only thing I actually hate about Linux would be all the toxic Linux fanboys
as for the OP's question: try and see, msc, gcc, clang, whatever works best for you. compilers gotten really amazing these days.
and, if you don't already know, try godbolt.org, where you can examine the assembly generated by various compilers
VS (despite the insane amount of bugs) is so far the best IDE out there. Tried CodeBlocks, CLion, QtCreator, XCode on Mac, nothing comes even close.
The most important part (for me) is actually debugging, this is where VS is exceptional. natvis (pretty printing custom types) + conditional breakpoints, watches that actually work and so on.
Try debugging in CodeBlocks for example - a nightmare.
Of course IDE != vim+gdb, as some masochists would think
So if someone has actually a suggestion about a good C++ IDE for Linux, I'm all ears.
I really like Linux a lot - compiler toolchain is awesome, with sanitizers that actually work, unix shell and kernel, no "case agnostic" fs and more and more...
the only thing I actually hate about Linux would be all the toxic Linux fanboys
as for the OP's question: try and see, msc, gcc, clang, whatever works best for you. compilers gotten really amazing these days.
and, if you don't already know, try godbolt.org, where you can examine the assembly generated by various compilers
Martin Sedlak
-
- Posts: 1342
- Joined: Wed Mar 08, 2006 9:41 pm
- Location: Morgantown, WV, USA
Re: Compiler Speed Nowadays
Eclipse is pretty good and cross environment. I started using it for Java but they have a C/C++ version as well. Personally I say use whatever is most comfortable for you and effective. Goal is to fight the task at hand, not the tools to get there. Cheers.
Thanks!