* DecC vs. gcc-2.8.1, why is the difference in speed so large?
@ 1999-06-04 4:00 Christoph Walti
1999-06-04 4:00 ` David T. Blake
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Christoph Walti @ 1999-06-04 4:00 UTC (permalink / raw)
Hi,
recently, I compared the speed of a very simple program (posted below),
which was once compiled using DecC and a second time using GNU gcc-2.8.1
on a Digital-alpha staion DS20 with DUnix4.0F. To my very surprise, the
DecC-compiled version was at least 30, if not even 50 times as fast as the
gcc-compiled version! I did not use any optimisation flags, but the ones
which are set by default (are there any? I don't know.)
Does someone know, where this enormous difference comes from? Does the
DecC compiler realize, that in this loop nothing is to do anyway, and
therefore, the result is known from the very beginning and can be put in
the executable directly?
Thanks for your help
Chris
PS1: This difference in speed persists, when the printf-statement is removed.
PS2: The gcc version was compiled on this machine (and should be optimized
for ev6).
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <setjmp.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
void do_that(int *);
int r1=0, r2=0;
main()
{
do_that;
}
void do_that(int *anz)
{
int i,j,x;
for (i=0; i <15; i++) {
printf("doing this\n");
x=0;
for (j=0; j <10000000; j++) x=x+i; /* 10 millions */
(*anz)++;
}
}
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: DecC vs. gcc-2.8.1, why is the difference in speed so large?
1999-06-04 4:00 DecC vs. gcc-2.8.1, why is the difference in speed so large? Christoph Walti
@ 1999-06-04 4:00 ` David T. Blake
1999-06-08 4:00 ` Jeff Sullivan
1999-06-07 4:00 ` Mark Gelinas
1999-06-08 4:00 ` Serguei Patchkovskii
2 siblings, 1 reply; 6+ messages in thread
From: David T. Blake @ 1999-06-04 4:00 UTC (permalink / raw)
njmp_walti@njmp_solid.phys.ethz.ch (Christoph Walti) writes:
>which was once compiled using DecC and a second time using GNU
>gcc-2.8.1 on a Digital-alpha staion DS20 with DUnix4.0F. To my very
>surprise, the DecC-compiled version was at least 30, if not even 50
>times as fast as the gcc-compiled version! I did not use any
>optimisation flags, but the ones which are set by default (are there
>any? I don't know.) Does someone know, where this enormous
>difference comes from? Does the DecC compiler realize, that in this
>loop nothing is to do anyway, and therefore, the result is known from
>the very beginning and can be put in the executable directly?
I am not certain what contributes to your speed difference,
but I write all kinds of number crunching float/int operations
under Dec Unix. I ocassionally try to optimize once for gcc and
once for cc. I cannot beat cc for speed. Typically I get
15-20% speed differences.
However, I also find subtle differences in the parsing of
the compilers, and I am either more used to gcc, or it is
more bug free, because I continue to use it. Things like
typecasting of arguments tend to get me in much more trouble
using cc than gcc.
--
Dave Blake
dblake@phy.ucsf.edu
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: DecC vs. gcc-2.8.1, why is the difference in speed so large?
1999-06-04 4:00 ` David T. Blake
@ 1999-06-08 4:00 ` Jeff Sullivan
0 siblings, 0 replies; 6+ messages in thread
From: Jeff Sullivan @ 1999-06-08 4:00 UTC (permalink / raw)
"David T. Blake" wrote:
> ... I write all kinds of number crunching float/int operations
> under Dec Unix. I ocassionally try to optimize once for gcc and
> once for cc. I cannot beat cc for speed. Typically I get
> 15-20% speed differences.
If you are running V4.0D or later, you might also be interested
in trying the Developer's Toolkit compiler, which contains newer
features and diagnostics, as well as a better optimizer (especially
for ev6). See http://www.unix.digital.com/developerstoolkit/
> However, I also find subtle differences in the parsing of
> the compilers, and I am either more used to gcc, or it is
> more bug free, because I continue to use it. Things like
> typecasting of arguments tend to get me in much more trouble
> using cc than gcc.
Please send me details of the differences or things that you
consider bugs in DEC C and we'll take a look. I would need
to know which version of the compiler and OS that you are
working with.
Thanks,
-Jeff
--
Jeff Sullivan | Compaq Computer Corp | mailto:jps@zk3.dec.com
Compaq C/C++ | Nashua, NH ZK3-2X23 | Jeff.Sullivan@compaq.com
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: DecC vs. gcc-2.8.1, why is the difference in speed so large?
1999-06-04 4:00 DecC vs. gcc-2.8.1, why is the difference in speed so large? Christoph Walti
1999-06-04 4:00 ` David T. Blake
@ 1999-06-07 4:00 ` Mark Gelinas
1999-06-08 4:00 ` Serguei Patchkovskii
2 siblings, 0 replies; 6+ messages in thread
From: Mark Gelinas @ 1999-06-07 4:00 UTC (permalink / raw)
njmp_walti@njmp_solid.phys.ethz.ch (Christoph Walti) writes:
> Hi,
>
> recently, I compared the speed of a very simple program (posted below),
> which was once compiled using DecC and a second time using GNU gcc-2.8.1
> on a Digital-alpha staion DS20 with DUnix4.0F. To my very surprise, the
> DecC-compiled version was at least 30, if not even 50 times as fast as the
> gcc-compiled version! I did not use any optimisation flags, but the ones
> which are set by default (are there any? I don't know.)
> Does someone know, where this enormous difference comes from? Does the
> DecC compiler realize, that in this loop nothing is to do anyway, and
> therefore, the result is known from the very beginning and can be put in
> the executable directly?
>
> Thanks for your help
>
> Chris
>
On DU4.0F, the DEC C compiler defaults to -O1 (minimal optimization).
If memory serves, gcc defaults to -O2.
I've seen postings where user testing has shown that the DEC C math
libraries can improve performance of calculation-intensive code by a
factor of 50 or more. This is because they were crafted for the Alpha
CPU, so can best take advantage of it. Gcc has no/darn little Alpha-specific
optimization capabilities. Egcs is better, but not much. If you want speed,
use the DEC C compiler.
>
> PS1: This difference in speed persists, when the printf-statement is
> removed.
Again, math libraries make the difference.
> PS2: The gcc version was compiled on this machine (and should be
> optimized for ev6).
>
Compiling natively will only make gcc run faster on the DS20. It will not
allow gcc to produce better EV6-specific binaries.
MarkG
--
Mark Gelinas Compaq Computer Corporation
EMail: gelinas@zk3.dec.com 110 Spit Brook Road, ZKO3-3/V08
Phone: +1 (603) 884-1511 Nashua, NH 03062-2698 USA
Views expressed are my own, and not necessarily those of my employer.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: DecC vs. gcc-2.8.1, why is the difference in speed so large?
1999-06-04 4:00 DecC vs. gcc-2.8.1, why is the difference in speed so large? Christoph Walti
1999-06-04 4:00 ` David T. Blake
1999-06-07 4:00 ` Mark Gelinas
@ 1999-06-08 4:00 ` Serguei Patchkovskii
1999-06-08 4:00 ` Jeff Sullivan
2 siblings, 1 reply; 6+ messages in thread
From: Serguei Patchkovskii @ 1999-06-08 4:00 UTC (permalink / raw)
Christoph Walti (njmp_walti@njmp_solid.phys.ethz.ch) wrote:
: recently, I compared the speed of a very simple program (posted below),
: which was once compiled using DecC and a second time using GNU gcc-2.8.1
: on a Digital-alpha staion DS20 with DUnix4.0F. To my very surprise, the
: DecC-compiled version was at least 30, if not even 50 times as fast as the
: gcc-compiled version! I did not use any optimisation flags, but the ones
[snip]
: void do_that(int *anz)
: {
: int i,j,x;
: for (i=0; i <15; i++) {
: printf("doing this\n");
: x=0;
: for (j=0; j <10000000; j++) x=x+i; /* 10 millions */
: (*anz)++;
: }
: }
Your benchmark is meaningless, as the entire inner loop computing 'x'
can be eliminated after simple local analysis of the do_that() subroutine.
gcc deliberately refrains from performing loop elimination in such cases,
as this can result in unexpected results for programs relying on loops for
delays (which is a bad idea in any case - but that had never stopped anyone).
DEC cc apparently removes your inner loop at the default optimization level,
which can easily explain a factor of 50 difference in the timing.
/Serge.P
--
home page: http://www.cobalt.chem.ucalgary.ca/ps/
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: DecC vs. gcc-2.8.1, why is the difference in speed so large?
1999-06-08 4:00 ` Serguei Patchkovskii
@ 1999-06-08 4:00 ` Jeff Sullivan
0 siblings, 0 replies; 6+ messages in thread
From: Jeff Sullivan @ 1999-06-08 4:00 UTC (permalink / raw)
Serguei Patchkovskii wrote:
> Your benchmark is meaningless, as the entire inner loop computing 'x'
> can be eliminated after simple local analysis of the do_that() subroutine.
> gcc deliberately refrains from performing loop elimination in such cases,
> as this can result in unexpected results for programs relying on loops for
> delays (which is a bad idea in any case - but that had never stopped anyone).
> DEC cc apparently removes your inner loop at the default optimization level,
> which can easily explain a factor of 50 difference in the timing.
Yes, this is true. The original test case that was posted also
contained this in main():
do_that; /* instead of do_that(&some_int);
which is not actually a function call and even more meaningless.
There are many test cases and "real world" code that will demostrate
the improved optimizations provided by Compaq C (formerly DEC C), but
this case is not a very good (or fair) example.
For developers interested in an even more advanced compiler for
UNIX V4.0D and later, you might take a look at the Developer's
Toolkit for Tru64 UNIX.
See http://www.unix.digital.com/developerstoolkit/
-Jeff
--
Jeff Sullivan | Compaq Computer Corp | mailto:jps@zk3.dec.com
Compaq C/C++ | Nashua, NH ZK3-2X23 | Jeff.Sullivan@compaq.com
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~1999-06-08 4:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-06-04 4:00 DecC vs. gcc-2.8.1, why is the difference in speed so large? Christoph Walti
1999-06-04 4:00 ` David T. Blake
1999-06-08 4:00 ` Jeff Sullivan
1999-06-07 4:00 ` Mark Gelinas
1999-06-08 4:00 ` Serguei Patchkovskii
1999-06-08 4:00 ` Jeff Sullivan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox