INTEL compilers comprise a family of highly optimizing compilers
for the scientific programming languages C, C++, and FORTRAN.
The INTEL compilers are:
- icc, the C compiler;
- icpc, the C++ compiler;
ifort, the FORTRAN compiler, for programs written in
Fortran77, Fortran90, Fortran 2003 and so on;
In its most common use, an INTEL compiler takes user code written
in the source language, checks it for correctness, converts it into
relocatable code, adds in system and user libraries that are properly
referenced, and creates a program that can be executed.
For a simple program hello.c, these steps could be broken down
icc -c hello.c <-- check hello.c, create relocatable hello.o icc hello.o <-- add libraries to hello.o, create a.out mv a.out hello <-- rename executable to "hello"
although the first three steps can be combined into
icc hello.c -o hello
after which the program can be run by:
./hello <-- run program by name.
Two common complications to the procedure are include files
and precompiled libraries. On a cluster computer, the user
may write a main program, say myprog.c, which needs to access
functions in a precompiled library maintained by the system
administrators. The user may be told that the directory of
include files has the symbolic name $BLAS_INC and the library
directory has the symbolic name $BLAS_LIB, while the library file
itself might be called libblas.a. In that case, the
compilation procedure might look like this:
icc -c -I$BLAS_INC myprog.c <-- use includes from this directory icc myprog.o -L$BLAS_LIB -lblas <-- use libblas.a from this directory mv a.out myprog <-- rename executable as usual
although these steps can be combined into:
icc -I$BLAS_INC hello.c -o hello -L$BLAS_LIB -lblas
If the library files were not created by the same compiler, then
incompatibity issues may arise, most likely at load time. Usually,
it is possible to mix files compiled with different versions of
the same compiler. If is also often possible to load together
files written in different languages (say C and FORTRAN, for instance),
if the corresponding compilers belong to the same family, and if
certain other precautions are taken, peculiar to mixed-language
The INTEL compiler has a -Olevel switch, by which the
user can request that the compiler spend some extra effort to optimize
the code for more efficient execution. For example, the command
icc -O3 myprog.c
asks the compiler to try to optimize your code aggressively.
This can sometimes produce a significant speedup in execution time.
Sometimes, however, a compiler optimization can be erroneous, so
it's important to compare the results of the optimized code to the
original version to make sure nothing has gone seriously wrong.
Another feature of the compiler allows the user to define macro variables,
optionally including a value, which can be specified at compilation,
and affect the behavior of he program. A common
practice is to allow the definition of the variable DEBUG, as in:
icc -DDEBUG myprog.c
Within the program, there would then be lines such as
# ifdef DEBUG print_arrays ( a, b, c ); # else printf ( "Printout of arrays is omitted.\n" ); # endif
The INTEL compilers can also process OpenMP compiler directives. This
requires the command line switches -openmp and -parallel,
icc -openmp -parallel myprog.c
The resulting program can take advantage of multiple cores on a
shared memory process. The degree to which the program parallelizes
is typically controlled by setting an environment variable before the
program is executed:
icc -openmp -parallel -o myprog myprog.c export OMP_NUM_THREADS=8 ./myprog
Versions of the INTEL compilers are available for use with MPI,
with the names mpiicc, mpiicpc, and mpifort.
An INTEL specific version of the MPI library is available as impi.
Users of the INTEL compilers are encouraged to access the mkl
which provides highly optimized versions of a mathematical kernel library.
- Intel C++ Compiler 17.0 Developer Guide and Reference
- Intel Fortran Compiler 17.0 Developer Guide and Reference
On any ARC cluster, check the installation details
by typing "module spider intel".
INTEL requires that the appropriate modules be loaded before it can be run.
One version of the appropriate commands for use on NewRiver is:
module purge module load intel/16.1
The following batch file illustrates several ways of compiling a program.
#! /bin/bash # #PBS -l walltime=00:05:00 #PBS -l nodes=1:ppn=1 #PBS -W group_list=newriver #PBS -q open_q #PBS -j oe # cd $PBS_O_WORKDIR # module purge module load intel/16.1 # # 3 step compile, load, rename: # icc -c heated_plate.c icc heated_plate.o mv a.out heated_plate ./heated_plate rm heated_plate.o rm heated_plate # # 1 step compile, load, rename. # Also set commandline "PRINT" macro, so program will print data. # icc -DPRINT -o heated_plate heated_plate.c ./heated_plate rm heated_plate # # Compile with optimization levels 0, 1, 2, 3 and time the results. # if [ -f intel_timings.txt ]; then rm intel_timings.txt fi for n in 0 1 2 3; do echo "Compile with optimization level -O$n" icc -O$n -o heated_plate heated_plate.c time ( ./heated_plate ) 2>> intel_timings.txt done rm heated_plate
A complete set of files to carry out a similar process are available in intel_example.tar