aCC take long time when using the optimize flag -O (221 Views)
Reply
Occasional Advisor
sohochaser1
Posts: 10
Registered: ‎09-08-2008
Message 1 of 7 (221 Views)

aCC take long time when using the optimize flag -O

Hi All,
I use aCC 6.15 under hp ia 64 machine to compile cpp file. Compile will take long time when existing string concatenation with complier flag -O!!!! For a simple cpp, it will take 120 seconds to finish compile.

Is it a bug of aCC 6.15 or anything I can do to speed up the compiling.


Here is the flag I used:

BASE_CCFLAGS=" -AA +DD64 -mt -O"

Here is my cpp file.

#include
#include
using namespace std;

//Macro to print starting and ending tags
#define XML_ELEMENT_BEGIN(x) string("<") + string(x) + string(">")
#define XML_ELEMENT_END(x) string("")
int main()
{
return 0;
}

int buildBrowseReply( string &xml ,int count)
{
string MDS_BROWSE_NODE("Test string");
string MDS_EXPANDABLE("Test string");
string MDS_IMPORTABLE("Test string");

int i=count;
while( i>0 )
{

xml += XML_ELEMENT_BEGIN(MDS_BROWSE_NODE);
xml += XML_ELEMENT_BEGIN(MDS_EXPANDABLE) + MDS_TRUE + XML_ELEMENT_END(MDS_EXPANDABLE);
xml += XML_ELEMENT_BEGIN(MDS_IMPORTABLE) + MDS_FALSE + XML_ELEMENT_END(MDS_IMPORTABLE);
...(Repeat 10 times)
}

}

Here is my compiler and OS infomration:
aCC:
aCC: HP C/aC++ B3910B A.06.15 [May 16 2007]
OS:
HP-UX vanpghpq B.11.23 U ia64
Acclaimed Contributor
Dennis Handly
Posts: 25,047
Registered: ‎03-06-2006
Message 2 of 7 (221 Views)

Re: aCC take long time when using the optimize flag -O

>Compile will take long time when existing string concatenation with compiler flag -O! For a simple cpp, it will take 120 seconds to finish compile.

I get 600 times slower.

>Is it a bug of A.06.15

No, that's what happens when you optimize straight line code.
On A.06.25, it takes 9 minutes then it drops to +O1:
Warning #20099-D: Exceeding compiler resource limits, routine: buildBrowseReply; some optimizations skipped. Use +Onolimit if override desired.

>anything I can do to speed up the compiling.

Break it up. Turn off inlining with +d or turn it down with +inline_level 1.
Or don't optimize since you can't really improve things.

Or change your code to use string::append.

xml.append("<");
xml.append(MDS_BROWSE_NODE);
xml.append(">");
xml.append("<");
xml.append(MDS_EXPANDABLE);
xml.append(">");
xml.append(MDS_TRUE);
xml.append(" xml.append(MDS_EXPANDABLE);
xml.append(">");
xml.append("<");
xml.append(MDS_IMPORTABLE);
xml.append(">");
xml.append(MDS_TRUE);
xml.append(" xml.append(MDS_IMPORTABLE);
xml.append(">");
xml.append("<");
// ...(Repeat 10 times)

This takes 8 seconds and if you reserve the string space, it could only take one malloc at runtime.
Exalted Contributor
Steven E. Protter
Posts: 33,806
Registered: ‎08-15-2002
Message 3 of 7 (221 Views)

Re: aCC take long time when using the optimize flag -O

Shalom,

Optimization should take time. The compiler has to do a lot more work to come up with the "best" binary.

Now it looks from your output that you ran out of resources during the compile and optimization was not complete.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Acclaimed Contributor
Dennis Handly
Posts: 25,047
Registered: ‎03-06-2006
Message 4 of 7 (221 Views)

Re: aCC take long time when using the optimize flag -O

>SEP: Optimization should take time.

Unfortunately in this case the optimizer tries too hard then gives up but wastes all that time. :-(

>Now it looks from your output that you ran out of resources during the compile and optimization was not complete.

(That was my output.)
Unless the code is rewritten like my suggestion, it isn't worth optimizing that large function. You can stop the optimization by using pragmas or use:
+O1=_Z...buildBrowseReply... (Using the mangled name).
Acclaimed Contributor
Dennis Handly
Posts: 25,047
Registered: ‎03-06-2006
Message 5 of 7 (221 Views)

Re: aCC take long time when using the optimize flag -O

(The actual mangled name in question.)
You can stop the optimization by using pragmas or use:
+O1=_Z16buildBrowseReplyRSsi
Occasional Advisor
sohochaser1
Posts: 10
Registered: ‎09-08-2008
Message 6 of 7 (221 Views)

Re: aCC take long time when using the optimize flag -O

Hi Dennis Handly,
Thanks for the information. I still have questions.

1. +O1=_Z16buildBrowseReplyRSsi, where do you get this flag? As I can get for the man aCC. Do you have any link to document?

2. Does +O1=_Z16buildBrowseReplyRSsi have the same effect as remove -O?

Thanks.
Allen
Acclaimed Contributor
Dennis Handly
Posts: 25,047
Registered: ‎03-06-2006
Message 7 of 7 (221 Views)

Re: aCC take long time when using the optimize flag -O

>1. +O1=_Z16buildBrowseReplyRSsi, where do you get this flag?

It's on the man page. +Olevel=name
http://docs.hp.com/en/14487/options.htm#opt+Olevel

>2. Does +O1=_Z16buildBrowseReplyRSsi have the same effect as remove -O?

But only for that one function, buildBrowseReply.
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.