icc vs g++

K

Klaas Vantournhout

Hi,

I was wondering about the following.
How can I write a programme that can be compiled both with g++ and icc,
but when compiled it does this automatically with the optimized math
libraries and complex libraries and so on.

How would I do this?

Regards
Klaas
 
K

Klaas Vantournhout

Yes I am aware of this, and that is indeed the reason why I need to have
this. On AMD machines, I will compile with g++, while intel-based I
need the icc.

I know I can do this with makefiles, I mean i can set the compiler with
the makefile automatically, but within the code itself I would need to
change headers for optimization.

Like

#include <math>
becomes for intel
#include <mathimf>

are there other libraries that have similar intel libraries that are
optimised? And what about usage of SSE1,2,3 or MMX and more.
are you going to use the binary on intel-based machines only??
read this and you mind change mind about using the intel compilers...
http://yro.slashdot.org/yro/05/07/12/1320202.shtml?tid=142&tid=118&tid=123
[ AMD Alleges Intel Compilers Create Slower AMD Code ]

Klaas said:
Hi,

I was wondering about the following.
How can I write a programme that can be compiled both with g++ and icc,
but when compiled it does this automatically with the optimized math
libraries and complex libraries and so on.

How would I do this?

Regards
Klaas
 
E

ehilah

Klaas Vantournhout ha scritto:
Yes I am aware of this, and that is indeed the reason why I need to have
this. On AMD machines, I will compile with g++, while intel-based I
need the icc.

I know I can do this with makefiles, I mean i can set the compiler with
the makefile automatically, but within the code itself I would need to
change headers for optimization.

Like

#include <math>
becomes for intel
#include <mathimf>

are there other libraries that have similar intel libraries that are
optimised? And what about usage of SSE1,2,3 or MMX and more.
with #define .... and #ifdef and #ifndef ?
 
K

Klaas Vantournhout

ehilah said:
Klaas Vantournhout ha scritto:
with #define .... and #ifdef and #ifndef ?

Indeed, #if __INTEL_COMPILER would do the trick, there that is true.

But I was wondering what I need to change in the code itself. Where do
I need to make the changes.
 
M

Marcus Kwok

Klaas Vantournhout said:
Indeed, #if __INTEL_COMPILER would do the trick, there that is true.

But I was wondering what I need to change in the code itself. Where do
I need to make the changes.

Maybe you could create another header, like:

my_math.h
#ifdef __INTEL_COMPILER
#include <mathimf>
#else
#include <math> // probably should be <math.h> or <cmath>
#endif

Then in your actual code,
#include "my_math.h"
 
F

F.J.K.

Klaas said:
Yes I am aware of this, and that is indeed the reason why I need to have
this. On AMD machines, I will compile with g++, while intel-based I
need the icc.

Have you tried yet if icc is really slower for AMD than g++ is? This
should be the first thing to evaluate.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top