O1 and O2 (218 Views)
Reply
Frequent Advisor
Alex Vinokur
Posts: 52
Registered: ‎09-19-2010
Message 1 of 9 (218 Views)
Accepted Solution

O1 and O2

Hi,

HP-UX v2 and v3
aCC: HP C/aC++ B3910B A.06.25.01 [May 16 2010]

For instance, we need to create two libraries: liba.so and libb.so

Library liba.so is built on basis of files a1.cpp, a2.cpp, ..., a1.h, a2.h, ...

Library libb.so is built on basis of files b1.cpp, b2.cpp, ..., b1.h, b2.h, ...

Files b1.h, b2.h, ... include some of files a1.h, a2.h, ...

Question.
Is it correct to compile liba.so with optimize mode O1, but libb.so with optimize mode O2?
Can that cause undefined behaviour (incuding crashing program that uses liba.so and libb.so)?

Thanks

Alex




Please use plain text.
Trusted Contributor
mvpel
Posts: 271
Registered: ‎01-11-2009
Message 2 of 9 (218 Views)

Re: O1 and O2

Here's some HP docs about aC++ optimization, which is probably functionally pretty similar to aCC.

The "Level 1 optimzation" is the default, so it seems unlikely that O2 or any other opt level would have any potential to create undefined behavior when used with O1 libs, and if it did it would probably be considered a compiler bug. So my advice would be not to fret about it.

http://docs.hp.com/en/1559/optimize.htm

Level 1 Optimization
Level 1 optimization includes branch optimization, dead code elimination, faster register allocation, instruction scheduling, and peephole (statement-by-statement) optimization. Use +O1 to get level 1 optimization. Level 1 is the default.

Level 1 optimization produces faster programs than without optimization and compiles faster than level 2 optimization. Programs compiled at level 1 can be used with the HP Distributed Debugging Environment (DDE) debugger. Use the debugger option -g0 or -g1.

Level 2 Optimization
Level 2 optimization includes level 1 optimizations, plus optimizations performed over entire functions in a single file. Level 2 optimizes loops in order to reduce pipeline stalls and analyzes data-flow, memory usage, loops, and expressions. Use -O or +O2 to get level 2 optimization.

Specifically, level 2 provides:

* Coloring register allocation.
* Induction variable elimination and strength reduction.
* Local and global common subexpression elimination.
* Advanced constant folding and propagation. (Simple constant folding is done by default.)
* Loop invariant code motion.
* Store/copy optimization.
* Unused definition elimination.
* Software pipelining.
* Register reassociation.

Level 2 can produce faster run-time code than level 1 if programs use loops extensively. Loop-oriented floating-point intensive applications may see run times reduced by 50%. Operating system and interactive applications that use the already optimized system libraries can achieve 30% to 50% additional improvement. Level 2 optimization produces faster programs than level 1 and compiles faster than level 3 optimization.
Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,978
Registered: ‎03-06-2006
Message 3 of 9 (218 Views)

Re: O1 and O2

>Is it correct to compile liba.so with optimize mode +O1, but libb.so with optimize mode +O2?

Yes, you can mix and match opt levels.
Do you have any problems or just asking?
Please use plain text.
Frequent Advisor
Alex Vinokur
Posts: 52
Registered: ‎09-19-2010
Message 4 of 9 (218 Views)

Re: O1 and O2

> >Is it correct to compile liba.so with optimize mode +O1, but libb.so with optimize mode +O2?

> Yes, you can mix and match opt levels.
> Do you have any problems or just asking?

We have crashing some program. While investigating we check any thing that can cause the problem.

Thanks
Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,978
Registered: ‎03-06-2006
Message 5 of 9 (218 Views)

Re: O1 and O2

>We have crashing some program

Do you have a stack trace where it crashes?
Please use plain text.
Frequent Advisor
Alex Vinokur
Posts: 52
Registered: ‎09-19-2010
Message 6 of 9 (218 Views)

Re: O1 and O2


Callstack is attached.

Dennis, thank you.
Please use plain text.
Acclaimed Contributor
Dennis Handly
Posts: 24,978
Registered: ‎03-06-2006
Message 7 of 9 (218 Views)

Re: O1 and O2

>Callstack is attached.

Are you in a thread?
You seem to be dying while creating a map<:rostringref> in MT_NBIRefMapping.cpp:50.
Please use plain text.
Frequent Advisor
Alex Vinokur
Posts: 52
Registered: ‎09-19-2010
Message 8 of 9 (218 Views)

Re: O1 and O2

> Are you in a thread?
> You seem to be dying while creating a map<:rostringref> in MT_NBIRefMapping.cpp:50.

The developers try to investigate, localize and reproduce the situation.
When the situation reproduces, the relevent stuff will be send to the forum.

P.S The program is not mine. I was asked to ask of that in HP-forum.

Thank you.

Please use plain text.
Frequent Advisor
Alex Vinokur
Posts: 52
Registered: ‎09-19-2010
Message 9 of 9 (218 Views)

Re: O1 and O2

I didn't receive reproduced crash-situation from my colleagues. It seems that they could not reproduce it.



Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation