This is the mail archive of the java-discuss@sourceware.cygnus.com 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]

Re: bug in gcj constant folding


"Konstantin L. Metlov" wrote:
 
It seems there is a bug in a constant propagation (folding) code of gcj.
Sorry if it was already reported.


I suspect this could be related to the problem I reported a few days ago to do under "gcjh and static final's". The problem is to do with the source parser - if you compile your .java file with another java compiler (jikes or javac), then compile the class files to native code with gcj, the problem does not occur.

Unfortunately I was not able to run this test under latest egcs snapshot.
Compilation of recent libgcj failed for me with
gcj: Internal compiler error: program jc1 got fatal signal 11
when compiling class library to bytecode (gcj -C ... a lot of .java
files).
FYI: I'm getting this too. I might try checking out the gcc 2.95 branch from cvs if it doesn't go away soon.
Anyway gcj works great and runs my numerical simulation (physics) nearly
twice as fast as jdk with a JIT. This is my first simulation in java (all
others were in Fortran). I think java+gcj are great for numerical
computations when no special mathematical functions are required.
A while back I ran the Sieve.java benchmark (attached) that comes with TYA through GCJ and compared it to a few other environments:

Eratosthenes Sieve prime number benchmark in Java (P2 233Mhz)

                                 (iterations/sec)
Linux:
JDK 1.1.7A (no JIT)              76
JDK 1.1.7A (TYA 1.2v3 JIT)       248
kaffe 1.0b4                      335
JDK 1.2pre1 (Sun JIT)            494
gcj -O (w/array bounds checking) 1099
gcj -O (--no-bounds-check)       2005

Windows:
JDK 1.1.7 (NT, no JIT)           81
JDK 1.2 (NT w/JIT)               1404
JDK 1.1.7 (NT w/JIT)             1423

I've noticed that gcj compiled numerical benchmarks seem to perform faster with -O than with -O3. Strange, since I allways thought that higher numbers were supposed to increase the level of optimisation?

regards

  [ bryce ]
 

//  Eratosthenes Sieve prime number benchmark in Java

public class Sieve {

  static String results1, results2;

  public static void main(String[] args) {
     System.out.println("Running Sieve benchmark.");
     System.out.println("This will take about 10 seconds.");
     runSieve();
     System.out.println(results1);
     System.out.println(results2);
  }

  static void runSieve() {
     int SIZE = 8190;
     boolean flags[] = new boolean[SIZE+1];
     int i, prime, k, iter, count;
     int iterations = 0;
     double seconds = 0.0;
     int score = 0;
     long startTime, elapsedTime;

     startTime = System.currentTimeMillis();
     while (true) {
        count=0;
        for(i=0; i<=SIZE; i++) flags[i]=true;
        for (i=0; i<=SIZE; i++) {
           if(flags[i]) {
              prime=i+i+3;
              for(k=i+prime; k<=SIZE; k+=prime)
                 flags[k]=false;
              count++;
           }
        }
        iterations++;
        elapsedTime = System.currentTimeMillis() - startTime;
        if (elapsedTime >= 10000) break;
     }
     seconds = elapsedTime / 1000.0;
     score = (int) Math.round(iterations / seconds);
     results1 = iterations + " iterations in " + seconds + " seconds";
     if (count != 1899)
        results2 = "Error: count <> 1899";
     else
        results2 = "Sieve score = " + score;
  }
}

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