{"id":1201,"date":"2018-11-29T09:50:43","date_gmt":"2018-11-29T09:50:43","guid":{"rendered":"http:\/\/ri.itservices.manchester.ac.uk\/csf3\/?page_id=1201"},"modified":"2026-02-25T16:22:52","modified_gmt":"2026-02-25T16:22:52","slug":"gnu","status":"publish","type":"page","link":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/software\/compilers\/gnu\/","title":{"rendered":"GNU Compilers"},"content":{"rendered":"<h2>Overview<\/h2>\n<p>The GNU Compiler Collection supports a number of programming languages. <\/p>\n<p>Several versions are available on the CSF &#8211; please see the table below.<\/p>\n<p>Advice on programming in Fortran or C is currently beyond the scope of this webpage.<\/p>\n<h2>Restrictions on use<\/h2>\n<p>Code may be compiled on the login node, but aside from &#8216;very&#8217; short test runs (e.g., one minute on fewer than 4 cores), executables must always be run by submitting to the batch system, Slurm. If you need to do a bigger test than this then please use batch or <code>srun<\/code> (see below).<\/p>\n<h2>Set up procedure<\/h2>\n<p>This depends on which version you require.<\/p>\n<table class=\"striped\">\n<tr>\n<th>Version<\/th>\n<th>Commands \/ compilers available<\/th>\n<th width=\"35%\">Module required<\/th>\n<th>Additional Notes<\/th>\n<\/tr>\n<tr>\n<td>14.2.0 <\/td>\n<td>gcc, g++, gfortran<\/td>\n<td><code>module load compilers\/gcc\/14.2.0<\/code><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>14.1.0 <\/td>\n<td>gcc, g++, gfortran<\/td>\n<td><code>module load compilers\/gcc\/14.1.0<\/code><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>13.3.0 <\/td>\n<td>gcc, g++, gfortran<\/td>\n<td><code>module load compilers\/gcc\/13.3.0<\/code><\/td>\n<td>Use this or newer if optimizing for AMD nodes<\/td>\n<\/tr>\n<tr>\n<td>12.2.0 <\/td>\n<td>gcc, g++, gfortran<\/td>\n<td><code>module load compilers\/gcc\/12.2.0<\/code><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td>11.5.0 <\/td>\n<td>gcc, g++, gfortran<\/td>\n<td>System default, no modulefile to load<\/td>\n<td><\/td>\n<\/tr>\n<\/table>\n<p>Older versions listed in the table below are no longer supported by us. Existing apps that were available on the old CSF may still load the modulefiles. But if problems occur with these compilers, or any application compiled with them, we may simply recompile the app with a newer version, or recommend that you recompile your own code.<\/p>\n<table class=\"striped\">\n<tr>\n<th>Version<\/th>\n<th>Commands \/ compilers available<\/th>\n<th width=\"35%\">Module required<\/th>\n<th>Additional Notes<\/th>\n<\/tr>\n<tr>\n<td>11.2.0 <\/td>\n<td>gcc, g++, gfortran<\/td>\n<td><code>module load compilers\/gcc\/11.2.0<\/code><\/td>\n<td>Limited support<\/td>\n<\/tr>\n<tr>\n<td>9.3.0 <\/td>\n<td>gcc, g++, gfortran<\/td>\n<td><code>module load compilers\/gcc\/9.3.0<\/code><\/td>\n<td>Limited support<\/td>\n<\/tr>\n<tr>\n<td>8.2.0 <\/td>\n<td>gcc, g++, gfortran<\/td>\n<td><code>module load compilers\/gcc\/8.2.0<\/code><\/td>\n<td>Limited support<\/td>\n<\/tr>\n<tr>\n<td>6.4.0 <\/td>\n<td>gcc, g++, gfortran<\/td>\n<td><code>module load compilers\/gcc\/6.3.0<\/code><\/td>\n<td>No longer supported<\/td>\n<\/tr>\n<tr>\n<td>4.8.5 <\/td>\n<td>gcc, g++, gfortran<\/td>\n<td><code>module load compilers\/gcc\/4.8.5<\/code><\/td>\n<td>No longer supported<\/td>\n<\/tr>\n<tr>\n<td>4.2.3 <\/td>\n<td>gcc, g++, gfortran<\/td>\n<td><code>module load compilers\/gcc\/4.2.3<\/code><\/td>\n<td>No longer supported<\/td>\n<\/tr>\n<\/table>\n<p>By loading\/swapping modules, the correct <code>LD_LIBRARY_PATH<\/code> will be set.<\/p>\n<h2>Running the application<\/h2>\n<h3>Example Code Compilations<\/h3>\n<p>The following are minimum \/ basic compiler commands. See below for how to compile more optimized code for the various CSF node architectures:<\/p>\n<pre>\r\ngcc hello_world.c -o hello\r\n\r\ng++ hello_world.c++ -o cpphello\r\n\r\ngfortran hello_fworld.f77 -o f77hello\r\ngfortran hello_fworld.f95 -o f95hello\r\n<\/pre>\n<h2 id=\"compile\">Optimizing Flags for CSF Hardware<\/h2>\n<p>Note that in general, you will <strong>not<\/strong> need to recompile or reinstall any applications, python envs, R packages, conda envs for the AMD Genoa nodes. Code that you have previously compiled for older CSF nodes will run perfectly well on the new nodes. However, you may wish to recompile to see whether the compiler can optimize your code for the newer hardware.<\/p>\n<p>The AMD Genoa hardware provides the <code>avx<\/code>, <code>avx2<\/code> and <code>avx512<\/code> vector instructions found in the CSF&#8217;s Intel CPUs. So applications are expected to perform at least as well on the new nodes. A full discussion of this hardware is outside of the scope of this page, so please see the <a href=\"https:\/\/www.amd.com\/en\/products\/processors\/server\/epyc\/4th-generation-9004-and-8004-series.html\">AMD documentation<\/a> if you want more in-depth information.<\/p>\n<p>You may wish to compile code, to be optimized a little more for the AMD nodes. We will be providing more information about this in the next few months, but for now, we have some advice below.<\/p>\n<p>We recommend using the GCC 13.3.0 compiler (or newer) as this supports the AMD <code>znver4<\/code> microarchitecture, which enables the AVX-512 extensions.<\/p>\n<p>AMD provide some <a href=\"https:\/\/www.amd.com\/content\/dam\/amd\/en\/documents\/developer\/compiler-options-quick-ref-guide-amd-epyc-9xx4-series-processors.pdf\">recommended compiler flags (PDF)<\/a> to use with various compilers (GNU compiler collection, Intel OneAPI C\/C++ and the AMD AOCC compiler.) You will need to use at least an<em>architecture flag<\/em> to enable the AVX-512 extensions available in the Genoa CPUs:<\/p>\n<pre>\r\n# <strong>GNU compilers<\/strong> (13.3.0 or newer, via a modulefile, not system-wide v11)\r\n-march=znver4                           # Code will <em>only<\/em> run on AMD Genoa and Intel Skylake (or newer)\r\n-march=haswell -mtune=znver4            # Code will run on all CSF3 node types, with some further\r\n                                        # tuning for the AVX-512 extensions found in the AMD and\r\n                                        # Intel Skylake nodes where possible. \r\n\r\n# Intel OneAPI compilers\r\n-mavx2 -axCORE-AVX512,CORE-AVX2,AVX     # Code will run on all CSF3 node types, with AVX-512\r\n                                        # instruction enabled if supported\r\n\r\n# AMD AOCC compilers (not <em>yet<\/em> installed on the CSF - coming soon)\r\n-march=znver4                           # Code will <em>only<\/em> run on AMD Genoa and Intel Skylake (or newer)\r\n\r\n# Note that the above flags can be applied when compiling code on the login nodes.\r\n# An alternative is to login to the AMD nodes, using srun, and then compile for\r\n# the \"current\" node's architecture, using:\r\n-march=native\r\n<\/pre>\n<p>The above PDF provides further optimization flags you may wish to use in addition to the above architecture flags.<\/p>\n<p>An example of using the common <code>configure<\/code> command when compiling on CSF3 that we&#8217;ve used when installing applications, is:<\/p>\n<pre>\r\n.\/configure 'CFLAGS=-march=haswell -mtune=znver4' CPPFLAGS='-march=haswell -mtune=znver4' --prefix=<em>path\/to\/install\/area<\/em>\r\n<\/pre>\n<h3>Serial batch job submission<\/h3>\n<p>Please see the <a href=\"\/csf3\/batch-slurm\/serial-jobs-slurm\/\n\">Running Serial Jobs<\/a> documentation.<\/p>\n<p>Reminder that if you loaded a particular compiler modulefile to compile your code, your <em>must<\/em> load that modulefile in your jobscript (or <code>srun<\/code> interactive session &#8211; see below) before you run your program.<\/p>\n<h3>Parallel batch job submission<\/h3>\n<p>Your code, and thus the resulting executable, must use either OpenMP and\/or MPI in order to run in parallel. Please see the <a href=\"\/csf3\/batch-slurm\/parallel-jobs-slurm\">Running Parallel Jobs<\/a> documentation.<\/p>\n<p>Reminder that if you loaded a particular compiler modulefile to compile your code, your <em>must<\/em> load that modulefile in your jobscript (or <code>srun<\/code> interactive session &#8211; see below) before you run your program.<\/p>\n<h2>Testing via srun and batch<\/h2>\n<p><code>srun<\/code> can be used to gain interactive access to a compute node (limited resources reserved for this). This is useful for both compilation and testing of your code. Example:<\/p>\n<pre>\r\n# Start a 1-core 30-minute interactive session (max 1 hour is permitted) on an AMD Genoa node\r\nsrun -p interactive -n 1 -t 30 --pty bash\r\nmodule load compilers\/gcc\/14.2.0\r\n# Compile with additional optimization for AMD Genoa, but will run on any CSF node type\r\ngcc -march=haswell -mtune=znver4 hello_world.c -o hello\r\n# Run your code\r\n.\/hello\r\n<\/pre>\n<h2>Further info<\/h2>\n<ul>\n<li>Online manuals available from the command line:<\/li>\n<\/ul>\n<pre>\r\n     man gcc\r\n         # for the C\/C++ compiler\r\n\r\n     man gfortran\r\n         # for the fortran compiler\r\n<\/pre>\n<ul>\n<li><a href=\"http:\/\/gcc.gnu.org\/\">GNU Compiler Collection website<\/a><\/li>\n<li>If you require advice on programming matters, for example how to debug a code, or how to use MKL, please <a href=\"\/csf3\/overview\/help\/\">contact us<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Overview The GNU Compiler Collection supports a number of programming languages. Several versions are available on the CSF &#8211; please see the table below. Advice on programming in Fortran or C is currently beyond the scope of this webpage. Restrictions on use Code may be compiled on the login node, but aside from &#8216;very&#8217; short test runs (e.g., one minute on fewer than 4 cores), executables must always be run by submitting to the batch.. <a href=\"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/software\/compilers\/gnu\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"parent":130,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1201","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/1201","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/comments?post=1201"}],"version-history":[{"count":21,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/1201\/revisions"}],"predecessor-version":[{"id":11968,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/1201\/revisions\/11968"}],"up":[{"embeddable":true,"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/pages\/130"}],"wp:attachment":[{"href":"https:\/\/ri.itservices.manchester.ac.uk\/csf3\/wp-json\/wp\/v2\/media?parent=1201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}