Compilers & Numerical Libraries

(modified 9/15/2003)


Installed on the group machines are C, C++, Fortran 77 and Fortran 90 compilers, as well as various numeric libraries such as BLAS, LAPACK, and FFT routines.

On this page we'll cover what one can expect to be installed, and how to use the compilers. Unfortunately, due to the variety of platforms, the invocation of the compilers and linking of the libraries will vary depending on the platform. These pages will focus on Linux, since we are migrating toward Linux as a consistent OS, though different processors.

GCC (GNU Compiler Collection)

GCC is the GNU compiler collection, and is a ubiquitous open source compiler available on nearly every conceivable platform. The versions present on most machines are 3.2 or 3.3 (the default) and
2.95. The 3.3 version is about as fast or  faster than the 2.95 version, but is much more standard and feature rich. However, some code that was written for 2.95 and can't be compiled with later version remains, and so the 2.95 is usually still installed alongside the latest version.

GCC doesn't  have the same optimizing capabilities as vendor compilers, but is feature-rich and very consistent across platforms. GCC has three relevant compilers: gcc is the C compiler, g++ the C++ compiler, and g77 a FORTRAN77 frontend that really just translates fortran to C and compiles it.

GCC is usually the place to start with your code, since it integrates well with Linux, has a number of good debugging tools,  and is often "good enough." Once things work correctly, a switch to a faster compiler is often as easy as changing compiler options.

In general, for most simulation purposes it's best to statically link your code (use the libxxx.a libs instead of libxxx.so); this produces much larger code, but saves time in resolving function calls, which on Intel and AMD (Athlon) processors, which is poor in registers, can produce significantly faster execution.

Platform and purpose
command line (replace gcc by g++ or g77)
C compiling for debugging and profiling purposes
gcc -static -g3 -pg  -O  -Q
C compiling for speed on alphas
gcc -O3 -mcpu=ev6
C compiling for speed on Athlons
gcc -O2 -fomit-frame-pointer -malign-double -mcpu=athlon-xp
C compiling for speed on Pentium 4
gcc -O2 -fomit-frame-pointer -malign-double -mcpu=pentium4


Compaq Compilers

Fortran :
C
C++

Compaq has released compilers for Linux on the alpha processor, but since the alpha is essentially a dead platform, they haven't been updated for two years or so. However, they should compile much faster code than gcc. They are essentially a linux port of the Tru64 (DEC Unix) native copmilers, and so the compilers options are mostly the same.

The fortran compiler fort is fully FORTRAN90 compliant. The C compiler ccc, and as a result the C++ compiler cxx, has a small incompatibilty with later version of glibc on Debian, and as such may need a little more help to get code to compile.

Purpose (all on Linux alpha platform)
command line
Fortran 90 for speed
fort -fast -static
Fortran 77 for speed
fort -f77 -fast -static
Fortran for debugging
fort  -g3 -ladebug
C compiling for speed on Pentium 4



Intel Compilers

Fortran :
C/C++

Intel makes available Fortran 90 and C/C++ compilers for Intel platforms, and specifically is about the only way to exploit the optimizations in the Pentium 4 processor.

One problem with the present version (7.1) is that is incompatible with RedHat 9.0. To workaround this, I've setup a compatibility environment. This however makes libraries that are compiled with gcc and intel compilers incompatible at this point, so they can't be mixed. This should be resolved in the next version of the Intel compilers.


Purpose (all on Linux alpha platform)
command line
Fortran 90
ifc  -O3 -xK -static 
Fortran 77 for speed
ifc -w -O3 -xK -static
Fortran for speed on Pentium 4 only
ifc  -O3 -xW -static
Fortran for debugging
ifc -w -static -pg -C -vec_report5







Numeric Libraries

This section covers various standard numeric libraries and their incarnation as vendor supplied versions on the group machines.

LAPACK/BLAS


These are usually available as vendor tuned libraries, so to link them in, you'll need to know the compiler you're using and what platform you are on. In addition, they may be separated into different libraries depending on processor version etc., so below we list a variety of command line options for successfully linking in these libraries.

However, the naming and usage of the routines is fairly standardized, so compiling between platforms should for the most part involve a change in command line options alone.

Because of the age of the CXML library on Alpha Linux, compiling with g77 and linking in the CXML libs seems to not be entirely compatible and produces run time errors. Best to stick with Alpha compiler when using CXML it seems.

Purpose
command line
MKL: general link order for static linking  on Intel architectures
 (...)  -lmkl_lapack -lmkl_ia32 -lguide -lpthread
G77 compiling on Alpha Linux using ATLAS routines
g77 -O3  -static code.f  -o out -llapack -lf77blas -latlas 
G77 compiling on Alpha Linux using CXML routines (not a good idea)
g77 -O3  -static code.f  -o out  -lcxml -lcpml -lots
G77 compiling on Intel Linux using MKL routines
g77 -O3 -malign-double -static code.f  -o out  -lmkl_lapack -lmkl_ia32 -lguide -lpthread
Fortran compiling on Intel Linux with LAPACK etc. routines in MKL
ifc -O3 -xK -static -lmkl_lapack -lmkl_ia32 -lguide -lpthread
Fortran compiling on Alpha Linux with LAPACK etc. routines in CXML libs
fort -fast -static -lcxml

Purpose
command line
MKL: general link order for static linking  on Intel architectures
 (...)  -lmkl_lapack -lmkl_ia32 -lguide -lpthread












ARPACK

ARPACK is an open source library for solving sparse linear algebra systems. It should be installed on most machines.

SuperLU

Library for performing Gaussian Elimination

FFTW

FFTW is most likely the fastest FFT implementation out there, often faster than vendor tuned libraries. It

Other FFT Libraries

Both the MKL and CXML vendor libraries have FFT and DFT routines. Unfortunately they aren't source compatible. Refer to the docs on each for usage:

Other Basic Libraries

CPML (Compaq Portable Math Library)