Development/GCC: Difference between revisions
mNo edit summary |
mNo edit summary |
||
Line 38: | Line 38: | ||
|style="padding:3px"| GNU Fortran compiler |
|style="padding:3px"| GNU Fortran compiler |
||
|} |
|} |
||
<br> |
|||
<br> |
<br> |
||
= Versions and Availability = |
= Versions and Availability = |
||
Line 52: | Line 53: | ||
|height=480 |
|height=480 |
||
}} |
}} |
||
⚫ | |||
<br> |
|||
On the command line interface of any bwHPC cluster you'll get a list of available versions |
On the command line interface of any bwHPC cluster you'll get a list of available versions |
||
by using the command 'module avail |
by using the command 'module avail compiler/gnu'. |
||
<pre> |
<pre> |
||
$ : bwUniCluster |
|||
$ module avail |
$ module avail compiler/gnu |
||
------------------------ /opt/bwhpc/common/modulefiles ------------------------- |
------------------------ /opt/bwhpc/common/modulefiles ------------------------- |
||
compiler/gnu/4.5 compiler/gnu/4.8 compiler/gnu/5.2 |
|||
chem/gamess/12052014 |
|||
compiler/gnu/4.7(default) compiler/gnu/4.9 |
|||
</pre> |
</pre> |
||
<br> |
<br> |
||
= Loading = |
= Loading = |
||
⚫ | |||
<pre>$ module avail compiler/gnu</pre> |
|||
There is a default version which will be loaded when no version is explicitly specified, so the command |
There is a default version which will be loaded when no version is explicitly specified, so the command |
||
<pre>$ module load compiler/gnu</pre> |
<pre>$ module load compiler/gnu</pre> |
Revision as of 17:08, 10 December 2015
Description | Content |
---|---|
module load | compiler/gnu/xxx |
Availability | bwUniCluster | BwForCluster_Chemistry |
License | GPL |
Citing | n/a |
Links | GNU-Homepage |
Graphical Interface | No |
Included modules | gcc | g++ | gfortran |
Introduction
The GNU Compiler Collection (GCC) consists of tools to compile C, C++ and Fortran programs:
gcc | GNU C compiler |
g++ | GNU C++ compiler |
gfortran | GNU Fortran compiler |
Versions and Availability
A list of versions currently available on all bwHPC-C5-Clusters can be obtained from the
Cluster Information System CIS
{{#widget:Iframe
|url=https://cis-hpc.uni-konstanz.de/prod.cis/bwUniCluster/compiler/gnu
|width=99%
|height=480
}}
There is a version of GCC available on the system without loading a module but it may be outdated and it is recommended to load the GNU compiler module.
On the command line interface of any bwHPC cluster you'll get a list of available versions
by using the command 'module avail compiler/gnu'.
$ : bwUniCluster $ module avail compiler/gnu ------------------------ /opt/bwhpc/common/modulefiles ------------------------- compiler/gnu/4.5 compiler/gnu/4.8 compiler/gnu/5.2 compiler/gnu/4.7(default) compiler/gnu/4.9
Loading
There is a default version which will be loaded when no version is explicitly specified, so the command
$ module load compiler/gnu
will load the default version.
Documentation
Online documentation
Local documentation
For version specific documentation see the help page of the module. For example
$ module help compiler/gnu
will show the information for the default version. For detailed lists of the different program options consult the particular man page:
$ man gcc $ man g++ $ man gfortran
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
$ gcc -march=native -O2 ex.c -o ex
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
$ gcc -march=native -O3 ex.c -o ex
For a complete list of all the optimization options execute
$ gcc --help=optimizers
Profiling with gprof: Gprof is the profiler which belongs to the gcc compiler. Gprof is also installed on the system and can be used to profile your code. The profiler supports C, C++, Pascal and Fortran 77 program code. With this tool it is possible to analyse call times and time spent within program functions.
The first required step is to compile your program with the profiling flag "-pg".
$ gcc -pg ex.c -o ex
Compiled in this way your program will generate profiling data during execution. By default a file named gmon.out can be found in the work directory after running the program.
$ ./ex
The next step is to run the gprof program to analyse the gmon.out profiling data file. This file contains profiling data concerning the program execution, like an overview, time information or the call graph, in human readable format.
$ gprof gmon.out ex > outputfile.txt