public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* gcc: speed problem with several g++ versions
@ 2004-08-02 12:46 Andreas Kowarz
  2004-08-04  8:57 ` Alex Vinokur
  2004-08-04  9:12 ` gcc: " Falk Hueffner
  0 siblings, 2 replies; 7+ messages in thread
From: Andreas Kowarz @ 2004-08-02 12:46 UTC (permalink / raw)
  To: gcc-help


[-- Attachment #1.1: Type: text/plain, Size: 1132 bytes --]


Hello,

we made some interesting experience while implementing and testing a software 
package, which makes use of overloaded operators. One aspect of the 
implementation is the speed of the resulting binaries. To find the best solution 
we have tested the following approaches: normal overloading and templates. The 
example (attachment) contains the source code for 3 programms:

prog     - execution without overloading
progtemp - template based
progover - normal overloading

Compiled with g++ version 3.2 we got the following runtime:
prog       about 2.9 seconds
progtemp   about 2.9 seconds
progover   about 3.5 seconds
It seems clear that the template based implementation should be the one to use.

After recompiling with g++ version 3.4.1 we got a complete different result:
prog       about 2.9 seconds
progtemp   about 15.4 seconds !!!
progover   about 3.5 seconds
This time the template version is not really good. :-(
(Same problem with g++ version 3.3.2 on a different machine)

My questions are:
- Is this a known problem?
- Is there a compiler switch which can solve the problem?

Sincerely yours,

Andreas Kowarz

[-- Attachment #1.2: example.tar.bz2 --]
[-- Type: application/x-bzip, Size: 1704 bytes --]

[-- Attachment #1.3: kowarz.vcf --]
[-- Type: text/x-vcard, Size: 339 bytes --]

begin:vcard
fn:Andreas Kowarz
n:Kowarz;Andreas
org;quoted-printable:TU Dresden;Institut f=C3=BCr wissenschaftliches Rechnen
adr:;;Fachrichtung Mathematik;Dresden;Sachsen;D-01062;Germany
email;internet:kowarz@math.tu-dresden.de
title:Dipl.-Inf.
tel;work:+49 351 / 463 - 35060
note:ICQ: 165700422
x-mozilla-html:FALSE
version:2.1
end:vcard


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 256 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: speed problem with several g++ versions
  2004-08-02 12:46 gcc: speed problem with several g++ versions Andreas Kowarz
@ 2004-08-04  8:57 ` Alex Vinokur
  2004-08-04  9:12 ` gcc: " Falk Hueffner
  1 sibling, 0 replies; 7+ messages in thread
From: Alex Vinokur @ 2004-08-04  8:57 UTC (permalink / raw)
  To: gcc-help


"Andreas Kowarz" <kowarz@math.tu-dresden.de> wrote in message news:410E3788.1080806@math.tu-dresden.de...
>
> Hello,
>
> we made some interesting experience while implementing and testing a software
> package, which makes use of overloaded operators. One aspect of the
> implementation is the speed of the resulting binaries. To find the best solution
> we have tested the following approaches: normal overloading and templates. The
> example (attachment) contains the source code for 3 programms:
>
> prog     - execution without overloading
> progtemp - template based
> progover - normal overloading
>
> Compiled with g++ version 3.2 we got the following runtime:
> prog       about 2.9 seconds
> progtemp   about 2.9 seconds
> progover   about 3.5 seconds
> It seems clear that the template based implementation should be the one to use.
>
> After recompiling with g++ version 3.4.1 we got a complete different result:
> prog       about 2.9 seconds
> progtemp   about 15.4 seconds !!!
> progover   about 3.5 seconds
> This time the template version is not really good. :-(
> (Same problem with g++ version 3.3.2 on a different machine)
>
> My questions are:
> - Is this a known problem?
> - Is there a compiler switch which can solve the problem?
>
> Sincerely yours,
>
> Andreas Kowarz
>

tar (GNU tar) 1.13.25  doesn't extract files from example.tar which contains tested sources.



-- 
   Alex Vinokur
     http://mathforum.org/library/view/10978.html
     http://sourceforge.net/users/alexvn




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gcc: speed problem with several g++ versions
  2004-08-02 12:46 gcc: speed problem with several g++ versions Andreas Kowarz
  2004-08-04  8:57 ` Alex Vinokur
@ 2004-08-04  9:12 ` Falk Hueffner
  2004-08-04  9:22   ` Alex Vinokur
  2004-08-04 14:32   ` Andreas Kowarz
  1 sibling, 2 replies; 7+ messages in thread
From: Falk Hueffner @ 2004-08-04  9:12 UTC (permalink / raw)
  To: Andreas Kowarz; +Cc: gcc-help

Andreas Kowarz <kowarz@math.tu-dresden.de> writes:

> we made some interesting experience while implementing and testing a
> software package, which makes use of overloaded operators. One aspect
> of the implementation is the speed of the resulting binaries. To find
> the best solution we have tested the following approaches: normal
> overloading and templates. The example (attachment) contains the
> source code for 3 programms:
>
> prog     - execution without overloading
> progtemp - template based
> progover - normal overloading
>
> Compiled with g++ version 3.2 we got the following runtime:
> prog       about 2.9 seconds
> progtemp   about 2.9 seconds
> progover   about 3.5 seconds
> It seems clear that the template based implementation should be the one to use.
>
> After recompiling with g++ version 3.4.1 we got a complete different result:
> prog       about 2.9 seconds
> progtemp   about 15.4 seconds !!!
> progover   about 3.5 seconds
> This time the template version is not really good. :-(
> (Same problem with g++ version 3.3.2 on a different machine)
>
> My questions are:
> - Is this a known problem?
> - Is there a compiler switch which can solve the problem?

This seems to be something target specific; on Alpha, I get the exact
same time for all three programs with both 3.3 and 3.4. I guess one
would have to look at the assembly to see what causes it... might be
register allocation or inlining. You could try changing inline
settings and -fomit-frame-pointer and -fnew-ra.

-- 
	Falk

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gcc: speed problem with several g++ versions
  2004-08-04  9:12 ` gcc: " Falk Hueffner
@ 2004-08-04  9:22   ` Alex Vinokur
  2004-08-05 10:42     ` Alex Vinokur
  2004-08-04 14:32   ` Andreas Kowarz
  1 sibling, 1 reply; 7+ messages in thread
From: Alex Vinokur @ 2004-08-04  9:22 UTC (permalink / raw)
  To: gcc-help


"Falk Hueffner" <hueffner@informatik.uni-tuebingen.de> wrote in message news:87657zi7x7.fsf@informatik.uni-tuebingen.de...
[snip]
> This seems to be something target specific;
[snip]

Yes, performance of the same compiler on different targets is quite different.
See, for instance:
http://article.gmane.org/gmane.comp.lang.c%2B%2B.perfometer/37
http://groups.google.com/groups?selm=biihim%249opf4%241%40ID-79865.news.uni-berlin.de


-- 
   Alex Vinokur
     http://mathforum.org/library/view/10978.html
     http://sourceforge.net/users/alexvn




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gcc: speed problem with several g++ versions
  2004-08-04  9:12 ` gcc: " Falk Hueffner
  2004-08-04  9:22   ` Alex Vinokur
@ 2004-08-04 14:32   ` Andreas Kowarz
  2004-08-04 15:31     ` Marco Manfredini
  1 sibling, 1 reply; 7+ messages in thread
From: Andreas Kowarz @ 2004-08-04 14:32 UTC (permalink / raw)
  To: Falk Hueffner; +Cc: gcc-help


[-- Attachment #1.1: Type: text/plain, Size: 2763 bytes --]


Hi,

thank you for the quick response and your suggestions.

According to platform dependent results:
We have testes the old example on a Pentium3 700 MHz and on an Athlon-XP 1666 
MHz. The problem with the template version occurred for both machines.

However, we have a new example which leads to much more interesting results on 
these machines by using gcc332 and gcc341, respectively. The new example 
contains some overloaded basic operators, which can be used for very simple 
derivative calculations. The interesting observations concern the runtime, again.
On the Pentium3 the function evaluation (prog) needs more than twice the time 
than calculating function AND derivative (progover). (Somebody should wake me up 
:-) ). The difference on the Athlon-XP is not that high but has the same 
(unbelievable) signature.

By the way: We will not optimize our code for a specific compiler and version 
since we do not know, which compiler our users will apply. But we seem to have a 
good point for discussion about speed, now.

I hope this information is useful for gcc development.

Sincerely yours,

Andreas Kowarz

================================================================================

Falk Hueffner wrote:
> Andreas Kowarz <kowarz@math.tu-dresden.de> writes:
> 
> 
>>we made some interesting experience while implementing and testing a
>>software package, which makes use of overloaded operators. One aspect
>>of the implementation is the speed of the resulting binaries. To find
>>the best solution we have tested the following approaches: normal
>>overloading and templates. The example (attachment) contains the
>>source code for 3 programms:
>>
>>prog     - execution without overloading
>>progtemp - template based
>>progover - normal overloading
>>
>>Compiled with g++ version 3.2 we got the following runtime:
>>prog       about 2.9 seconds
>>progtemp   about 2.9 seconds
>>progover   about 3.5 seconds
>>It seems clear that the template based implementation should be the one to use.
>>
>>After recompiling with g++ version 3.4.1 we got a complete different result:
>>prog       about 2.9 seconds
>>progtemp   about 15.4 seconds !!!
>>progover   about 3.5 seconds
>>This time the template version is not really good. :-(
>>(Same problem with g++ version 3.3.2 on a different machine)
>>
>>My questions are:
>>- Is this a known problem?
>>- Is there a compiler switch which can solve the problem?
> 
> 
> This seems to be something target specific; on Alpha, I get the exact
> same time for all three programs with both 3.3 and 3.4. I guess one
> would have to look at the assembly to see what causes it... might be
> register allocation or inlining. You could try changing inline
> settings and -fomit-frame-pointer and -fnew-ra.
> 

[-- Attachment #1.2: template_example_3.tar.bz2 --]
[-- Type: application/x-bzip, Size: 2375 bytes --]

[-- Attachment #1.3: kowarz.vcf --]
[-- Type: text/x-vcard, Size: 339 bytes --]

begin:vcard
fn:Andreas Kowarz
n:Kowarz;Andreas
org;quoted-printable:TU Dresden;Institut f=C3=BCr wissenschaftliches Rechnen
adr:;;Fachrichtung Mathematik;Dresden;Sachsen;D-01062;Germany
email;internet:kowarz@math.tu-dresden.de
title:Dipl.-Inf.
tel;work:+49 351 / 463 - 35060
note:ICQ: 165700422
x-mozilla-html:FALSE
version:2.1
end:vcard


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 256 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gcc: speed problem with several g++ versions
  2004-08-04 14:32   ` Andreas Kowarz
@ 2004-08-04 15:31     ` Marco Manfredini
  0 siblings, 0 replies; 7+ messages in thread
From: Marco Manfredini @ 2004-08-04 15:31 UTC (permalink / raw)
  To: gcc-help

On Wednesday 04 August 2004 16:32, Andreas Kowarz wrote:

> According to platform dependent results:
> We have testes the old example on a Pentium3 700 MHz and on an Athlon-XP
> 1666 MHz. The problem with the template version occurred for both machines.

Hmm. Did you try marking you template functions inline? template functions 
aren't neccesarily inlined _automatically_ with all versions of gcc.


I've got this: 
progtemp without inline 10.9 sec.

Then I tagged the _declarations_ inline: 

template <class T> class adouble {
   public:
      inline adouble();
      inline adouble(const T v);
      inline adouble(const T v1, const T v2);
      
      inline void operator = (const T v);
      inline void operator = (const adouble& v);
      
etc...

An I've got:
progtemp with inline 0.7 sec.

Greetings
Marco

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: gcc: speed problem with several g++ versions
  2004-08-04  9:22   ` Alex Vinokur
@ 2004-08-05 10:42     ` Alex Vinokur
  0 siblings, 0 replies; 7+ messages in thread
From: Alex Vinokur @ 2004-08-05 10:42 UTC (permalink / raw)
  To: gcc-help


"Alex Vinokur" <alexvn@connect.to> wrote in message news:ceq9t0$5d5$1@sea.gmane.org...
>
> "Falk Hueffner" <hueffner@informatik.uni-tuebingen.de> wrote in message news:87657zi7x7.fsf@informatik.uni-tuebingen.de...
> [snip]
> > This seems to be something target specific;
> [snip]
>
> Yes, performance of the same compiler on different targets is quite different.
> See, for instance:
> http://article.gmane.org/gmane.comp.lang.c%2B%2B.perfometer/37
> http://groups.google.com/groups?selm=biihim%249opf4%241%40ID-79865.news.uni-berlin.de
>
[snip]

Also
http://groups.google.com/groups?threadm=bjosu1%24lk214%241%40ID-79865.news.uni-berlin.de


-- 
   Alex Vinokur
     http://mathforum.org/library/view/10978.html
     http://sourceforge.net/users/alexvn




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2004-08-05  5:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-02 12:46 gcc: speed problem with several g++ versions Andreas Kowarz
2004-08-04  8:57 ` Alex Vinokur
2004-08-04  9:12 ` gcc: " Falk Hueffner
2004-08-04  9:22   ` Alex Vinokur
2004-08-05 10:42     ` Alex Vinokur
2004-08-04 14:32   ` Andreas Kowarz
2004-08-04 15:31     ` Marco Manfredini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).