Intel Fortran Compiler

来源:互联网 发布:杭州初级程序员薪资 编辑:程序博客网 时间:2024/05/22 01:41

Intel Fortran Compiler

Skip to end of metadata
Go to start of metadata

We have installed the Intel compiler suite on the DSCR, including C, C++, Fortran 77, and Fortran 90. These compilers may provide a significant performance boost to almost any program, simply by recompiling your source code. Since it has deep knowledge of the CPU microarchitecture, it is able to better schedule instructions, make better use of cache, and potentially incorporate SSE (SIMD) acceleration.  See also Using the Intel Compiler.

Compiler Location

The Intel compilers are located in the /opt/apps/intel directory. To easily access the compilers, simply add the folowing to .cshrc or .bashrc file:

  • for csh/tcsh users, edit your .cshrc file and include the following line:

source /opt/apps/intel/intelvars.csh

  • for sh/bash uses, edit your .bashrc file and include the following line:
. /opt/apps/intel/intelvars.sh
(period space /opt/apps/intel/intelvars.sh)

That will alter your path so you can locate the executables and also set some environment variables so that the Intel tools can locate related files – once you include that file you should be ready to run any of the tools!   As a quick test, try the following at a command prompt:

% which ifort
/net/filer.../apps/el6/intel/versions/.../bin/intel64/ifort

Note that 'ifort' provides both Fortran 77 and 90 (and 95), it will use the filename extent (.f, .f77, .f90, etc.) to determine the standard to compile against. 

Basic Compilation

You can invoke the compiler just by replacing 'g77' with 'ifort' in your normal build process:

ifort -o file.o -c file.f

If your program builds through a standard 'makefile', you may try:

make FF=ifort

In many cases, this will swap the standard (g77) compiler with the Intel compiler for all portions of the build process. If that doesn't work for your application, you may need to modify the makefile or make other adjustments.

The main issues you're likely to have are if you've used any command-line arguments to 'gcc', e.g. for optimization.

option

gcc flag

ifort flag

optimization

-O

-O

max. optimization

-O3 or -O5

-O3 or -fast

optimize for current host

 

-xHost

look for SSE optimizations

 

-axAVX

try to prefetch memory

 

-opt-prefetch

inter-procedure optimizations

 

-ipo

profile-guided optimizations

 

-prof-gen

 

 

-prof-use

optimization report

 

-opt-report=3

SSE report

 

-vec-report=3

See also Intel Compiler Optimizations

A good starting point is generally:

% ifort -fast -axAVX -o code.o -c code.f

This will product a highly optimized (-fast) "base" code, and then include alternate code-paths for AVX and SSE (if the run-time CPU supports them).  If you leave out the -axAVX, your code will be optimized ONLY for the CPU you compiled on (in the DSCR, the login machines are often a year or two behind the current "best" CPU).

NOTE: when using the '-ipo' option, be sure to recompile all of your code with '-ipo' for maximum effect. Since this specifically kicks-in optimizations that can happen ACROSS procedures or functions, it makes sense to enable that for as many functions as possible.

Profile-Guided Optimization

Since a compiler could encounter any kind of code, it must make certain assumptions or guesses when it decides to optimize or not optimize a section of code. The Intel compilers allow you to compile a test-program and then run it, capturing an information trace as it runs. A second invocation of the compiler can then read in that trace file and make better assumptions, potentially giving you better performance.

First, do a basic compilation:

ifort -prof-gen -o prog.exe prog.f

Next, run the program on a sample dataset:

./prog.exe -flags input.dat

Finally, recompile the code:

ifort -prof-use -o prog.exe prog.f

Note that if you are building the program with a 'makefile', you may need to remove all object files (.o files) before re-building to ensure that you actually recompile everything – if 'make' sees prog.o, it may not invoke the compiler the second time.

Optimized Intel Libraries

We also have several of the Intel libraries installed. These provide highly optimized routines for a wide range of functions – linear algebra, signal/image/video processing, statistics, etc.

See the Intel Tools page for more info.

https://wiki.duke.edu/display/SCSC/Intel+Fortran+Compiler