views:

961

answers:

6

I am not sure whether I should post this question here, because this seems to be a programming-oriented website.

Anyway, I think there must be some gurus here who knows this.

Now I have a AMD Opteron server running CentOS 5. I want to have a compiler for a fairly large c++ Boost based program. Which compiler I should choose?

+10  A: 

There is an interesting PDF here which compares a number of compilers.

Goz
Psssstttttt....I was just about to post that. It really only discusses micro optimization, and seems to imply that gcc is better that icc in most cases.
dmckee
Aye its an interesting document on that front. I wish you could get Visual astudio integration for GCC. That would be the mutt's nuts ...
Goz
+1  A: 

I used to work on a fairly large signal processing system which ran on a large cluster. We used to reckon for heavy maths crunching, the Intel compiler gave us about 10% less CPU load than GCC. That's very unscientific but it was our experience (that was about 18 months ago).

What would have been interesting is if we'd been able to use Intel's math libraries as well which use their chipset more efficiently.

Benj
+8  A: 

The MySQL team posted once that icc gave them about a 10% performanct boost over gcc. I'll try to find the link.

In general I've found that the 'native' compilers perform better than gcc on their respective platforms

edit: I was a little off. Typical gains were 20-30% not 10%. Some narrow edge cases got a doubling of performance. http://www.mysqlperformanceblog.com/files/presentations/LinuxWorld2004-Intel.pdf

Glen
+3  A: 

We use the Intel compiler on our product (DB2), on Linux and Windows IA32/AMD64, and on OS X (i.e. all our Intel platform ports except SunAMD).

I don't know the numbers, but the performance is good enough that we:

  • pay for the compiler which I'm told is very expensive.
  • live with the 2x times slower build times (primarily due to the time it spends acquiring licenses before it allows itself to run).
Peeter Joot
+2  A: 

I suppose it varies depending on the code, but with the codebase I am working on now, ICC 11.035 gives an almost 2x improvement over gcc 4.4.0 on a Xeon 5504.

icc options: -O2 -fno-alias
gcc options: -O3 -msse3 -mfpmath=sse -fargument-noalias-global

The options are specific to just the file containing the compute-intensive code, where I know there is no aliasing. Single-threaded code with a 5-level nested loop.

Although autovectorization is enabled, neither compilers generate vectorized code (not a fault of the compilers)

Gautham Ganapathy
Sorry, that should have been -fargument-noalias-global for gcc, not -fno-alias
Gautham Ganapathy
Thank you for posting this. After I read your article, I tried out your gcc options. I had tried my program with `-O3` without noticing much of an improvement, but `-O3 -msse3` made a *huge* improvement on my program! The stuff I'm doing (audio DSP) is fairly vectorizable, but I haven't looked at the generated code yet. But my program passes its test suite, and does it in under 2/3 the time it did before!
steveha
@steveha Cool! Additionally, try using -fargument-noalias-global if you know there is no aliasing in the code, or selectively restrict your pointers using the restrict keyword. This gives the compiler much more flexibility in reordering instructions. Gave a huge performance boost when I was optimizing some video code for a TI DSP
Gautham Ganapathy
Note that `-mfpmath=sse` is the default when the target is x86-64. Also, `-march=native` is usually a good way to take advantage of your hardware. Occasionally (usually only with the latest instruction set), this causes a minor slowdown, perhaps because there hasn't been enough time to tune for that instruction set.
Jed
+2  A: 

I hope this helps more than hurts :)

I did a little compiler shootout sometime over a year ago, and I am going off memory.

  1. GCC 4.2 (Apple)
  2. Intel 10
  3. GCC 4.2 (Apple) + LLVM

I tested multiple template heavy audio signal processing programs that I'd written.

Compilation times: The Intel compiler was by far the slowest compiler - more than '2x times slower' as another posted cited.

GCC handled deep templates very well in comparison to Intel.

The Intel compiler generated huge object files.

GCC+LLVM yielded the smallest binary.

The generated code may have significant variance due to the program's construction, and where SIMD could be used.

For the way I write, I found that GCC + LLVM generated the best code. For programs which I'd written before I took optimization seriously (as I wrote), Intel was generally better.

Intel's results varied; it handled some programs far better, and some programs far worse. It handled raw processing very well, but I give GCC+LLVM the cake because when put into the context of a larger (normal) program... it did better.

Intel won for out of the box, number crunching on huge data sets.

GCC alone generated the slowest code, though it can be as fast with measurement and nano-optimizations. I prefer to avoid those because the wind may change direction with the next compiler release, so to speak.

I never measured poorly written programs in this test (i.e. results outperformed distributions of popular performance libraries).

Finally, the programs were written over several years, using GCC as the primary compiler in that time.

Update: I was also enabling optimizations/extensions for Core2Duo. The programs were clean enough to enable strict aliasing.

Justin
Could you elaborate on what you mean by 'for the way you write'?
int3
@int3 In brief, for optimized programs, I write: incredibly strictly/small, force the compiler to evaluate the program, provide specializations/overloads, go out of my way to achieve compile time polymorphism (vs. runtime), provide a much visibility to the compiler, use many language features as intended, const correctness, force inlining, have an incredibly long warning list. I measure and benchmark, no inline asm. Specific to the compiler shootout; I do stop before I rewrite programs to take advantage of vectorization/SIMD insns, (an area Intel's compiler excelled at). I hope that helps.
Justin