Development/Intel Compiler: Difference between revisions

From bwHPC Wiki
Jump to navigation Jump to search
No edit summary
(Describe Profiling in a bit more detail)
Line 48: Line 48:
'''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
'''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>$ icc -xHost -O2 ex.c</pre>
<pre>$ icc -xHost -O2 ex.c</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
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:
<pre>$ icc -fast ex.c</pre>
<pre>$ icc -fast ex.c</pre>

'''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:
<pre>$ icc -p ex.c -o ex</pre>
Using the gprof tool, one may manually inspect execution count of each executed line of source code.

For compiler optimization, recompile Your source using
<pre>$ icc --prof-gen ex.c -o ex</pre>
then execute the most common and typical use-case of Your application, and then recompile using the generated profile count (and using optimization):
<pre>$ icc --prof-use -O2 ex.c -o ex</pre>

'''Further literature:'''
A tutorial on optimization can be found at http://download-software.intel.com/sites/default/files/article/301481/compiler-essentials.1.pdf
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
Line 56: Line 69:
$ icc -help advanced
$ icc -help advanced
</pre>
</pre>
or the previously described catch-all option '''-v --help'''.



'''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>
[[Category:Compiler_software]][[Category:bwUniCluster]]
[[Category:Compiler_software]][[Category:bwUniCluster]]

Revision as of 09:50, 8 May 2014

Navigation: bwHPC BPR


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
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 compilers 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 explicitly specified, so the command

$ module load compiler/intel

will load the default version.

Online documentation: 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 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

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 common 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

Further literature: 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

or the previously described catch-all option -v --help.