Compiler-level optimization

From HP-SEE Wiki

Revision as of 22:57, 20 April 2012 by Compphys (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Using GNU compilers

FORTRAN

Contributed by UKIM

1. Compiling

The general rule to make an executable file from free source fortran code in file with extension .f90 or .f95 is to run:

g95 myprog.f90 -o myprog

This creates the executable with filename "myprog" All include files should be present in the same directory.

2. Compiler options

One may try to invoke g95 with speed optimization option:

g95 myprog.f90 -o myprog -O2

Many other options are available however and one may wish to consult online docs repository at http://www.g95.org/docs.shtml If several subprograms (or modules) have be included in the main program, and compiled and recompiled many times during testing and debugging phase, one may wish to invest some time to learn to use "make"

3. Running the executable

With

$ myprog (or, for some configurations $ ./myprog) 

the executable runs interactively - the program have to exit (with DONE or with an ERROR) for the command prompt to reappear. With

$ myprog & 

the process runs into background. The screen output and (eventual) error messages may be redirected to corrseponding files with:

$ myprog 1>myoutput 2>myerrors &

4.Terminating the program

In case one wish to terminate the running program the following steps are advised:

$ ps -ax (to list the running processes with their PID)
$ kill -9 "process number"

Using IBM XL compilers

Section contributed by IICT-BAS

The IBM XL suite of compilers is deployed at the Blue Gene/P. The most important advantage of these compilers with respect to the GNU compiler collection is that they support the special features of the processors of Blue Gene/P that allow to double the floating point performance in double precision. Thus one should always try to compile with these compilers first. One should also remember that the compilation is in effect a cross-compilation, since it is done on the front-end node, which has slightly different architecture. The configure script or whatever build system is used, must be instructed to use the cross-compiler instead of the standard gcc or other, to perform compilation. Usually, it can be done by setting the environment variable like CC, F90, CXX, MPICC, MPIF90, MPICXX to point to the respective IBM XL compilers. The usual flags to achieve optimal result on the Blue Gene/P in Sofia are:

-O2 -qarch=450d -qtune=450

which specify the CPU architecture.

Intel® Parallel Studio XE development suite

Sun (Oracle Solaris) Studio

Section contributed by UPB

On the NCIT-Cluster systems we employ Sun Studio v12.1. The Sun Studio development tools include the Fortran95, C and C++ compilers. The best way to keep your applications free of bugs and at the actual performance level we recommend you to recompile your code with the latest production compiler. In order to check the version that your are currently using use the flag -V.

The commands that invoke the compilers are cc, f77, f90, f95 and CC. Actually, the command f77 invokes a script that is a wrapper and it is used to pass the necessary compatibility options, like -f77, to the f95 compiler. We recommend adding -f77 -trap=common in order to revert to f95 settings for error trapping. At the link step you may want to use the -xlang=f77 option(when linking to old f77 object binaries). For more information about the use of Sun (Oracle Solaris) Studio compilers you may use the man pages but you may also use the documentation found at:

http://www.oracle.com/technetwork/server-storage/solarisstudio/documentation/index.html

PGI

javac

Personal tools