Specifications

Chapter 3 Performance-Centric Compiler Switches 29
Compiler Usage Guidelines for AMD64 Platforms
32035 Rev. 3.22 November 2007
3.7 Sun Compilers (64-bit) for Solaris
Sun provides C, C++, and Fortran compilers for AMD64 architecture-based systems running the
Solaris operating system. The current version (as of August, 2007) is version 5.9 available in the Sun
Studio 12 developer tools suite. All the options described below apply to this version of the compiler.
3.7.1 Invocation Commands
The following commands invoke specific compilers:
cc invokes the Sun Studio C compiler.
CC invokes the Sun Studio C++ compiler.
f77 invokes the Sun Studio Fortran 77 compiler.
f90 invokes the Sun Studio Fortran 90 compiler.
3.7.2 Generic Performance Switches
Use the following switches to enable generation of 64-bit binaries, -xarch=sse3a -m64, which
includes prefetch to help tune better for the AMD instruction set architecture; -m64, which is the
same as
-xarch=generic64 (which we otherwise recommend because it helps for SPARC as well as Xeon and
Opteron processors) produces binaries meant to run on both ISA, Xeons and AMD processors.
Different optimization switches are recommended for different platforms. The -fast switch enables a
number of optimizations that optimize the execution time on the compilation platform. If the program
is run on a different machine -fast can be combined with -xtarget to optimize for a different platform.
If performance on a wide variety of systems is desired, combine
-xtarget=generic with -fast. If a switch implied by -fast (e.g., -xarch=isa) is overridden, that switch
must follow -fast on the command line, or it will be ignored. For AMD Family 10h, we recommend
using -xtarget=barcelona to take better advantage of AMD Family 10h ISA. Note that patch01 for
Sun Studio 12 must be installed before one can use this switch.
3.7.3 Other Switches
In addition to the generic switches, the following switches may improve the performance of the
program. It is worth experimenting with these switches.
Use the -xO[1|2|3|4|5] switch to enable various levels of general optimization algorithms. Usually
using a higher number results in faster execution, but in some cases -xO2 or -xO3 is faster than
-xO4 or -xO5.
Note: The -fast switch implies the -xO5 switch.
The -xprofile=collect:[name] and -xprofile=use:[name] flags enable profile-guided optimization.
The flags must be specified both when compiling and linking. After compiling with the