Difference between revisions of "Development/Intel Compiler"

From bwHPC Wiki
Jump to: navigation, search
 
(75 intermediate revisions by 10 users not shown)
Line 1: Line 1:
  +
{{Softwarepage|compiler/intel}}
{| style="border-style: solid; border-width: 1px"
 
! Navigation: [[BwHPC_Best_Practices_Repository|bwHPC BPR]]
 
|}
 
   
  +
{| width=600px class="wikitable"
= 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
 
<pre>$ module avail compiler</pre>
 
Both Intel and GCC have compilers for different languages which will be available after the module is loaded.
 
 
{| style="width:30%; vertical-align:top;border:1px solid #000000;padding:1px;margin:5px;border-collapse:collapse" border="1"
 
 
|-
 
|-
  +
! Description !! Content
! Compiler Suite
 
! Language
 
! Command
 
 
|-
 
|-
  +
| module load
|style="padding:3px" rowspan="3" | Intel Composer
 
  +
| compiler/intel
|style="padding:3px"|C
 
|style="padding:3px"| icc
 
 
|-
 
|-
  +
| License
|style="padding:3px"|C++
 
  +
| Commercial. See $INTEL_HOME/install-doc/EULA.txt. &#124; [https://software.intel.com/en-us/faq/licensing Intel Product Licensing FAQ]
|style="padding:3px"|icpc
 
 
|-
 
|-
  +
|Citing
|style="padding:3px"|Fortran
 
  +
| n/a
|style="padding:3px"|ifort
 
 
|-
 
|-
  +
| Links
|style="padding:3px" rowspan="3" | GCC
 
  +
| [https://software.intel.com/en-us/c-compilers Intel C-Compiler Homepage]
|style="padding:3px"|C
 
|style="padding:3px"|gcc
 
 
|-
 
|-
  +
| Graphical Interface
|style="padding:3px"|C++
 
  +
| [[#Debugger|Yes (Intel Debugger GUI-Verison)]]
|style="padding:3px"|g++
 
 
|-
 
|-
  +
| Included modules
|style="padding:3px"|Fortran
 
  +
| icc &#124; icpc &#124; ifort &#124; idb &#124; gdb-ia
|style="padding:3px"| gfortran
 
 
|}
 
|}
  +
<br>
 
  +
= Introduction =
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
 
  +
The '''Intel Compiler''' of the '''Intel Composer XE Suite''' consists of tools to compile and debug C, C++ and Fortran programs:
<source lang=C style="font: normal normal 2em monospace">
 
  +
{| width=500px class="wikitable"
#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 divided into two steps:
 
<pre>
 
$ icc -c ex.c
 
$ icc ex.o -o ex
 
</pre>
 
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>
 
$ icc -c ex.c -I$FFTW_INC_DIR
 
$ icc ex.o -o ex -L$FFTW_LIB_DIR -lfftw3
 
</pre>
 
 
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 information (option -g):
 
<pre>$ icc -g ex.c -o ex</pre>
 
 
= 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"
 
 
|-
 
|-
 
|style="padding:3px"| icc
 
|style="padding:3px"| icc
|style="padding:3px"| Intel C compiler
+
|style="padding:3px"| Intel C compiler
 
|-
 
|-
 
|style="padding:3px"| icpc
 
|style="padding:3px"| icpc
Line 72: Line 35:
 
|-
 
|-
 
|style="padding:3px"| ifort
 
|style="padding:3px"| ifort
|style="padding:3px"| Intel Fortran compiler
+
|style="padding:3px"| [https://software.intel.com/en-us/fortran-compilers Intel Fortran compiler]
 
|-
 
|-
|style="padding:3px"| idb
+
|style="padding:3px"| [[#GUI|idb]]
|style="padding:3px"| Intel debugger in GUI mode
+
|style="padding:3px"| Intel debugger in GUI mode (until version 14 only)
 
|-
 
|-
|style="padding:3px"| idbc
+
|style="padding:3px"| [[#Console Mode|gdb-ia]]
|style="padding:3px"| Intel debugger in console mode
+
|style="padding:3px"| Intel version of GNU debugger in console mode (from version 15)
  +
|-
  +
|style="padding:3px"| [[#Console Mode|idbc]]
  +
|style="padding:3px"| Intel debugger in console mode (until version 14 only)
 
|}
 
|}
  +
The intel compiler suite also includes the TBB (Threading Building Blocks) and IPP (Integrated Performance Primitives) libraries.
  +
<br>
  +
<br>
  +
More information about the MPI versions of the Intel Compiler is available here:
  +
* [[Development/Parallel_Programming|Best Practices Guide for Parallel Programming]].
  +
<br>
   
  +
= Documentation =
Aside from that the suite also includes the TBB (Threading Building Blocks) and IPP (Integrated Performance Primitives) libraries.
 
  +
== Online documentation ==
  +
* [https://software.intel.com/en-us/articles/intel-c-composer-xe-documentation Intel® C-Compiler Documentation]
  +
* [https://software.intel.com/en-us/intel-software-technical-documentation Intel® Software Documentation Library]
   
  +
= Debugger =
'''Loading:''' There are different versions of the Intel compilers installed. To get a list of these installations execute the following command:
 
  +
Please use DDT. It is a parallel debugger with graphical user interface and can also be used for debugging serial programs. The description of the debugger can be found on the website
<pre>$ module avail compiler/intel</pre>
 
  +
<br>
There is a default version which will be loaded when no version is explicitly specified, so the command
 
  +
http://www.bwhpc-c5.de/wiki/index.php/DDT
<pre>$ module load compiler/intel</pre>
 
  +
<br><br>
will load the default version.
 
   
  +
= Optimizations =
'''Online documentation:'''
 
  +
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
http://software.intel.com/en-us/articles/intel-c-composer-xe-documentation
 
  +
'''icc -xHost -O2 ex.c'''.
  +
With the option '''-xHost''' instructions for the highest instruction set available on the compilation host processor are generated. If you want to generate optimal code on bwUniCluster for both nodes with Sandy Bridge architecture and nodes with Broadwell architecture, you must compile your code with the options '''-xAVX -axCORE-AVX2''' (instead of '''-xHost''').
  +
<br>
  +
There are more aggressive optimization flags and levels (e.g. -O3 or -fast and implied options) but the compiled programs can get quite large due to inlining. Additionally the compilation process will probably take longer. Moreover it may happen that the compiled program is even slower -- or may require installation of additional statically-linked libraries. Such a command would be for example:
  +
'''icc -fast ex.c'''
  +
<br>
  +
<br>
   
  +
= Profiling =
'''Local documentation:''' For version specific documentation see the help page of the module. For example
 
  +
Profiling an application means augmenting the compiled binary with information on execution counts per source-line (and basic blocks) -- e.g. one may see how many times an if-statement has been evaluated to true. To do so, compile your code with the profile flag:
<pre>$ module help compiler/intel</pre>
 
  +
'''icc -p ex.c -o ex'''.
will show the information for the default version.
 
  +
<br>
For detailed lists of the different program options consult the particular man page:
 
  +
Using the gprof tool, one may manually inspect execution count of each executed line of source code.
<pre>
 
  +
<br>
$ man icc
 
  +
For compiler optimization, recompile your source using
$ man icpc
 
  +
'''icc -prof-gen ex.c -o ex'''
$ man ifort
 
  +
then execute the most co]]mmon and typical use-case of your application, and then recompile using the generated profile count (and using optimization):
$ man idb
 
  +
'''icc -prof-use -O2 ex.c -o ex'''.
</pre>
 
  +
<br>
 
  +
== Further literature ==
'''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
 
  +
A tutorial on optimization can be found at [https://software.intel.com/sites/default/files/managed/c1/61/compiler-essentials.1.pdf Compiler-Essentials.pdf]
<pre>$ icc -xHost -O2 ex.c</pre>
 
There are more aggressive optimization flags but the compiled programs can get quite large. Moreover it can happen that the so compiled program is even slower. Such a command would be for example
 
<pre>$ icc -fast ex.c</pre>
 
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
 
and to get the different optimization options execute
  +
'''icc -help opt'''
<pre>
 
$ icc -help opt
+
'''icc -help advanced'''
  +
<br>
$ icc -help advanced
 
  +
or the previously described catch-all option '''''-v --help'''''.
</pre>
 
 
'''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 =
 
 
The GNU Compiler Collection (GCC) consists of tools to compile and debug C, C++ and Fortran programs:
 
{| border="1" style="margin:5px;border-collapse:collapse"
 
|-
 
|style="padding:3px"| gcc
 
|style="padding:3px"| GNU C compiler
 
|-
 
|style="padding:3px"| g++
 
|style="padding:3px"| GNU C++ compiler
 
|-
 
|style="padding:3px"| gfortran
 
|style="padding:3px"| GNU Fortran compiler
 
|-
 
|style="padding:3px"| gdb
 
|style="padding:3px"| GNU debugger
 
|}
 
 
'''Loading:''' There are different versions of the GCC compilers installed. To get a list of these installations execute the following command:
 
<pre>$ module avail compiler/gnu</pre>
 
There is a default version which will be loaded when no version is explicitly specified, so the command
 
<pre>$ module load compiler/gnu</pre>
 
will load the default version.
 
 
'''Online documentation:''' http://gcc.gnu.org/onlinedocs/
 
 
'''Local documentation:''' For version specific documentation see the help page of the module. For example
 
<pre>$ module help compiler/gnu</pre>
 
will show the information for the default version.
 
For detailed lists of the different program options consult the particular man page:
 
<pre>
 
$ man gcc
 
$ man g++
 
$ man gfortran
 
$ man gdb
 
</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>$ gcc -march=native -O2 ex.c -o ex</pre>
 
There are more aggressive optimization flags but the compiled programs can get quite large and the compilation process will probably take much longer. Moreover it can happen that the so compiled program is even slower. Such a command would be for example
 
<pre>$ gcc -Ofast ex.c -o ex</pre>
 
For a complete list of all the optimization options execute
 
<pre>$ gcc --help=optimizers</pre>
 
 
'''Profiling:''' If you want to profile your program using gprof you have to compile your code with the profile flag:
 
<pre>$ gcc -pg ex.c -o ex</pre>
 

Latest revision as of 23:57, 8 December 2022

The main documentation is available via module help compiler/intel on the cluster. Most software modules for applications provide working example batch scripts.


Description Content
module load compiler/intel
License Commercial. See $INTEL_HOME/install-doc/EULA.txt. | Intel Product Licensing FAQ
Citing n/a
Links Intel C-Compiler Homepage
Graphical Interface Yes (Intel Debugger GUI-Verison)
Included modules icc | icpc | ifort | idb | gdb-ia


1 Introduction

The Intel Compiler of 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 (until version 14 only)
gdb-ia Intel version of GNU debugger in console mode (from version 15)
idbc Intel debugger in console mode (until version 14 only)

The intel compiler suite also includes the TBB (Threading Building Blocks) and IPP (Integrated Performance Primitives) libraries.

More information about the MPI versions of the Intel Compiler is available here:


2 Documentation

2.1 Online documentation

3 Debugger

Please use DDT. It is a parallel debugger with graphical user interface and can also be used for debugging serial programs. The description of the debugger can be found on the website
http://www.bwhpc-c5.de/wiki/index.php/DDT

4 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. With the option -xHost instructions for the highest instruction set available on the compilation host processor are generated. If you want to generate optimal code on bwUniCluster for both nodes with Sandy Bridge architecture and nodes with Broadwell architecture, you must compile your code with the options -xAVX -axCORE-AVX2 (instead of -xHost).
There are more aggressive optimization flags and levels (e.g. -O3 or -fast and implied options) but the compiled programs can get quite large due to inlining. Additionally the compilation process will probably take longer. Moreover it may happen that the compiled program is even slower -- or may require installation of additional statically-linked libraries. Such a command would be for example: icc -fast ex.c

5 Profiling

Profiling an application means augmenting the compiled binary with information on execution counts per source-line (and basic blocks) -- e.g. one may see how many times an if-statement has been evaluated to true. To do so, compile your code with the profile flag: icc -p ex.c -o ex.
Using the gprof tool, one may manually inspect execution count of each executed line of source code.
For compiler optimization, recompile your source using icc -prof-gen ex.c -o ex then execute the most co]]mmon and typical use-case of your application, and then recompile using the generated profile count (and using optimization): icc -prof-use -O2 ex.c -o ex.

5.1 Further literature

A tutorial on optimization can be found at Compiler-Essentials.pdf and to get the different optimization options execute icc -help opt icc -help advanced
or the previously described catch-all option -v --help.