"-O" or "-xO3" for optimization with Sun C++ Compiler

"-O" or "-xO3" for optimization with Sun C++ Compiler

Post by qazm » Sat, 12 Oct 2002 15:18:47



I read from the article posted at
http://forte.sun.com/s1scc/articles/CC_perf/
that using "-x03" will give better optimization compared the
optimization flag "-O" for C++ code.

I would like to get your suggestions also about this. How effective
will it be in case if I go for "-xO3" instead of "-O".   Improving the
code is the best way to get better performance is a well-known fact.
Hence, I don't invite any argument about that in this thread. I would
like to know it only from the compiler point of view.

Thanks!

 
 
 

"-O" or "-xO3" for optimization with Sun C++ Compiler

Post by Barbie LeVil » Sat, 12 Oct 2002 15:29:07


On 10 Oct 2002 23:18:47 -0700


> I read from the article posted at
> http://forte.sun.com/s1scc/articles/CC_perf/
> that using "-x03" will give better optimization compared the
> optimization flag "-O" for C++ code.

man cc tells you hat will be optimized at the different levels.

--
Barbie - Prayers are like junkmail for Jesus

I have seen things you lusers would not believe.
I've seen Sun monitors on fire off the side of the multimedia lab.
I've seen NTU lights glitter in the dark near the Mail Gate.
All these things will be lost in time, like the root partition last week.
Time to die.

 
 
 

"-O" or "-xO3" for optimization with Sun C++ Compiler

Post by Roland Main » Sat, 12 Oct 2002 21:05:23



> I read from the article posted at
> http://forte.sun.com/s1scc/articles/CC_perf/
> that using "-x03" will give better optimization compared the
> optimization flag "-O" for C++ code.

> I would like to get your suggestions also about this. How effective
> will it be in case if I go for "-xO3" instead of "-O".   Improving the
> code is the best way to get better performance is a well-known fact.
> Hence, I don't invite any argument about that in this thread. I would
> like to know it only from the compiler point of view.

"-O" is an alias for "-xO2", e.g. optimizer level two; "-xO3" is level
three.

Higher optimizer levels usually result in better optimisation, however
you may need patches for your compiler to get working results for
anything beyond "-xO2" (level two) - for example Sun Workshop 6 Update 2
FCS won't compile Mozilla (http://www.mozilla.org/) properly with "-xO4"
while a patched version creates working binaries.

Additionally Sun Workshop offers the option "-xcrossfile" which allows
the optimizer to work beyond (source) file boundaries, e.g. inlining can
occur between functions which sit in different sources ("-xcrossfile"
requires to pass all source files at the command line; "-xipo" (which
was AFAIK introduced in WS6U2) allows to compile each file seperately
and then do the interprocedural optimisation when CC links the *.o files
into the final executable).

----

Bye,
Roland

--
  __ .  . __


  /O /==\ O\  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
 (;O/ \/ \O;) TEL +49 641 99-41370 FAX +49 641 99-41359

 
 
 

"-O" or "-xO3" for optimization with Sun C++ Compiler

Post by Paul Flo » Sun, 13 Oct 2002 22:10:59



Quote:>I read from the article posted at
>http://forte.sun.com/s1scc/articles/CC_perf/
>that using "-x03" will give better optimization compared the
>optimization flag "-O" for C++ code.

>I would like to get your suggestions also about this. How effective
>will it be in case if I go for "-xO3" instead of "-O".   Improving the
>code is the best way to get better performance is a well-known fact.
>Hence, I don't invite any argument about that in this thread. I would
>like to know it only from the compiler point of view.

The only way to be sure is to try it and see. The different optimization
levels use various techniques to optimize the code. There are often
trade-offs (size for speed being the most common, e.g., inlining
functions and unrolling loops). Whilst the higher the optimization, the
faster the code *in general*, there are always cases where specific bits
of code will run faster at a lower optimization level.

Furthermore, as has already been mentioned, the more aggressive the
optimization, the higher the risk that the compiler will generate
something that won't work.

A bientot
Paul
--
Paul Floyd                 http://paulf.free.fr (for what it's worth)
What happens if you have lead in your pants as well as lead in your pencil?

 
 
 

"-O" or "-xO3" for optimization with Sun C++ Compiler

Post by Chris Morga » Mon, 14 Oct 2002 06:34:59



> Furthermore, as has already been mentioned, the more aggressive the
> optimization, the higher the risk that the compiler will generate
> something that won't work.

and the longer your compiles will take
--
Chris Morgan <cm at mihalis.net>                  http://www.mihalis.net
      Temp sig. - Enquire within