Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am programming a code to simulate a membrane which will run on computation cluster (single node). I want to optimize the code for that machine. I have used the -optimize, -O3 and -march=core2.

How can I tell if I can improve the march factor and is there any other thing I can do to improve this?

thanks

share|improve this question
3  
What compiler are you using? –  Let_Me_Be Sep 27 '11 at 8:28
2  
Wait, I thought you meant GCC, but -optimize? What compiler has such option? –  rozcietrzewiacz Sep 27 '11 at 8:59
    
I am using g++. I have placed it there after reading this in some documentation (the code compiles) –  Yotam Sep 27 '11 at 16:42
add comment

3 Answers 3

up vote 6 down vote accepted

Use -mtune. -march is used to determine the allowed instruction set, whereas -mtune is to be used to tune performance of the code (as always, see man gcc). Depending on the precise CPU type, you might also consider values other than core2. And if you use a recent GCC version (at least 4.4, I think), you might best use native instead.

share|improve this answer
    
How can I tell which cpu type I have? I tried to use the native switch but the compiler doesn't know this... –  Yotam Sep 27 '11 at 16:54
    
On the system-side, cat /proc/cpuinfo will give you enough information. Using this, you can google for -march/-mtune recommendations. But a better option might be to just upgrade your GCC and use -march=native -mtune=native. –  rozcietrzewiacz Sep 27 '11 at 17:28
    
upgrading gcc is not an option since I am not the root of the machine (or the cluster). –  Yotam Sep 27 '11 at 17:43
    
I have a 4 core processor with: model name : Intel(R) Core(TM) i7 CPU 860 @ 2.80GHz. I tried to use corei7 but it won't compile. gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html –  Yotam Sep 27 '11 at 17:49
1  
Better first read what you are referring to. The source you linked states clearly that It corresponds to the compilers (GCC) version 4.7.0. If native does not work, it must be a few years old, much older than the processor. Ask the administrator for an update if you really need such top performance. –  rozcietrzewiacz Sep 27 '11 at 18:28
show 2 more comments

The best thing is to read the manual for your compiler and look at the optimisation options. Note that some optimisation will not give you much, so you must test your code after it has been compiled. Note that you may notice bugs in the code depending on what options you choose.

If you use icc, you can make sure of some #pragma options in the code to paralelise some loops.

share|improve this answer
add comment

If your computations involve many vectors, you may want to consider the Intel Math Library. A project I am on for work uses it and they swear by it.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.