Intel Compilers
Intel compilers produce efficient executables for Intel blades and allow linking
to the intel mkl math libraries. Linking object files to produce an
executable sometimes requires shuffling the order in which the object
files are listed, or listing object files multiple times.
64 bit Intel compiled executables for AMD blades
encounter run time errors.
To use the Intel compilers it is necessary
to properly configure some environment
variables and paths.
As a convenience an alias - add - has been created
for tcsh users to set up the environment for various
software packages. To use the Intel compilers from the 64 bit login
nodes, the command
add intel_mpich2_hydra-101
gives access to mpich2 libraries which are most reliable
for passing large messages in distributed memory parallel MPI
codes. From either 32 or 64 bit nodes, using
add intel
will set the necessary environment variables for compiling and linking
to mpich1 libraries.
Currently the command 'add intel' will set up the
environment for version
10.1 of the Intel compiler. 'add intel' is equivalent to
'source /usr/local/apps/env/intel.csh'. To use older
versions of the intel complers, look in the /usr/local/apps/env
directory for other intel*.csh files and try the corresponding
`add` commands.
Once one of these files have been executed, the Intel
compilers may be invoked with the icc, icpc,
and ifort commands for the C, C++, and Fortran77/90
compilers respectively.
Intel 7.1 compilers were invoked with icc for the
C/C++ compiler and ifc for the Fortran compiler.
Compiling a Serial Program
The following command would generate an executable named
'exec' from the Fortran source code file named 'code.f'
with a moderately high level of optimization.
ifort -O3 -axW -o exec code.f
Compiling a Multi-Core Program
Intel Compilers can generate shared memory parallel executables,
e.g. for multi-core processors.
Older cluster nodes have only two processors, so shared memory
parallelization did not provide much benefit.
However, blades purchased over the last few years have 4, 8 and
even 16 cores. Other machines such as desktops and even laptops
are also likely to have multiple cores.
OpenMP directives in C and Fortran codes are one popular means
of achieving shared memory parallelism. The following command
line should enable OpenMP parallelism with a high degree
of optimisation.
ifort -o exec -openmp -O3 -xW code.f
This command produces code for either Intel or AMD blades and runs
relatively fast in either case. However,
64 bit ifort compiled codes encounter runtime errors on the AMD blades (which
are our only current blades with 16 cores).
Compiling a Distributed Memory Parallel Program
Distributed memory parallel programs written
with MPI function calls are currently the most
appropriate programming model to achieve good
performance from commodity clusters such as
henry2.
For 64 bit blades, the best current choice of intel compiler and
corresponding mpich parallel library is obtained by the
command 'source /home/gwhowell/scripts/mpich13a2-in101-em64t.csh' executed from
one of the 64 bit login nodes (login64.hpc.ncsu.edu). This add
command sets paths
so that the intel 10.1 compilers link to the mpich2-1.3a2 hydra
MPI library. For 32 bit compilations, instead use
the command 'source /home/gwhowell/scripts/mpich13a2-in101-32.csh/The developers
of the mpich libraries no longer support the older mpich1 libraries
packaged with the other 'add intel' commands. 'net_send' run time
errors sometimes occur when the mpich1 libraries are used.
MPI parallel programs compiled with the Intel compilers
should use the mpif77, mpif90, mpicc, or mpiCC
commands to link with the MPICH libraries.
The following command line would compile an MPI
code with a high level of optimization:
mpif90 -o exec -O3 -axW code.f
The MPICH MPI library is used when the mpi* commands
are invoked with the Intel compiler environments.
When C and Fortran object files are linked together, the
-static-libcxa flag avoids a run-time error. For example,
the executable pring produced by
ifort -c ring.f
icc -c host.c
mpif90 -o pring host.o ring.o -static-libcxa
ran successfully, while leaving out the flag gave a run-time
error "error while loading shared libraries: libcxa.so.5".
Any of these compilers (and in particular the mpiCC) compiler
are prone to run-time errors when shared libraries are used.
Using a -static flag is therefore recommended. For example,
mpiCC greetings2.c -o greetings2 -static
avoids a run-time error which frequently occurs when the -static
flag is omitted.
|