This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Different results of java and C verion of same program ?


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]