mabalenk
mabalenk

Reputation: 1043

GNU Fortran architecture dependent compiler option

Is there a GNU Fortran compiler (v5.3.0) option to tune the code for a particular architecture? I'm especially interested in Intel Core i7. I could not find anything related to code tuning in the official option summary at GNU Fortran 5.3.0 Option Summary. I remember in the past there used to be an option -march=.... Thank you.

Edit:

I have found out the processor architecture with cat /proc/cpuinfo and visited the Intel CPU Specifications website to find out that I have Sandy Bridge CPUs. In my case the correct GNU option would be -march=sandybridge.

Upvotes: 0

Views: 584

Answers (3)

Anthony Scemama
Anthony Scemama

Reputation: 1593

All the information you are looking for is in the man page of gcc and not in the man page of gfortran :

man gcc

Upvotes: 2

i7 is not an architecture, SandyBridge, IvyBridge, Haswell and similar are architectures of Intel CPUs. And all of these architectures can have i3, i5, i7 or Xeon variants sold.

You can have two i7 CPUs, one older and one more recent and they can have different architectures.

In GCC (the whole suite for C, C++, Fortran...) has options -march and -mtune (see https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html#x86-Options ) With march the compile code will only run on the specified architecture and newer. With mtune it will run on older, but will be somehow optimized for the specified one.

You can use native and the compiler will use the architecture of your current CPU. Or you can specify some architecture manually, like -march=haswell, -march=ivybridge or -march=core-avx-i.

Be aware you need a recent version of compiler to optimize for new CPU architectures.

Upvotes: 2

Mohammed Li
Mohammed Li

Reputation: 901

I assume -march=native does not work?

edit: tried hello world with gcc 5.3, it does compile with the option, don't know though, if it improves things.

Upvotes: 1

Related Questions