Comparing Oracle Solaris Studio SPARC and x86 Compiler Options


Oracle Solaris Studio C, C++, and Fortran compilers build applications for Oracle Solaris SPARC, x86, and Linux platforms. Application developers should be aware of a few differences in compiler options between the SPARC and x86 compilers.
 


Oracle Solaris Studio Developer Tools

Solaris Studio software consists of C, C++, Fortran compilers, the Performance Analyzer, Thread Analyzer, an IDE, and debugger. The complete compilation architecture includes compilers, an assembler, and a link editor. The compiler front end syntax and semantic analyzer modules transforms the source language, while the back end component performs code optimization and code generation tightly based on the instruction set for a particular target hardware.

Solaris Studio developer tools are available for the Oracle Solaris OS on SPARC and x86 platforms, and Linux. Since the compilers share a common front end, most source code is easily ported between platforms. Applications with platform-specific definitions (for example, #ifdef __sparc), may require changes before porting between platforms.

Performance-sensitive applications generally use optimization flags to achieve good performance. These flags are architecture dependent and are different for the SPARC and x86 platforms. This article details these differences by focusing on the scenario where an application is being ported from the Solaris SPARC platform to a Solaris x86 platform using Solaris Studio tools.


Compiler Options for SPARC Platform Not Available on x86 Platform

The following compiler options are used in the SPARC version of Solaris Studio compilers; they are not present in the x86 version. When a source program is compiled using these options on the Solaris OS, x86 Platform Edition, either a warning is issued or the option is silently ignored.

Table 1: Oracle Solaris Studio Compiler Options for SPARC Platforms Only

Compiler Option

Explanation

-fma

Enables automatic generation of floating-point, fused, multiply-add instructions.

-xbinopt

Instructs the compiler to prepare the binary for later optimizations, transformations and analysis by binopt(1)

-xcode

This option specifies the code address space. (See -Kpic on x86)

-xhwcprof

This option enables compiler support for hardware counter-based profiling.

-xlinkopt

This option instructs the compiler to perform link-time optimization on the resulting executable or dynamic library over and above any optimizations in the object files.

-xmemalign

This option specifies maximum assumed memory alignment and behavior of misaligned data accesses.

-xMerge

This option merges data segments into text segments. (C++)

-xprefetch=latx:factor

With -xprefetch=auto, adjust the compiler's assumed prefetch-to-load and prefetch-to-store latencies

-xprofile_ircache

This option is used with -xprofile=collect, or -xprofile=use to improve compilation time during the use phase by reusing compilation data saved from the collect phase.

-xprofile_pathmap

This option is used with -xprofile=use and it uses the prefix of the UNIX pathname of a directory tree in which object files were compiled.

-xregs=appl,float

This option specifies the usage of registers (appl and float) for the generated code.

-xsafe=mem

This option allows the compiler to assume no memory-based traps occur.

-xvis

This option is used when the assembly-language templates defined in the VIS instruction-set Software Developers Kit (VSDK) are used.

-XlistMP (f95)

Check OpenMP directives


 


Compiler Options for x86 Platform Not Available on SPARC Platforms

The following options are limited to the x86 version of Solaris Studio software and are not available in the SPARC version. When a source program is compiled using these options on the Solaris OS on SPARC platforms, a warning is issued indicating that an illegal option was used, or the compiler ignores the option.

Table 2: Oracle Solaris Studio Compiler Options for x86 Platforms Only

Compiler Option

Explanation

-flteval (C)

Controls how floating point expressions are evaluated

-fprecision

This option initializes the rounding-precision mode bits in the floating-point control word to single (24 bits), double (53 bits), or extended (64 bits).

-fstore

This option causes the compiler to convert the value of a floating-point expression or function to the type on the left side of an assignment rather than leave the value in a register when: The expression or function is assigned to a variable. The expression is cast to a shorter floating-point type.

-nofstore

This option disables forced precision of an expression.

-xaddr32

Restricts the resulting executable or shared object to a 32-bit address space.

-xmodel

Determines the data address model for shared objects on the Solaris x64 platforms and should only be specified for the compilation of such objects. This option is valid only when -m64 is also specified on 64-bit enabled x64 processors.

-xpentium

Generates code for the Pentium processor.

-xregs=frameptr

Allow the compiler to use the frame-pointer register (%ebp on IA32, %rsp on x86 64-bit platforms) as a general-purpose register.


 


Compiler Options Used on Both Solaris Platforms But with Differences

The following options in the Solaris Studio developer tools are used on both SPARC and x86 versions, but with different implications that are explained in the table. When a source program is compiled on the Solaris OS using these options, the values passed to the options are different on both platforms.

Table 3: Solaris Studio Compiler Options – SPARC vs x86

Compiler Option

Explanation

Values for SPARC

Values for x86

-fast

This option selects a set of baseline options for optimizing benchmark applications.

Expansion of -fast may change with each release.

To determine the expansion of -fast on a running system, execute the command
cc -fast -xdryrun |& grep ###

CC -fast -xdryrun |& grep ###

f95 -fast -dryrun |& grep ###

The (Studio 12.2) option expands to the following values on SPARC platform:
-fns
-fsimple=2
-fsingle
-xalias_level=basic
-xbuiltin=%all
-xdepend
-xlibmil
-xlibmopt

-xmemalign=8s
-xO5
-xprefetch=
auto,explicit
-xtarget=native

The (Studio 12.2) option expands to the following values on x86 platform:
-fns
-fsimple=2
-fsingle
-nofstore
-xbuiltin=%all
-xdepend
-xlibmil
-xO5
-xregs=frameptr
-xtarget=native

-fnonstd

This option enables hardware traps for floating-point overflow, division by zero, and invalid operations exceptions.

This option expands to:
fns -ftrap=common

This option expands to: ftrap=common
(does not include -fns on x86 platforms)

-fns

Select nonstandard floating-point arithmetic

For SPARC, this option causes the nonstandard floating-point mode to be enabled when a program begins execution.

For x86, this option selects SSE flush-to-zero mode and, where available, denormals-are-zero mode. This option causes subnormal results to be flushed to zero on x86. Where available, this option also causes sub-normal operands to be treated as zero. This option has no effect on traditional x86 floating-point operations that do not utilize the SSE or SSE2 instruction set.

-KPIC

This option is used to compile source files when building a shared library.

Obsolete, use: -xcode=pic32

Same as -Kpic

-Kpic

This option is used to compile source files when building a shared library.

Obsolete, use: -xcode=pic13

Compiles with position-independent code.

-m32
-m64

Compile for 32- or 64-bit processors.

Default on SPARC platforms is -m32

Default on Linux x86 platforms is -m64.
Default on Solaris x86 platforms is -m32.

-xarch

This option specifies the instruction set architecture (ISA).

Values will vary with each software release. Check documentation.

Default is generic

 

The values are:
generic
generic64
native
native64
sparc
sparcvis
sparcvis2
sparcvis3

sparcfmaf
sparcima
v9 (-m64 -xarch=sparc)

v9a (-m64 -xarch=sparcvis)
v9b (-m64 -xarch=sparcvis2)

The values are:
generic
pentium_pro
sse
sse2
sse3
sse3a
ssse3
sse4_1
sse4_2
amdsse4a
amd64 (-m64 -xarch=sse2 Solaris only)
pentium_proa
ssea
sse2a
amd64a (-m64 -xarch=sse2a Solaris only)

-xchip

This option specifies the target processor for use by the optimizer.

Values will vary with each software release. Check documentation.

The values are:
generic
native
sparc64vi
sparc64vii

ultra
ultra3
ultra3cu
ultra3i
ultra4
ultra4plus
ultraT1
ultraT2
ultraT2plus
ultraT3

The values are:
generic
native
opteron

pentium
pentium_pro
pentium3
pentium4
core2
amdfam10
penryn
nehalem

-xdepend

Analyzes loops for inter-iteration data dependencies and performs loop restructuring.

On SPARC, -xdepend is turned on for all optimization levels -xO3 and above, and is off for lower opt levels. Also, an explicit setting of -xdepend overrides any implicit setting.

On x86, if optimization is not at -xO3 or higher, the compiler raises the optimization to -xO3 and issues a warning.

-xia

Link the appropriate interval arithmetic libraries and set a suitable floating-point environment. (f95)

 

Requires SSE2. Solaris only.

-xpagesize

Set the preferred page size for the stack and the heap.

-xpagesize=4K 8K 64K 512K 2M 4M 32M 256M 2G 16G or default.

-xpagesize=4K 2M 4M 1G or default

-xregs

Specify the usage of registers for the generated code

Default is -xregs=appl,float

Default is -xregs=no%frameptr

-xtarget

This option specifies the target system for instruction set and optimization.

Values will vary with each software release. Check documentation.

The values are:
native
native64
generic
generic64
ultra3
ultra3cu
ultra3i
ultra4 ultra4plus
ultraT1
ultraT2
ultraT2plus ultraT3
sparc64vi
sparc64vii

The values are:
native
generic
nehalem
opteron

pentium
pentium_pro
pentium3
pentium4
penryn
woodcrest

-xvector

Enables automatic generation of calls to the vector library and/or the generation of the SIMD (Single Instruction Multiple Data) instructions.

Default is -xvector=%none

-xvector alone expands to -xvector=lib

Default is -xvector=simd

-xvector alone expands to -xvector=simd,lib on Solaris, -xvector=simd on Linux


Conclusion

Many applications can be migrated without changing source code from the Solaris OS on SPARC platforms to the Solaris OS on x86 platforms. Oracle Solaris Studio software supports both the SPARC and x86 versions of the Solaris OS, you can easily port applications between these platforms using the same compiler. A few compiler flags might need to be changed in the build environment for each platform.

Complete Oracle Solaris Studio documentation is available at the Oracle Technical Network website

(January 2011)