User Guide

© 2021 IBM Corporation
11
IBM
®
Power
®
Power10 Quick-start Guide GNU Compiler Collection (GCC)
Availability
The GCC compilers are available on all Enterprise Linux distributions and on
AIX.
The installed GCC version is 8.4 on RHEL 8 and 7.4 on SLES 15. RHEL 9 is
expected to ship GCC 11.2.
There are several ways to obtain a sufficiently recent version of GCC when
the default compilers for the distribution are too old to support Power10.
Red Hat supports the GCC Toolset
[1] for this purpose.
SUSE provides the Development Tools Module. [2]
IBM provides the latest compilers and libraries via the Advance Toolchain. [3]
Compatibility and New Features on Power10
Applications compiled with earlier versions of GCC to run on POWER8 or
POWER9 processors will run compatibly on Power10 processors.
GCC 11.2 or later is recommended to exploit all new features available in
Power ISA 3.1 and implemented in Power10 processors.
GCC 11.2 provides access to the Matrix Multiply Assist (MMA) feature
provided by Power10 processors.
[5]
MMA programs can be compiled using any of the GCC, LLVM, and Open XL
compilers, provided you use sufficiently recent releases.
Languages
C (gcc), C++ (g++), and Fortran (gfortran), along with others such as Go
(gccgo), D (gdc), and Ada (gnat).
Only gcc, g++, and gfortran are usually installed by default.
The golang compiler
[4] is the preferred alternative for building Go programs
on Power.
IBM Advance Toolchain
The Advance Toolchain provides Power-optimized system libraries along
with the compilers, debuggers, and other tools.
Building code with the Advance Toolchain can produce the most highly
optimized code possible on the latest processors.
IBM Recommended and Supported Compiler Flags
[6]
-O3 or -Ofast
Aggressive optimization. -Ofast is essentially equivalent to -O3
-ffast-math, which also relaxes restrictions on IEEE floating-
point arithmetic.
-mcpu=power
n
Compile using instructions supported by the Powern processor.
For example, to use instructions available only on Power10,
select -mcpu=power10.
-flto
Optional. Perform “link-time” optimization. This optimizes code
across function calls where the caller and called functions exist
in different compilation units, and can often provide a significant
performance boost.
-funroll-loops
Optional. Perform more aggressive duplication of loop bodies
than the compiler normally would. Generally you should omit
this, but on some codes this can provide better performance.
Note:
Although -mcpu=power10 is supported as early as GCC 10.3, GCC 11.2 is preferred
because earlier compilers don’t support every feature implemented in the Power10
processors. Also, objects created using -mcpu=power10 will not run on POWER9 or
earlier processors! However, there are ways to create code that is optimized for
different processor versions.
[7]
[1] Red Hat: Using GCC Toolset. https://access.redhat.com/documentation/en-
us/red_hat_enterprise_linux/8/html/developing_c_and_cpp_applications_in_rhel_8/gcc-toolset_toolsets.
[2] SUSE: Understanding the Development Tools Module. https://www.suse.com/c/suse-linux-essentials-
where-are-the-compilers-understanding-the-development-tools-module/.
[3] Advance Toolchain for Linux on IBM Power Systems. https://www.ibm.com/support/pages/advance-
toolchain-linux-power.
[4] Go Language. https://golang.org.
[5] Matrix-Multiply Assist Best Practices Guide.
http://www.redbooks.ibm.com/redpapers/pdfs/redp5612.pdf.
[6] Using the GNU Compiler Collection. https://gcc.gnu.org/onlinedocs/gcc.pdf.
[7] Target-Specific Optimization with the GNU Indirect Function Mechanism.
https://developer.ibm.com/tutorials/optimized-libraries-for-linux-on-power/#target-specific-optimization-
with-the-gnu-indirect-function-mechanism.