Development/Intel Compiler: Difference between revisions

From bwHPC Wiki
Jump to navigation Jump to search
(Created page with "{| style="border-style: solid; border-width: 1px" ! Navigation: bwHPC BPR |} = Intel = bwUniCluster currently provides Intel compiler suit…")
 
No edit summary
Line 3: Line 3:
|}
|}


= General compiler usage =


The basic operations can be performed with the same commands for all available compilers. For advanced usage such as optimization and profiling you should consult the best practice guide of the compiler you intend to use ([[BwHPC_BPG_Compiler#GCC|GCC]], [[BwHPC_BPG_Compiler#Intel Suite|Intel Suite]]). To get a list of the compilers installed on the system execute
= Intel =
<pre>$ module avail compiler</pre>
Both Intel and GCC have compilers for different languages which will be available after the module is loaded.


{| border="1" style="margin:5px;border-collapse:collapse"
bwUniCluster currently provides Intel compiler suite versions:
|-
* 13.1 (default)
! Compiler Suite
* 12.1
! Language
<br>
! Command
To load the default compiler suite execute in your terminal session:
|-
| rowspan="3" | Intel Composer
| C
| icc
|-
| C++
| icpc
|-
| Fortran
| ifort
|-
| rowspan="3" | GCC
| C
| gcc
|-
| C++
| g++
|-
| Fortran
| gfortran
|}

The following compiler commands work for all the compilers in the list above even though the examples will be for icc only. When ex.c is a C source code file such as
<source lang=C>
#include <stdio.h>
int main() {
printf("Hello world\n");
return 0;
}
</source>
it can be compiled and linked with the single command
<pre>$ icc ex.c -o ex</pre>
to produce an executable named ex.
This process can be devided into two steps:
<pre>
<pre>
$ icc -c ex.c
$ module load compiler/intel
$ icc ex.o -o ex
</pre>
</pre>
To load your prefered version, e.g. 12.1, enter:
When using libraries you must sometimes specify where the include files are (option -I) and where the library files are (option -L). In addition you have to tell the compiler which library you want to use (option -l). For example after loading the module numlib/fftw you can compile code for fftw using
<pre>
<pre>
$ icc -c ex.c -I$FFTW_INC_DIR
$ module load compiler/intel/12.1
$ icc ex.o -o ex -L$FFTW_LIB_DIR -lfftw3
</pre>
</pre>
For details about unloading or switching compiler suites, please see chapter [[BwUniCluster_Environment_Modules| environment modules]].


To inspect what exactly your program does (e.g. when the program crashes), you can run a debugger. To use the debugger properly with your program you have to compile it with debug informations (option -g):
<pre>$ icc -g ex.c -o ex</pre>


== Default Intel compiler suite - version 13.1 ==
= Intel Suite =
The Intel Composer XE Suite consists of tools to compile and debug C, C++ and Fortran programs:
{| border="1" style="margin:5px;border-collapse:collapse"
|-
| icc
| Intel C compiler
|-
| icpc
| Intel C++ compiler
|-
| ifort
| Intel Fortran compiler
|-
| idb
| Intel debugger in GUI mode
|-
| idbc
| Intel debugger in console mode
|}


Aside from that the suite also includes the TBB (Threading Building Blocks) and IPP (Integrated Performance Primitives) libraries.
This module provides the Intel® compiler suite version 13.1.3 via
commands 'icc', 'icpc' and 'ifort', the debugger 'idb' as well as the Intel®
Threading Building Blocks TBB and the Integrated Performance Primitives IPP
libraries (for details see also http://software.intel.com/en-us/intel-compilers/).


'''Loading:''' There are different versions of the Intel compiler installed. To get a list of these installations execute the following command:
The related Math Kernel Library MKL module is 'numlib/mkl/11.0.5'.
<pre>$ module avail compiler/intel</pre>
The related Intel MPI module is 'mpi/impi/4.1.1-intel-13.1'.
There is a default version which will be loaded when no version is explicitely specified, so the command
The Intel icpc should work well with GNU compiler 4.7.
<pre>$ module load compiler/intel</pre>
will load the default version.


'''Online documentation:'''
The compiler suite contains:
http://software.intel.com/en-us/intel-composer-xe
<pre>
http://software.intel.com/en-us/articles/intel-c-composer-xe-documentation/
icc # Intel® C compiler
'''Local documentation:''' For version specific documentation see the help page of the module. For example
icpc # Intel® C++ compiler
<pre>$ module help compiler/intel</pre>
ifort # Intel® Fortran compiler
will show the information for the default version.
idb # Intel® debugger in GUI mode
For detailed lists of the different program options consult the particular man page:
idbc # Intel® debugger in console mode
</pre>

For local documentation consult the module help:
<pre>
$ module help compiler/intel/13.1
</pre>
or the '''man pages''' of each compiler:
<pre>
<pre>
$ man icc
$ man icc
$ man icpc
$ man icpc
$ man ifort
$ man ifort
$ man idb
</pre>


'''Optimizations:''' You can turn on various optimization options to enhance the performance of your program. Which options are the best depends on the specific program and can be determined by benchmarking your code. A command which gives good performance and a decent file size is
</pre>
<pre>$ icc -xHost -O2 ex.c</pre>
For further online documentation visit:
There are more aggressive optimization flags but the compiled programs can get quite large, e.g.
* [http://software.intel.com/sites/products/search/search.php?q=&x=27&y=4&product=composerxef&version=2013&docos=lin Intel® Fortran Composer XE Version 2013]
<pre>$ icc -fast ex.c</pre>
* [http://software.intel.com/sites/products/search/search.php?q=&x=25&y=6&product=composerxec&version=2013&docos=lin Intel® C++ Composer XE Version 2013]
A tutorial on optimization can be found at http://download-software.intel.com/sites/default/files/article/301481/compiler-essentials.1.pdf
<br>
and to get the different optimization options execute
For some Intel® compiler option examples, hints on how to compile 32bit code
and solutions for less common problems see the tips and troubleshooting doc under:
<pre>
<pre>
$ icc -help opt
$INTEL_DOC_DIR/intel-compiler-tips-and-troubleshooting.txt
$ icc -help advanced
</pre>
</pre>
<br>
For details on library and include directories of this compiler suite please enter:
<pre>
$ module show compiler/intel/13.1
</pre>
<br>
Note that, the environment variables and commands are '''only''' available after loading this module.



'''Profiling:''' If you want to profile your program using gprof you have to compile your code with the profile flag:
<pre>$ icc -p ex.c -o ex</pre>


= GCC =
= GCC =

Revision as of 16:53, 24 January 2014

Navigation: bwHPC BPR

General compiler usage

The basic operations can be performed with the same commands for all available compilers. For advanced usage such as optimization and profiling you should consult the best practice guide of the compiler you intend to use (GCC, Intel Suite). To get a list of the compilers installed on the system execute

$ module avail compiler

Both Intel and GCC have compilers for different languages which will be available after the module is loaded.

Compiler Suite Language Command
Intel Composer C icc
C++ icpc
Fortran ifort
GCC C gcc
C++ g++
Fortran gfortran

The following compiler commands work for all the compilers in the list above even though the examples will be for icc only. When ex.c is a C source code file such as

#include <stdio.h>
int main() {
    printf("Hello world\n");
    return 0;
}

it can be compiled and linked with the single command

$ icc ex.c -o ex

to produce an executable named ex. This process can be devided into two steps:

$ icc -c ex.c
$ icc ex.o -o ex

When using libraries you must sometimes specify where the include files are (option -I) and where the library files are (option -L). In addition you have to tell the compiler which library you want to use (option -l). For example after loading the module numlib/fftw you can compile code for fftw using

$ icc -c ex.c -I$FFTW_INC_DIR
$ icc ex.o -o ex -L$FFTW_LIB_DIR -lfftw3

To inspect what exactly your program does (e.g. when the program crashes), you can run a debugger. To use the debugger properly with your program you have to compile it with debug informations (option -g):

$ icc -g ex.c -o ex

Intel Suite

The Intel Composer XE Suite consists of tools to compile and debug C, C++ and Fortran programs:

icc Intel C compiler
icpc Intel C++ compiler
ifort Intel Fortran compiler
idb Intel debugger in GUI mode
idbc Intel debugger in console mode

Aside from that the suite also includes the TBB (Threading Building Blocks) and IPP (Integrated Performance Primitives) libraries.

Loading: There are different versions of the Intel compiler installed. To get a list of these installations execute the following command:

$ module avail compiler/intel

There is a default version which will be loaded when no version is explicitely specified, so the command

$ module load compiler/intel

will load the default version.

Online documentation: http://software.intel.com/en-us/intel-composer-xe http://software.intel.com/en-us/articles/intel-c-composer-xe-documentation/ Local documentation: For version specific documentation see the help page of the module. For example

$ module help compiler/intel

will show the information for the default version. For detailed lists of the different program options consult the particular man page:

$ man icc
$ man icpc
$ man ifort
$ man idb

Optimizations: You can turn on various optimization options to enhance the performance of your program. Which options are the best depends on the specific program and can be determined by benchmarking your code. A command which gives good performance and a decent file size is

$ icc -xHost -O2 ex.c

There are more aggressive optimization flags but the compiled programs can get quite large, e.g.

$ icc -fast ex.c

A tutorial on optimization can be found at http://download-software.intel.com/sites/default/files/article/301481/compiler-essentials.1.pdf and to get the different optimization options execute

$ icc -help opt
$ icc -help advanced

Profiling: If you want to profile your program using gprof you have to compile your code with the profile flag:

$ icc -p ex.c -o ex

GCC

bwUniCluster currently provides GNU compiler suite versions:

  • 4.5
  • 4.7 (default)
  • 4.8


To load the default compiler suite execute in your terminal session:

$ module load compiler/gnu

To load your prefered version, e.g. 4.5, enter:

$ module load compiler/gnu/4.5

For details about unload or switching compiler suites, please see chapter environment modules.


Default GNU compiler suite - version 4.7

This module provides the GNU compiler suite version 4.7.3 via commands 'gcc', 'g++' and 'gfortran' (see also 'http://gcc.gnu.org/'). The GNU compiler has been build with gmp-4.3.2, mpfr-2.4.2 and mpc-0.8.1.

The compiler suite contains:

  cpp        # GNU pre processor
  gcc         # GNU C compiler
  g++       # GNU C++ compiler
  gfortran  # GNU Fortran compiler (Fortran 77, 90 and 95)


Libraries can be found under:

  $GNU_LIB_DIR = /opt/bwhpc/common/compiler/gnu/4.7.3/x86_64/lib64


For local documentation consult the module help:

$ module help compiler/gnu/4.7

or the man pages of each compiler:

$ man cpp
$ man gcc
$ man g++
$ man gfortran


For further online documentation visit:


For details on library and include directories of this compiler suite please enter:

$ module show compiler/gnu/4.7


Please do not add the gnu compiler module to any automatic environment setup procedure (neither to ~/.profile nor to ~/.bashrc).
Please note, that the environment variables and commands are only available after loading this module.