Optimizing for system architecture

You can instruct the compiler to generate code for optimal execution on a given microprocessor or architecture family. By selecting appropriate target machine options, you can optimize to suit the broadest possible selection of target processors, a range of processors within a given family of processor architectures, or a specific processor. The following table lists the optimization options that affect individual aspects of the target machine. Using a predefined optimization level sets default values for these individual options.

Table 9. Target machine options

Option Behavior
-q32 Generates code for a 32-bit (4/4/4) addressing model (32-bit execution mode). This is the default setting.
-q64 Generates code for a 64-bit (4/8/8) addressing model (64-bit execution mode).
-qarch Selects a family of processor architectures for which instruction code should be generated. This option restricts the instruction set generated to a subset of that for the PowerPC(R) architecture. The default on all Linux platforms except Y-HPC is -qarch=ppc64grsq. The default on Y-HPC is -qarch=ppc970. Using -O4 or -O5 sets the default to -qarch=auto.
-qtune Biases optimization toward execution on a given microprocessor, without implying anything about the instruction set architecture to use as a target. The default is -qtune=pwr4.
-qcache Defines a specific cache or memory geometry. The defaults are determined through the setting of -qtune.
-qenablevmx Instructs the compiler to generate VMX (AltiVec) code in any compiler phase. For SUSE 9, Y-HPC and Red Hat 4 Linux, this option is enabled by default; for Red Hat 3 Linux, the default is -qnoenablevmx.

For a complete listing of valid hardware-related suboptions and combinations of suboptions, see "Specify Compiler Options for Architecture-Specific, 32- or 64-bit Compilation", and "Acceptable Compiler Mode and Processor Architecture Combinations" in XL C/C++ Compiler Reference.

Getting the most out of target machine options

Using -qarch options

If your application will run on the same machine on which you are compiling it, you can use the -qarch=auto option, which automatically detects the specific architecture of the compiling machine, and generates code to take advantage of instructions available only on that machine (or on a system that supports the equivalent processor architecture). Otherwise, try to specify with -qarch the smallest family of machines possible that will be expected to run your code reasonably well.

Using -qtune options

If you specify a particular architecture with -qarch, -qtune will automatically select the suboption that generates instruction sequences with the best performance for that architecture. If you specify a group of architectures with -qarch, compiling with -qtune=auto will generate code that runs on all of the architectures in the specified group, but the instruction sequences will be those with the best performance on the architecture of the compiling machine.

Try to specify with -qtune the particular architecture that the compiler should target for best performance but still allow execution of the produced object file on all architectures specified in the-qarch option. For information on the valid combinations of -qarch and -qtune, see "Acceptable Compiler Mode and Processor Architecture Combinations" in XL C/C++ Compiler Reference.

Using -qcache options

Before using the -qcache option, use the -qlistopt option to generate a listing of the current settings and verify if they are satisfactory. If you decide to specify your own -qcache suboptions, use -qhot or -qsmp along with it. For the full set of suboptions, option syntax, and guidelines for use, see -qcache in XL C/C++ Compiler Reference. IBM Copyright 2003