This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
RE: Different results of java and C verion of same program ?
- From: Andrew Haley <aph at redhat dot com>
- To: David BalaÅic <david dot balazic at hermes dot si>
- Cc: java at gcc dot gnu dot org
- Date: Wed, 8 Mar 2006 10:13:37 +0000
- Subject: RE: Different results of java and C verion of same program ?
- References: <440EAC9F.6070508@hermes.si>
David Bala¾ic writes:
> I wrote:
>
> > Hi!
> >
> > I use gcc 3.3.5 (debian 3.1).
> > *
> > I have written a program in jav*a and compiled it with gcj.
> > Then I ported it to C and compiled with gcc.
> >
> > They give different results !
> >
> > Can this be some compiler error ?
> > Computing accuracy related ?
>
> It turned out, it was a bug in my C code (buffer overflow) :-(
>
> The problem now is : The Java compiled version is "too" slow.
>
> Here are the runtimes :
> - Sun JIT : 800 ms
> - C (optimised build) : 400 ms
> - gcj compiled : 4000 ms
>
> As you see, gcj is 10 times slower. Different -O options don't help.
> -O values above 2 make it break (null "pointer" exception right after
> start).
>
> The main part of the program is a double loop, comparing each element of
> a Vector
> with all other elements of the Vector (except itself).
>
> Any ideas for speedup ?
No, of course not. We don't know what your benchmark is or how it
might be better compiled with gcj. We don't know what your equivalent
C version looks like, either. The null pointer exceptions leads me to
suppose that your gcj might be entirely broken.
Now, it is possible that a really good JIT might notice optimization
opportunities that gcc misses, especially in a small self-contained
benchmark. But a factor of 10 loss of speed is rather extreme.
Andrew.