Development/GCC: Difference between revisions

From bwHPC Wiki
Jump to navigation Jump to search
No edit summary
 
(24 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Softwarepage|compiler/gnu}}
<!--{| align="right" {{Table|width=40%}} -->

{|{{Softwarebox}}
{| width=600px class="wikitable"
|-
|-
! Description !! Content
! colspan="2" style="text-align:center" | GCC
|-
|-
| module load
| module load
| compiler/gnu/xxx
| compiler/gnu
|-
|-
| License
| License
Line 11: Line 12:
|-
|-
|Citing
|Citing
|
| n/a
|-
|-
| Links
| Links
| [http://gcc.gnu.org/ Homepage]
| [http://gcc.gnu.org/ GNU-Homepage]
|
|-
|-
| Graphical Interface
| Graphical Interface
| No
| No
|-
|-
| Included in module
| Included modules
| gcc, g++, gfortran
| gcc &#124; g++ &#124; gfortran
|}
|}
<br>
= Description =
The '''GNU Compiler Collection (GCC)''' consists of tools to compile C, C++ and Fortran programs:
The '''GNU Compiler Collection (GCC)''' consists of tools to compile C, C++ and Fortran programs:
{| width=400px class="wikitable"
{| border="1" style="margin:5px;border-collapse:collapse"
|-
|-
|style="padding:3px"| gcc
|style="padding:3px"| gcc
Line 35: Line 37:
|style="padding:3px"| GNU Fortran compiler
|style="padding:3px"| GNU Fortran compiler
|}
|}
= Versions and Availability =
A list of versions currently available on all bwHPC-C5-Clusters can be obtained from the
<br>
<br>
<big>

[https://cis-hpc.uni-konstanz.de/prod.cis/ Cluster Information System CIS]

</big>
{{#widget:Iframe
|url=https://cis-hpc.uni-konstanz.de/prod.cis/bwUniCluster/compiler/gnu
|width=99%
|height=500
|border=0
}}
On the command line interface of any bwHPC cluster you'll get a list of available versions
by using the command 'module avail chem/gamess'.
<pre>
$ module avail chem/gamess
------------------------ /opt/bwhpc/common/modulefiles -------------------------
chem/gamess/12052014
</pre>
<br>
= Loading =
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. To get a list of all the different versions installed on the system 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.
<br>
<br>
More information about the MPI versions of the GCC Compiler is available here:
* [[Development/Parallel_Programming|Best Practices Guide for Parallel Programming]].


= Documentation =
== Online documentation ==
[http://gcc.gnu.org/onlinedocs/ Online Documentation]
<br>
== 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
</pre>
= Optimizations =
= 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
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
Line 86: Line 49:
For a complete list of all the optimization options execute
For a complete list of all the optimization options execute
<pre>$ gcc --help=optimizers</pre>
<pre>$ gcc --help=optimizers</pre>
<br>

== Profiling with Gprof ==
'''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.
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.

<br>
The first required step is to compile your program with the profiling flag "-pg".
The first required step is to compile your program with the profiling flag "-pg".
<pre>$ gcc -pg ex.c -o ex</pre>
<pre>$ gcc -pg ex.c -o ex</pre>
Line 95: Line 59:
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.
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.
<pre>$ gprof gmon.out ex > outputfile.txt</pre>
<pre>$ gprof gmon.out ex > outputfile.txt</pre>

[[Category:Compiler_software]][[Category:bwUniCluster]]

Latest revision as of 23:56, 8 December 2022

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


Description Content
module load compiler/gnu
License GPL
Citing n/a
Links GNU-Homepage
Graphical Interface No
Included modules gcc | g++ | gfortran


Description

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



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

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