Compile question

I got a few questions regarding compiling with Sun Studio.

1) If I compile a application for a specific CPU architecture, how specific can I be, specify exact CPU or just CPU family or perhaps both?

2) If I choose to compile for a specific CPU, could the application still be used on other CPU models but not get the same performance boost OR is the application totally locked for the specific CPU I compiled for?

3) If it isn't possible to run a specific compilation on all CPUs of the same family, is there a way to boost the performance generic for all CPU types in the same family?

Thanks,

Nergal

[638 byte] By [Nergal] at [2007-11-26 10:16:03]
# 1

Because of the range of CPU architectures, there is no simple answer to your question. The detailed answers are in the C User's Guide chapter on compiler options:

http://docs.sun.com/source/819-3688/cc_ops.app.html

Refer especially to the -xarch, -xtarget, and -xchip options, as well as related options like -xcache.

You can download a pdf version of the C Users Guide here:

http://docs.sun.com/app/docs/coll/771.7

By default, the compilers generate code for a 32-bit generic architecture that will run on all non-obsolete systems in that family (sparc or x86). If you add -xarch, -xtarget, or -xchip options, you narrow the range of systems that will be able to run the code.

For example, if you select -xarch=v8plusa, the resulting code wil run on sparc v8plusa, b, and c archtiectures, but not on v8 or v8plus. Similarly, if you specify SSE or SSE2 instruction sets for x86, the code will run only on systems that support those instructions. In addition, the SSE family of extensions is supported only on Solaris 9 update 6 and later.

Except forf sparc T1 ("Niagara"), the sparc architectures are ordered linearly. Code compiled for an earlier ("lower") architecture will run on all later architectures, but not as fast as code compiled for the later achitecture. (T1 is an exception, being more like UltraSparc II, although it was introduced after UltraSparc III.)

The x86 family has no simple inter-relationships, unfortunately. Later x86 architectures sometime drop support for instructions that were present in earlier architectures. The generic instruction set will run on all x86 systems, but you have to pay closer attention when you tell the compiler to generate more specialized code.

Finally, 32-bit code runs only on a 32-bit architecture (for example, a 64-bit chip in 32-bit mode), and 64-bit code runs only on a 64-bit architecture and OS. For both sparc and x86/x64, the instructions sets and other architectural details are different between 32-bit and 64-bit mode. You can't mix 32-bit and 64-bit code in the same program.

clamage45 at 2007-7-7 2:09:06 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2
Thanks for your answer, I will study the C user guide.Cheers,Nergal
Nergal at 2007-7-7 2:09:06 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 3
Here is an article about choosing optimization options: http://developers.sun.com/prodtech/cc/articles/options.html
clamage45 at 2007-7-7 2:09:06 > top of Java-index,Development Tools,Solaris and Linux Development Tools...