Sun Studio 12: C++ User's Guide

A.2.107.1 -xarch Flags for SPARC

The following table gives the details for each of the -xarch keywords on SPARC platforms.

Table A–23 The -xarch Flags for SPARC Platforms

Flag  

Meaning 

generic

Uses the instruction set common to most processors. This is the default. 

generic64

Compile for good performance on most 64-bit platforms. (Solaris only). 

This option is equivalent to -m64 -xarch=generic and is provided for compatibility with earlier releases. Use -m64 to specify 64-bit compilation instead of -xarch=generic64.

native

Compile for good performance on this system. The compiler chooses the appropriate setting for the current system processor it is running on. 

native64

Compile for good performance on this system (Solaris only). This option is equivalent to -m64 -xarch=native and is provided for compatibility with earlier releases.

sparc

Compile for the SPARC-V9 ISA, but without the Visual Instruction Set (VIS), and without other implementation-specific ISA extensions. This option enables the compiler to generate code for good performance on the V9 ISA. 

sparcvis

Compile for SPARC-V9 plus the Visual Instruction Set (VIS) version 1.0, and with UltraSPARC extensions. This option enables the compiler to generate code for good performance on the UltraSPARC architecture. 

sparcvis2

Enables the compiler to generate object code for the UltraSPARC architecture, plus the Visual Instruction Set (VIS) version 2.0, and with UltraSPARC III extensions. 

sparcfmaf

Enables the compiler to use instructions from the SPARC-V9 instruction set, plus the UltraSPARC extensions, including the Visual Instruction Set (VIS) version 1.0, the UltraSPARC-III extensions, including the Visual Instruction Set (VIS) version 2.0, and the SPARC64 VI extensions for floating-point multiply-add. 

You must use -xarch=sparcfmaf in conjunction with fma=fused and some optimization level to get the compiler to attempt to find opportunities to use the multiply-add instructions automatically.

v7

Compile for the SPARC-V7 ISA. (Obsolete)

Current Solaris operating systems no longer support the SPARC V7 architecture, and programs compiled with this option run slower on current platforms. 

The default is -xarch=v8plus.

Examples: SPARCstation 1, SPARCstation 2. 

v8a

Compile for the V8a version of the SPARC-V8 ISA. By definition, V8a means the V8 ISA, but without the fsmuld instruction.

This option enables the compiler to generate code for good performance on the V8a ISA. 

Example: Any system based on the microSPARC I chip architecture 

v8

Compile for the SPARC-V8 ISA. Enables the compiler to generate code for good performance on the V8 architecture. Example: SPARCstation 10 

v8plus

Compile for the V8plus version of the SPARC-V9 ISA. By definition, V8plus means the V9 ISA, but limited to the 32–bit subset defined by the V8plus ISA specification, without the Visual Instruction Set (VIS), and without other implementation-specific ISA extensions.

  • This option enables the compiler to generate code for good performance on the V8plus ISA.

  • The resulting object code is in SPARC-V8+ ELF32 format and only executes in a Solaris UltraSPARC environment—it does not run on a V7 or V8 processor.

    Example: Any system based on the UltraSPARC chip architecture

v8plusa

Compile for the V8plusa version of the SPARC-V9 ISA. By definition, V8plusa means the V8plus architecture, plus the Visual Instruction Set (VIS) version 1.0, and with UltraSPARC extensions.

  • This option enables the compiler to generate code for good performance on the UltraSPARC architecture, but limited to the 32–bit subset defined by the V8plus specification.

  • The resulting object code is in SPARC-V8+ ELF32 format and only executes in a Solaris UltraSPARC environment—it does not run on a V8 processor.

    Example: Any system based on the UltraSPARC chip architecture

v8plusb

Compile for the V8plusb version of the SPARC-V8plus ISA with UltraSPARC III extensions. 

Enables the compiler to generate object code for the UltraSPARC architecture, plus the Visual Instruction Set (VIS) version 2.0, and with UltraSPARC III extensions. 

  • The resulting object code is in SPARC-V8+ ELF32 format and executes only in a Solaris UltraSPARC III environment.

  • Compiling with this option uses the best instruction set for good performance on the UltraSPARC III architecture.

v9

Is equivalent to -m64 -xarch=sparc. Legacy makefiles and scripts that use -xarch=v9 to obtain the 64-bit memory model need only use -m64.

v9a

Is equivalent to -m64 -xarch=sparcvis and is provided for compatibility with earlier releases.

v9b

Is equivalent to -m64 -xarch=sparcvis2 and is provided for compatibility with earlier releases.

Also note the following:

For any particular choice, the generated executable may run much more slowly on earlier architectures. Also, although quad-precision (REAL*16 and long double) floating-point instructions are available in many of these instruction set architectures, the compiler does not use these instructions in the code it generates.

-xarch Flags for x86

The following table lists the -xarch flags on x86 platforms.

Table A–24 The -xarch Flags on x86

Flag 

Meaning  

amd64 

Is equivalent to -m64 -xarch=sse2 (Solaris only). Legacy makefiles and scripts that use -xarch=amd64 to obtain the 64-bit memory model need only use -m64.

amd64a 

Is equivalent to -m64 -xarch=sse2a (Solaris only).

generic

Uses the instruction set common to most processors. This is the default. 

generic64

Compile for good performance on most 64-bit platforms. (Solaris only). 

This option is equivalent to -m64 -xarch=generic and is provided for compatibility with earlier releases. Use -m64 to specify 64-bit compilation instead of -xarch=generic64.

native

Compile for good performance on this system. The compiler chooses the appropriate setting for the current system processor it is running on. 

native64

Compile for good performance on this system (Solaris only). This option is equivalent to -m64 -xarch=native and is provided for compatibility with earlier releases.

pentium_pro

Limits the instruction set to the 32–bit pentium_pro architecture. 

pentium_proa

Adds the AMD extensions (3DNow!, 3DNow! extensions, and MMX extensions) to the 32-bit pentium_pro architecture. 

sse

Adds the SSE instruction set to the pentium_pro architecture.

ssea

Adds the AMD extensions (3DNow!, 3DNow! extensions, and MMX extensions) to the 32-bit SSE architecture. 

sse2

Adds the SSE2 instruction set to the pentium_pro architecture.

sse2a

Adds the AMD extensions (3DNow!, 3DNow! extensions, and MMX extensions) to the 32-bit SSE2 architecture. 

sse3

Adds the SSE3 instruction set to SSE2 instruction set. 

Special x86 Notes

There are some important issues to be aware of when compiling for x86 Solaris platforms.

The legacy Sun-style parallelization pragmas are not available on x86. Use OpenMP instead. See the Sun Studio 12: OpenMP API User’s Guide for information on converting legacy parallelization directives to OpenMP.

Programs compiled with -xarch set to sse, sse2, sse2a, or sse3 must be run only on platforms that provide these extensions and features.

OS releases starting with Solaris 9 4/04 are SSE/SSE2-enabled on Pentium 4-compatible platforms. Earlier versions of Solaris OS are not SSE/SSE2-enabled. If an instruction set selected by -xarch is not enabled in the running Solaris OS, the compiler will not be able to generate or link code for that instruction set.

If you compile and link in separate steps, always link using the compiler and using the same -xarch setting to ensure that the correct startup routine is linked.

Numerical results on x86 may differ from results on SPARC due to the x86 80-bit floating-point registers. To minimize these differences, use the -fstore option or compile with -xarch=sse2 if the hardware supports SSE2.

Numerical results can also differ between Solaris and Linux because the intrinsic math libraries (for example, sin(x)) are not the same.

Binary Compatibility Verification

Starting with Sun Studio 11 and the Solaris 10 OS, program binaries compiled and built using these specialized -xarch hardware flags are verified that they are being run on the appropriate platform.

On systems prior to Solaris 10, no verification is done and it is the user's responsibility to ensure objects built using these flags are deployed on suitable hardware.

Running programs compiled with these -xarch options on platforms that are not enabled with the appropriate features or instruction set extensions could result in segmentation faults or incorrect results occurring without any explicit warning messages.

This warning extends also to programs that employ .il inline assembly language functions or __asm() assembler code that utilize SSE, SSE2, SSE2a, and SSE3 instructions and extensions.

The SPARC Default

The default architecture for which the C++ compiler produces code is now v8plus (UltraSPARC). Support for v7 will be dropped in a future release.

The new default yields higher run-time performance for nearly all machines in current use. However, applications that are intended for deployment on pre-UltraSPARC computers no longer execute by default on those computers. Compile with -xarch=v8 to ensure that the applications execute on those computers.

If you want to deploy on v8 systems, you must specify the option -xarch=v8 explicitly on every compiler command line as well as any link-time commands. The provided system libraries run on v8 architectures.

If you want to deploy on v7 systems, you must specify the option -xarch=v7 explicitly on every compiler command line as well as any link-time commands. The provided system libraries use the v8 instruction set. For this release, the only supported operating system for v7 is the Solaris 8 OS release. When a v8 instruction is encountered, the Solaris 8 OS interprets the instruction in software. The program runs, but performance is degraded.

The x86 Default

For x86, -xarch defaults to generic. Note that -fast on x86 expands to -xarch=native. This option limits the code generated by the compiler to the instructions of the specified instruction set architecture. This option does not guarantee use of any target–specific instructions. However, use of this option may affect the portability of a binary program.

Interactions

Although this option can be used alone, it is part of the expansion of the -xtarget option and may be used to override the –xarch value that is set by a specific -xtarget option. For example, -xtarget=ultra2 expands to -xarch=v8plusa -xchip=ultra2 -xcache=16/32/1:512/64/1. In the following command -xarch=v8plusb overrides the -xarch=v8plusa that is set by the expansion of -xtarget=ultra2.


example% CC -xtarget=ultra2 -xarch=v8plusb foo.cc

Use of –compat[=4] with -xarch=generic64, -xarch=native64, -xarch=v9, -xarch=v9a, or -xarch=v9b is not supported.

Warnings

If you use this option with optimization, the appropriate choice can provide good performance of the executable on the specified architecture. An inappropriate choice, however, might result in serious degradation of performance or in a binary program that is not executable on the intended target platform.

If you compile and link in separate steps, make sure you specify the same value for -xarch in both steps.