Compiling
From athena
MPI Users: Also check out the Using MPI section for MPI-specific compilation instructions.
FYI: SOME FOLKS ARE HAVING PROBLEMS WITH THE MKL
Athena has both GNU and Intel compiler sets installed (both Intel C++ and Fortran). We strongly recommend using the Intel compilers. For full information on the Intel compilers, see the Intel website.
Some quick links to Intel compiler documentation:
- Documentation for Intel C++ Compiler v10 for Linux
- Documentation for Fortran C++ Compiler v10 for Linux
Athena is an IA-64 architecture system.
Contents |
[edit] Compiling serial programs with the Intel compilers
Where to find software:
/opt/intel/ # Intel Compilers
[edit] Shell variable setup
By using the "vars" shell script in the appropriate Intel compilers directory, you will add the compiler and libraries to your environment. You must do this in order to use the Intel compilers (at least in serial...when using MPI it does not appear that you need to execute these shells if you have gone through the MPI setup).
In the following example, the user is sourcing the bash shell ifortvars to set up the Intel Fortran compiler and libraries:
source /opt/intel/fce/10.1.011/bin/ifortvars.sh
To do the equivalent for csh and tcsh:
source /opt/intel/fce/10.1.011/bin/ifortvars.csh
To use the C and C++ compiler:
source /opt/intel/cce/10.1.011/bin/iccvars.csh source /opt/intel/cce/10.1.011/bin/iccvars.sh
[edit] Compiling
To invoke the Intel Fortran, C or C++ compilers:
ifort myprogram.f icc myprogram.c icpc myprogram.cc
For more information on compiler flags and optimizations, consult the Intel online documentation or type "man icc" or "man ifort".
[edit] Intel Compiler Optimizations
Telling the compiler to try to optimize your code can potentially make your program run many times faster. Results will vary quite widely depending on the application, but it is almost always worth telling the compiler to optimize. Intel recommends that on this particular system, users start with the -O3
flag. This will invoke all "safe" optimizations ("safe" means that it is extremely unlikely to cause your code to misbehave). The most aggressive optimization is -fast
which also allows the compiler to not comply to IEEE floating point accuracy with divides (which are traditionally quite expensive computationally). This may or may not be important to you, so always test code compiled with the -fast
option against and unoptimized version.
A summary of useful optimizations:
-
-O | -O1 | -O2 | -O3
Successive levels of "safe" optimization, with-O
being the lowest and-O3
being highest. -
-O3 -ipo -static -xT
This is more aggressive than-O3
and is the highest level of optimization that you can have while still demanding IEEE floating point accuracy. -
-fast
Equivalent to the above with the addition of the option-no-prec-div
that specifies that a faster division method will be used that produces slightly less than the precision demanded by the IEEE specification.
[edit] Implementation notes
The Intel ROLL has been installed so all of the libraries are in the same subdirectories on all of the nodes.
[edit] Compiling OpenMP Programs
To compile and link an OpenMP program in Fortran or C, use the "-openmp" option:
ifort -openmp myprogram.f icc -openmp myprogram.f
To run an OpenMP program, you must request 1 node (OpenMP will only work on a single node), but ask for a number of processors equal to the number of OpenMP threads you intend to run.