Skip to main content



Compiler GCC

developerWorks

General Compile options
   Recommendations  |   More

Special GCC compile options for S/390 (31-bit) and System z (64-bit) architectures *Updated* March 2009
General GCC compile options improving performance
Options for generating 31-bit code on a 64-bit system *New* September 2008




Special GCC compile options for S/390 (31-bit) and System z (64-bit) architectures

With SLES9 GCC-3.3 and RHEL4 GCC-3.4 compile options '-march' and '-mtune' became available to Linux users on the mainframe. The GCC-4.1 introduces the additional argument 'z9-109' for both parameters '-mtune' and '-march'. The first distributions which provide support for taking specific advantage of System z9-109 models are Novell/SUSE SLES10 and Red Hat Enterprise Linux AS 5. The GCC-4.4 and the Novell/SUSE SLES11 GCC-4.3 provide System z10 support introducing the new argument 'z10' for '-march' and '-mtune' parameters.

'-march=z900 | z990 | z9-109 | z9-ec | z10'

generates code optimized for the particular CPU, using the instruction set of the CPU. The generated code targeting one CPU type will not necessarily run on a different mainframe CPU type. The 'march' parameter is upward compatible.So code compiled with 'march=z900' will run on a System z9 but it is not guaranteed that code compiled with 'march=z9-109' will run on an eServer zSeries 900. For eServer zSeries 800 use the 'z900' argument, for eServer zSeries 890 use the 'z990' argument.

'-mtune=z900 | z990 | z9-109 | z9-ec | z10'

generates code optimized for the particular CPU and the set of available instructions. The compiler's instruction scheduling is influenced but not the instruction set. The generated code targeting one CPU type will run on a different mainframe CPU type but may cause a performance degradation there. For eServer zSeries 800 use the 'z900' argument, for eServer zSeries 890 use the 'z990' argument.

In most cases the option '-march', '-mtune' or both improve the performance of the application if the binary code is optimized for the target machine. The arguments 'z990' and 'z9-109' and 'z10' utilize the super scalar machine capabilities. Two execution units per CPU allow to run up to two instructions and a branch in parallel, if the instructions are properly arranged. The performance improvement varies and depends upon the generated machine code and in case the CPU is the bottleneck. Our experiments show remarkable overall performance improvements.

  • Use '-march', if the generated optimized code is to be executed on only that single target machine type. If more than one target machine is identified, use the argument for the oldest model (march parameter is upward compatible).
  • Use '-mtune', if the generated optimized code is intended to run optimal on a specific target machine type, but should be definitely runnable on other machines, too.
  • For RHEL5 GCC-4.1 the defaults are '-mtune=z9-109' and '-march=z900'.
  • For SLES10 GCC-4.1 the defaults are '-mtune=z9-109' and '-march=z900'.
  • For SLES11 GCC-4.3 the defaults are '-mtune=z9-109' and '-march=z900'.
  • In other 64-bit environments the defaults are '-mtune=z900' and '-march=z900'.
  • In a 31-bit environment the defaults are '-mtune=g5' and '-march=g5'.

Back to top


General GCC compile options improving performance
  • Utilize the highest optimization level using parameter '-O3'.

  • The option '-funroll-loops' might help to speed up your application.

  • For a detailed description of the -m options defined for the S/390 (31-bit) and System z (64-bit) architectures see the GCC page 'S/390 and zSeries Options' at

    http://gcc.gnu.org/onlinedocs/gcc/S_002f390-and-zSeries-Options.html#S_002f390-and-zSeries-Options


Back to top


Options for generating 31-bit code on a 64-bit system

Some applications have to be compiled for 31-bit mode, because they are currently not prepared for 64-bit mode. One example for this is the Open Object Rexx package from http://www.oorexx.org/download.html. The following options and flag settings are recommended when compiling for 31-bit mode on a 64-bit system.

C/C++ preprocessor options

CPPFLAGS: append "-I<include dir>"

To use headers in a nonstandard directory, this option directs the preprocessor to this directory.
 
Compiler options for C, C++, and Fortran

CFLAGS, CXXFLAGS, FFLAGS: append "-m31"

With the option "-m31", the compiler generates code which is compliant to the GNU/Linux for S/390 ABI.
With the option "-m64", the compiler generates code which is compliant to the GNU/Linux for zSeries ABI. This allows GCC in particular to generate 64-bit instructions.
For 31-bit targets, the default is "-m31".
For 64-bit targets, the default is "-m64".

Be sure that you have fixed application problems with aliasing rules or other bugs. Temporarily, you might want to reduce the GCC optimization level or to specify the "-fno-strict-aliasing" compiler option.

Linker options

LDFLAGS: append "-L<lib dir>"

This option directs the linker to nonstandard library directories.

For example, if the 31-bit version of the libstdc++ library should be used instead of the 64-bit version, specify
LDFLAGS=-L/usr/lib64/gcc/s390x-suse-linux/4.1.2/32/

Best practice is to call the linker via GCC. Otherwise, "-m elf_s390" must be appended to LDFLAGS.

 


Back to top



Team
Please address any comments to the performance team: linux390@de.ibm.com