Development/General compiler usage: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{| width=600px class="wikitable" |
|||
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> |
|||
! Description !! Content |
|||
Both Intel and GCC have compilers for different languages which will be available after the module is loaded. |
|||
|- |
|||
| module load |
|||
{| style="width:30%; vertical-align:top;border:1px solid #000000;padding:1px;margin:5px;border-collapse:collapse" border="1" |
|||
| compiler/gnu|intel|pgi|... |
|||
|- |
|||
| Availability |
|||
| [[bwUniCluster]] | [[BwForCluster_Chemistry]] | bwGRiD_tu |
|||
|- |
|||
| License |
|||
| [[Intel_Compiler|Intel]]: Commercial | [[GCC|GNU]]: GPL | PGI: Commercial |
|||
|} |
|||
<br> |
|||
= Description = |
|||
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]]). |
|||
<br> |
|||
<br> |
|||
= Versions and Availability = |
|||
A list of versions currently available compilers on the bwHPC-C5-Clusters can be obtained from the |
|||
<br> |
|||
<big> |
|||
<br> |
|||
[https://cis-hpc.uni-konstanz.de/prod.cis/ Cluster Information System CIS] |
|||
<br> |
|||
</big> |
|||
== GNU == |
|||
{{#widget:Iframe |
|||
|url=https://cis-hpc.uni-konstanz.de/prod.cis/bwUniCluster/compiler/gnu |
|||
|width=99% |
|||
|height=470 |
|||
}} |
|||
== Intel == |
|||
{{#widget:Iframe |
|||
|url=https://cis-hpc.uni-konstanz.de/prod.cis/bwUniCluster/compiler/intel |
|||
|width=99% |
|||
|height=430 |
|||
}} |
|||
== PGI == |
|||
{{#widget:Iframe |
|||
|url=https://cis-hpc.uni-konstanz.de/prod.cis/bwUniCluster/compiler/pgi |
|||
|width=99% |
|||
|height=200 |
|||
}} |
|||
On the command line interface of any bwHPC cluster you'll get a list of available versions |
|||
by using the command ''''module avail compiler''''. |
|||
<pre> |
|||
$ : bwUniCluster |
|||
$ module avail compiler |
|||
------------------------ /opt/bwhpc/common/modulefiles ------------------------- |
|||
compiler/gnu/4.5 compiler/intel/12.1 |
|||
compiler/gnu/4.7(default) compiler/intel/13.1 |
|||
compiler/gnu/4.8 compiler/intel/14.0 |
|||
compiler/gnu/4.9 compiler/intel/15.0(default) |
|||
compiler/gnu/5.2 |
|||
$ : bwForCluster (Justus) |
|||
$ module avail compiler |
|||
------------------------ /opt/bwhpc/common/modulefiles ------------------------- |
|||
compiler/gnu/4.5 compiler/intel/15.0(default) |
|||
compiler/gnu/4.7(default) compiler/pgi/12.10(default) |
|||
compiler/gnu/4.8 compiler/pgi/12.10_static |
|||
compiler/gnu/4.9 compiler/pgi/13.7 |
|||
compiler/gnu/5.2 compiler/pgi/13.7_static |
|||
compiler/intel/12.1 compiler/pgi/14.10 |
|||
compiler/intel/13.1 compiler/pgi/14.10_static |
|||
compiler/intel/14.0 |
|||
</pre> |
|||
<br> |
|||
= Loading the module = |
|||
== Default Version == |
|||
You can load the default version of the a compiler with the command<br> |
|||
'''module load compiler'''/'''name-of-the-compiler-suite'''. |
|||
<br> |
|||
<u>Example with Intel on bwUniCluster</u> |
|||
<pre> |
|||
$ module avail compiler/intel |
|||
------------------------ /opt/bwhpc/common/modulefiles ------------------------- |
|||
compiler/intel/12.1 compiler/intel/14.0 |
|||
compiler/intel/13.1 compiler/intel/15.0(default) |
|||
$ module load compiler/intel |
|||
$ module list |
|||
Currently Loaded Modulefiles: |
|||
1) compiler/intel/15.0(default) |
|||
</pre> |
|||
Here, we got the "default" version 15.0 (example). |
|||
<br> |
|||
The module will try to load modules it needs to function. |
|||
If loading the module fails, check if you have already loaded the module with ''''module list''''. |
|||
== Specific (newer or older) Version == |
|||
If you wish to load a specific compiler version and release (if available), you can do so using<br> |
|||
'''module load compiler''/''name-of-the-compiler-suite''/''version-of-the-compiler-suite'''<br> |
|||
to load the version you desires. |
|||
<br> |
|||
<u>Example with Intel compiler, version 14.0 on bwUniCluster</u> |
|||
<pre> |
|||
$ module avail compiler/intel |
|||
------------------------ /opt/bwhpc/common/modulefiles ------------------------- |
|||
compiler/intel/12.1 compiler/intel/14.0 |
|||
compiler/intel/13.1 compiler/intel/15.0(default) |
|||
$ module load compiler/intel/14.0 |
|||
$ module list |
|||
Currently Loaded Modulefiles: |
|||
1) compiler/intel/14.0 |
|||
</pre> |
|||
Intel C-Compiler "version 14.0" is loaded now (example). |
|||
<br> |
|||
<br> |
|||
All Intel, GCC and PGI have compilers for different languages which will be available |
|||
after the module is loaded. |
|||
== Linux Original Compiler == |
|||
The original Compiler installed on all compute nodes is GNU. |
|||
* Don't get distracted with the available compiler modules. |
|||
* Only the modules are loading the complete environments needed. |
|||
<u>Example</u> |
|||
<pre> |
|||
$ module clear # unload all modules |
|||
Are you sure you want to clear all loaded modules!? [n] y |
|||
$ module list # control |
|||
No Modulefiles Currently Loaded. |
|||
$ gcc --version # see version of default Linux GNU compiler |
|||
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16) |
|||
[...] |
|||
$ module load compiler/gnu # load default GNU compiler module |
|||
$ module list # control |
|||
Currently Loaded Modulefiles: |
|||
1) compiler/gnu/4.7(default) |
|||
$ gcc --version # now, check the current (loaded) module |
|||
gcc (GCC) 4.7.3 |
|||
[...] |
|||
</pre> |
|||
<br> |
|||
= Synoptical Tables = |
|||
{| width=600px class="wikitable" |
|||
|- |
|- |
||
! Compiler Suite |
! Compiler Suite |
||
Line 9: | Line 137: | ||
! Command |
! Command |
||
|- |
|- |
||
|style=" |
| style="vertical-align:top;" rowspan="3" | <font color=green><big>Intel Composer</big></font><br><br> [[Intel_Compiler|• Best Practice Guides on Intel Compiler Software]] |
||
| C |
|||
|style="padding:3px"|C |
|||
| icc |
|||
|style="padding:3px"| icc |
|||
|- |
|||
| C++ |
|||
| icpc |
|||
|- |
|- |
||
| Fortran |
|||
|style="padding:3px"|C++ |
|||
| ifort |
|||
|style="padding:3px"|icpc |
|||
|- |
|||
| style="vertical-align:top;" rowspan="3" | <font color=green><big>GCC</big></font><br><br> [[GCC|• Best Practice Guides on GNU Compiler Software]] |
|||
| C |
|||
| gcc |
|||
|- |
|- |
||
| C++ |
|||
|style="padding:3px"|Fortran |
|||
| g++ |
|||
|style="padding:3px"|ifort |
|||
|- |
|- |
||
| Fortran |
|||
|style="padding:3px" rowspan="3" | GCC |
|||
| gfortran |
|||
|style="padding:3px"|C |
|||
|- |
|||
|style="padding:3px"|gcc |
|||
| style="vertical-align:top;" rowspan="3" | <font color=green><big>PGI</big></font> |
|||
| C |
|||
| pgcc |
|||
|- |
|- |
||
| C++ |
|||
|style="padding:3px"|C++ |
|||
| pgCC |
|||
|style="padding:3px"|g++ |
|||
|- |
|- |
||
| |
| Fortran 77/90 |
||
| pgf77 or pgf90 |
|||
|style="padding:3px"| gfortran |
|||
|} |
|} |
||
<br> |
|||
= How to use = |
|||
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 following compiler commands work for all the compilers in the list above even though |
|||
the examples will be for '''icc''' only. |
|||
== Commands == |
|||
When ex.c is a C source code file such as |
|||
<source lang=C style="font: normal normal 2em monospace"> |
<source lang=C style="font: normal normal 2em monospace"> |
||
#include <stdio.h> |
#include <stdio.h> |
||
Line 51: | Line 193: | ||
$ icc ex.o -o ex -L$FFTW_LIB_DIR -lfftw3 |
$ icc ex.o -o ex -L$FFTW_LIB_DIR -lfftw3 |
||
</pre> |
</pre> |
||
When the program crashes or doesn't produce the expected output the compiler can |
|||
help you by printing warning messages: |
|||
<pre>$ icc -Wall ex.c -o ex</pre> |
<pre>$ icc -Wall ex.c -o ex</pre> |
||
== Debugger == |
|||
If the problem can't be solved this way you can inspect what exactly your program |
If the problem can't be solved this way you can inspect what exactly your program |
||
does [[#BwHPC_BPG_Debugger|using a debugger]]. |
|||
<br> |
|||
<font color=green>To use the debugger properly with your program you have to compile it with debug information (option -g)</font>: |
|||
<br> |
|||
<u>Example</u> |
|||
<pre>$ icc -g ex.c -o ex</pre> |
<pre>$ icc -g ex.c -o ex</pre> |
||
Although -Wall should always be set, the -g option should only be stated when you want |
Although -Wall should always be set, the -g option should only be stated when you want |
||
to find bugs, since it may slow down execution and enlarges the binary due |
|||
to debugging symbols. |
|||
The usual and common way to compile your source is to apply compiler optimization. Since there are many optimization options, as a start for now the optimization level -O2 is recommended: |
|||
<br> |
|||
== Optimization == |
|||
The usual and common way to compile your source is to apply compiler optimization. |
|||
<br> |
|||
Since there are many optimization options, as a start for now the <font color=green>optimization level -O2</font> is recommended: |
|||
<pre>$ icc -O2 ex.c -o ex</pre> |
<pre>$ icc -O2 ex.c -o ex</pre> |
||
Both compilers offer a multitude of options (with regard to the above and others), |
|||
one may check the complete list of options with short explanation on both [[BwHPC_BPG_Compiler#GCC|GCC]] and |
|||
[[BwHPC_BPG_Compiler#Intel Suite|Intel Suite]] using option -v --help: |
[[BwHPC_BPG_Compiler#Intel Suite|Intel Suite]] using option -v --help: |
||
<pre>$ icc -v --help ex.c -o ex</pre> |
<pre>$ icc -v --help ex.c -o ex</pre> |
||
<br> |
|||
[[Category:Compiler_software]][[Category:bwUniCluster]] |
[[Category:Compiler_software]][[Category:bwUniCluster]] |
Revision as of 12:42, 18 December 2015
Description | Content |
---|---|
module load | compiler/gnu|intel|pgi|... |
Availability | bwUniCluster | BwForCluster_Chemistry | bwGRiD_tu |
License | Intel: Commercial | GNU: GPL | PGI: Commercial |
Description
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).
Versions and Availability
A list of versions currently available compilers on the bwHPC-C5-Clusters can be obtained from the
Cluster Information System CIS
GNU
{{#widget:Iframe |url=https://cis-hpc.uni-konstanz.de/prod.cis/bwUniCluster/compiler/gnu |width=99% |height=470 }}
Intel
{{#widget:Iframe |url=https://cis-hpc.uni-konstanz.de/prod.cis/bwUniCluster/compiler/intel |width=99% |height=430 }}
PGI
{{#widget:Iframe |url=https://cis-hpc.uni-konstanz.de/prod.cis/bwUniCluster/compiler/pgi |width=99% |height=200 }} On the command line interface of any bwHPC cluster you'll get a list of available versions by using the command 'module avail compiler'.
$ : bwUniCluster $ module avail compiler ------------------------ /opt/bwhpc/common/modulefiles ------------------------- compiler/gnu/4.5 compiler/intel/12.1 compiler/gnu/4.7(default) compiler/intel/13.1 compiler/gnu/4.8 compiler/intel/14.0 compiler/gnu/4.9 compiler/intel/15.0(default) compiler/gnu/5.2 $ : bwForCluster (Justus) $ module avail compiler ------------------------ /opt/bwhpc/common/modulefiles ------------------------- compiler/gnu/4.5 compiler/intel/15.0(default) compiler/gnu/4.7(default) compiler/pgi/12.10(default) compiler/gnu/4.8 compiler/pgi/12.10_static compiler/gnu/4.9 compiler/pgi/13.7 compiler/gnu/5.2 compiler/pgi/13.7_static compiler/intel/12.1 compiler/pgi/14.10 compiler/intel/13.1 compiler/pgi/14.10_static compiler/intel/14.0
Loading the module
Default Version
You can load the default version of the a compiler with the command
module load compiler/name-of-the-compiler-suite.
Example with Intel on bwUniCluster
$ module avail compiler/intel ------------------------ /opt/bwhpc/common/modulefiles ------------------------- compiler/intel/12.1 compiler/intel/14.0 compiler/intel/13.1 compiler/intel/15.0(default) $ module load compiler/intel $ module list Currently Loaded Modulefiles: 1) compiler/intel/15.0(default)
Here, we got the "default" version 15.0 (example).
The module will try to load modules it needs to function.
If loading the module fails, check if you have already loaded the module with 'module list'.
Specific (newer or older) Version
If you wish to load a specific compiler version and release (if available), you can do so using
module load compiler/name-of-the-compiler-suite/version-of-the-compiler-suite
to load the version you desires.
Example with Intel compiler, version 14.0 on bwUniCluster
$ module avail compiler/intel ------------------------ /opt/bwhpc/common/modulefiles ------------------------- compiler/intel/12.1 compiler/intel/14.0 compiler/intel/13.1 compiler/intel/15.0(default) $ module load compiler/intel/14.0 $ module list Currently Loaded Modulefiles: 1) compiler/intel/14.0
Intel C-Compiler "version 14.0" is loaded now (example).
All Intel, GCC and PGI have compilers for different languages which will be available
after the module is loaded.
Linux Original Compiler
The original Compiler installed on all compute nodes is GNU.
- Don't get distracted with the available compiler modules.
- Only the modules are loading the complete environments needed.
Example
$ module clear # unload all modules Are you sure you want to clear all loaded modules!? [n] y $ module list # control No Modulefiles Currently Loaded. $ gcc --version # see version of default Linux GNU compiler gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16) [...] $ module load compiler/gnu # load default GNU compiler module $ module list # control Currently Loaded Modulefiles: 1) compiler/gnu/4.7(default) $ gcc --version # now, check the current (loaded) module gcc (GCC) 4.7.3 [...]
Synoptical Tables
Compiler Suite | Language | Command |
---|---|---|
Intel Composer • Best Practice Guides on Intel Compiler Software |
C | icc |
C++ | icpc | |
Fortran | ifort | |
GCC • Best Practice Guides on GNU Compiler Software |
C | gcc |
C++ | g++ | |
Fortran | gfortran | |
PGI | C | pgcc |
C++ | pgCC | |
Fortran 77/90 | pgf77 or pgf90 |
How to use
The following compiler commands work for all the compilers in the list above even though the examples will be for icc only.
Commands
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 divided 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
When the program crashes or doesn't produce the expected output the compiler can help you by printing warning messages:
$ icc -Wall ex.c -o ex
Debugger
If the problem can't be solved this way you can inspect what exactly your program
does using a debugger.
To use the debugger properly with your program you have to compile it with debug information (option -g):
Example
$ icc -g ex.c -o ex
Although -Wall should always be set, the -g option should only be stated when you want
to find bugs, since it may slow down execution and enlarges the binary due
to debugging symbols.
Optimization
The usual and common way to compile your source is to apply compiler optimization.
Since there are many optimization options, as a start for now the optimization level -O2 is recommended:
$ icc -O2 ex.c -o ex
Both compilers offer a multitude of options (with regard to the above and others), one may check the complete list of options with short explanation on both GCC and Intel Suite using option -v --help:
$ icc -v --help ex.c -o ex