Specify instruction set architecture (ISA). If you use this option with optimization, the appropriate choice can provide good performance of the executable on the specified architecture. An inappropriate choice results in a binary program that is not executable on the intended target platform.
Use the -m64 or -m32 option to specify the intended memory model, LP64 (64-bits) or ILP32 (32-bits) respectively. The -xarch option no longer indicates the memory model, except for compatibility with previous releases, as indicated below.
If you compile and link in separate steps, make sure you specify the same value for -xarch in both steps. For a complete list of all compiler options that must be specified at both compile time and at link time, see Table A–2.
Although-xarch 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:
% cc -xtarget=ultra2 -xarch=v8plusb ... |
overrides the-xarch=v8 set by-xtarget=ultra2.
The following table details the performance of an executable that is compiled with a given-xarch option and then executed by various SPARC processors. The purpose of this table is to help you identify the best-xarch option for your executable given a particular target machine. Start by identifying the range of machines that are of interest to you and then consider the cost of maintaining multiple binaries versus the benefit of extracting the last iota of performance from newer machines.
Table B–12 The -xarch Matrix
Instruction Set of SPARC Machine: |
||||||
---|---|---|---|---|---|---|
V8a |
V8 |
V9 (Non-Sun Processor) |
V9 (Sun processor) |
V9b |
||
v8a |
N |
S |
S |
S |
S |
|
-xarch compilation option |
v8 |
PD |
N |
S |
S |
S |
v8plus |
NE |
NE |
N |
S |
S |
|
v8plusa |
NE |
NE |
** |
N |
S |
|
v8plusb |
NE |
NE |
** |
NE |
N |
|
v9 |
NE |
NE |
N |
S |
S |
|
v9a |
NE |
NE |
** |
N |
S |
|
v9b |
NE |
NE |
NE |
N |
||
** Note: An executable compiled with this instruction set may perform nominally on a V9 non-Sun processor chip or it may not execute at all. Check with your hardware vendor to make sure your executable can run on its target machine. |
N reflects Nominal performance. The program executes and takes full advantage of the processor’s instruction set.
S reflects Satisfactory performance. The program executes but may not exploit all available processor instructions.
PD reflects Performance Degradation. The program executes, but depending on the instructions used, may experience slight to significant performance degradation. The degradation occurs when instructions that are not implemented by the processor are emulated by the kernel.
NE means Not Executable. The program will not execute because the kernel does not emulate the instructions that are not implemented by the processor.
If you are compiling your executable with the v8plus or v8plusa instruction set, consider compiling with v9 or v9a instead. The v8plus and v8plusa options are provided so that programs can take advantage of some SPARC V9 and UltraSPARC features prior to the availability of Solaris 8 software with its support for 64-bit programs. Programs compiled with the v8plus or v8plusa option are not portable to SPARC V8 or older machines. You can recompile such programs with v9 or v9a, respectively, to take full advantage of all the features of SPARC V9 and UltraSPARC. The V8+ Technical Specification white paper, part number 802-7447-10, is available through your Sun representative and explains the limitations of v8plus and v8plusa.
SPARC instruction set architectures V8 and V8a are binary compatible.
Object binary files (.o) compiled with v8plus and v8plusa can be linked and can execute together, but only on a SPARC V8plusa compatible platform.
Object binary files (.o) compiled with v8plus, v8plusa, and v8plusb can be linked and can execute together, but only on a SPARC V8plusb compatible platform.
-xarch values v9, v9a, and v9b are only available on UltraSPARC 64-bit Solaris operating systems.
Object binary files (.o) compiled with v9 and v9a can be linked and can execute together, but will run only on a SPARC V9a compatible platform.
Object binary files (.o) compiled with v9, v9a, and v9b can be linked and can execute together, but will run only on a SPARC V9b compatible platform.
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.
The following table gives details for each of the-xarch keywords on SPARC platforms.
Table B–13 The -xarch Flags for SPARC Platforms
The following table lists the -xarch flags on the x86 architecture.
Table B–14 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. |
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.
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 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 software. When a v8 instruction is encountered, the Solaris 8 operating system interprets the instruction in software. The program runs, but performance is degraded.
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.