views:

404

answers:

6

Hello,

What is the fastest C++ compiler possible. I want to compile C++ version of LZMA. I did compile it using Visual Studio .NET, but it is not fast enough for my job. In addition, I need to change the Compiler settings in order to make it as fast as possible. I would appreciate if you introduce me a fast compiler and/or some information about its settings. I need the compiler to produce file that runs faster.

Thanks in advance, Shadi.

+4  A: 

It seems you're talking about generating code which runs fast - the Intel compiler has traditionally been the best compiler for Intel processors in that regard:

http://software.intel.com/en-us/intel-compilers/

Will Dean
+2  A: 
  1. Get a faster harddrive. Solid-state drives are fast.
  2. Disable all output optimizations.
  3. Use precompiled headers, if possible.
  4. Reduce dependencies and the use of templates.
  5. Test various compilers and see which compiler performs the fastest on your code.
strager
+6  A: 

The term "VC++" means literally "Visual C++" which is the name of a microsoft product. So natually, the only compiler for "VC++" is the microsoft one, cl.exe so the question is moot.

If you'd rather talk about a "C++ compiler", it is possible GCC is faster but that really depends on what you're compiling.

As for settings, usually if you disable all optimizations the compilation is generally faster but the executable you get is slower. Some compilers, like VC++ also have incremental linking which can speed up the final stage of compilation considerably and almost all decent compilers have precompiled headers which can also speed things up (but also slow them down for small projects)

shoosh
Beat me by 2 minutes. :P
Vilx-
Actually, I think I made a mistake in asking my question. I should have asked about "the fastest C++ compiler" instead of "the fastest VC++ compiler". so, what is the fastest C++ compiler and what are its optimization settings? I need compiler to generate code that runs faster (runtime).Thanks.
Shadi
+2  A: 

"Visual C++" is the name given to the compiler made by Microsoft. With each new version of Visual Studio there is a new version of the VC++ compiler as well, but there are no other "VC++ compilers" - by definition.

Now, I've got no idea which version of Visual Studio would compile your code fastest, or which one would generate the fastest code, but it's a good bet you want the latest there is. That, plus your code will probably not compile on a compiler older than the one it was meant for.

So my advice is - get the lastest Visual Studio there is (VS2010 if you're not afraid to experiment; VS2008 otherwise), and go through all the settings (with the help of manual/google) and tweak it as well as you can. That's the best you will get.

Also - Visual Studio exposes all the compiler switches through its UI, so you don't have to guess what you've missed.

Vilx-
Actually, I think I made a mistake in asking my question. I should have asked about "the fastest C++ compiler" instead of "the fastest VC++ compiler". so, what is the fastest C++ compiler and what are its optimization settings? I need compiler to generate code that runs faster (runtime).Thanks.
Shadi
@Shadi - alrighty then. :) Be more careful in the future. Remember - programmers are big nitpickers, comes with the job description. :)
Vilx-
A: 

Visual Studio .NET

That's because you compiled managed code, not native. When using Visual Studio, you need to set in the compiler "No CLR support.". This means that you will compile actual C++. Visual Studio 2010 is a fair step up from 2008, with performance enhancers like rvalue references.

DeadMG
Wherever from did you get the idea that he was compiling managed code?
Vilx-
A: 

It really matters whether you have some huge project that takes an hour to compile, and you would like to change compilers so it only takes 30 minutes to compile, or whether you are interested in the speed of the program produced by the compiler. These preferences are in direct opposition to each other. Just to give one example, optimizing takes time, so for faster compiles, turn it off, but for a faster application, turn it on.

I see in one of your clarifications you want faster running code. Different compilers make different assumptions in their optimizing, so your best bet is to test various versions. In general, the newer the compiler the better. You can also tweak your settings - set up custom builds or makes that turn particular features on and off - and see the effect.

VC++-specific things to consider: if you use a lot of template libraries (especially std:: stuff) then VC++ 2010 is going to help you, because it supports rvalue references which enables some dramatic speedups. That's not about the compiler exactly, more about the libraries that ship with it, but I'm going to assume you're using "compiler" to mean "brand name of tools I write, compile, and link with code with". Also PGO, profile guided optimization, lets you run the app under instrumentation and then apply profile information gathered on those runs to re-optimize your code so that it performs well under your circumstances. That's been in VC++ for a number of versions now. Perhaps someone else can speak to other compilers and those two features.

Kate Gregory