Sun Studio 12: Fortran Programming Guide

9.1.1.9 -xtarget=platform

The performance of some programs might improve if the compiler has an accurate description of the target computer hardware. When program performance is critical, the proper specification of the target hardware could be very important. This is especially true when running on the newer SPARC processors. However, for most programs and older SPARC processors, the performance gain could be negligible and a generic specification might be sufficient.

The Fortran User’s Guide lists all the system names recognized by -xtarget=. For any given system name (for example, ultra2, for UltraSPARC-II), -xtarget expands into a specific combination of -xarch, -xcache, and -xchip that properly matches that system. The optimizer uses these specifications to determine strategies to follow and instructions to generate.

The special setting -xtarget=native enables the optimizer to compile code targeted at the host system (the system doing the compilation). This is obviously useful when compilation and execution are done on the same system. When the execution system is not known, it is desirable to compile for a generic architecture. Therefore, -xtarget=generic is the default, even though it might produce suboptimal performance.

UltraSPARC-III and UltraSPARC-IV Support

Both the -xtarget and -xchip flags accept ultra3 and ultra3 variants and will generate optimized code for UltraSPARC-III and UltraSPARC-IV processors. When compiling and running an application on the latest UltraSPARC platforms, specify the -fast flag to automatically select the proper compiler optimization options for that platform.

For cross-compilations (compiling on a platform other than the latest UltraSPARC platforms but generating binaries intended to run on an UltraSPARC-III processor), use these flags:

-fast -xtarget=ultra3

Use -m64 to compile for 64-bit code generation.

See the Fortran User’s Guide for a list of -xtarget flags for the latest UltraSPARC processors.

Performance profiling, with -xprofile=collect: and -xprofile=use:, is particularly effective on the UltraSPARC-III and UltraSPARC-IV platforms because it allows the compiler to identify the most frequently executed sections of the program and perform localized optimizations to best advantage.

64-Bit x86 Platform Support

The Sun Studio Fortran compiler supports the compilation of 32-bit and 64-bit code for Solaris and Linux x86 platforms.

The -xtarget=pentium3 flag expands to: -xarch=sse -xchip=pentium3 -xcache=16/32/4:256/32/4.

For Pentium 4 systems, -xtarget=pentium4 expands to: -xarch=sse2 -xchip=pentium4 -xcache=8/64/4:256/128/8.

A new -m64 option specifies compilation for the 64-bit x64 instruction set.

A new -xtarget option, -xtarget=opteron, specifies the -xarch, -xchip, and -xcache settings for 32-bit AMD compilation.

You must specify -m64 after -fast and -xtarget on the command line to generate 64-bit code. The -xtarget option does not automatically generate 64-bit code. The -fast option also results in 32-bit code because it is a macro which also defines an -xtarget value. All the current -xtarget values (except -xtarget=native64 and -xtarget=generic64) result in 32- bit code, so it is necessary to specify -xarch=m64 after (to the right of) -fast or -xtarget to compile 64-bit code, as in:

% f95 -fast -m64 or % f95 -xtarget=opteron -m64

The compilers now predefine __amd64 and __x86_64 when you specify -xarch=amd64.

Additional information about compilation and performance on 32-bit and 64-bit x86 platforms can be found in the Fortran User’s Guide.