The Computer Language
24.11 Benchmarks Game

mandelbrot Java OpenJ9 #8 program

source code

/* The Computer Language Benchmarks Game
   https://salsa.debian.org/benchmarksgame-team/benchmarksgame/

   line-by-line from Greg Buchholz's C program
*/


class mandelbrot {

public static void main(String[] args) {   
 
    int w, h, bit_num = 0;
    int byte_acc = 0;
    int i, iter = 50;    
    double x, y, limit = 2.0;
    double Zr, Zi, Cr, Ci, Tr, Ti; 

    w = h = Integer.parseInt(args[0]);

    System.out.println("P4\n"+ w + " " + h);    
    
    for(y=0;y<h;y++) 
    {
        for(x=0;x<w;x++)
        {
            Zr = Zi = Tr = Ti = 0.0;
            Cr = (2.0*(double)x/w - 1.5); Ci=(2.0*(double)y/h - 1.0);            
        
            for (i=0;i<iter && (Tr+Ti <= limit*limit);++i)
            {
                Zi = 2.0*Zr*Zi + Ci;
                Zr = Tr - Ti + Cr;
                Tr = Zr * Zr;
                Ti = Zi * Zi;
            }
        
            byte_acc <<= 1; 
            if(Tr+Ti <= limit*limit) byte_acc |= 0x01;
                
            ++bit_num; 

            if(bit_num == 8)
            {                      
                System.out.write(byte_acc);
                byte_acc = 0;
                bit_num = 0;
            }
            else if(x == w-1)
            {
                byte_acc = byte_acc << (8-w%8);
                System.out.write(byte_acc);
                byte_acc = 0;
                bit_num = 0;
            }
        }
    }	
    System.out.flush();
}
}
    

notes, command-line, and program output

NOTES:
64-bit Ubuntu quad core
openjdk 23 2024-09-17
IBM Semeru Runtimebr>
Eclipse OpenJ9
(build openj9-0.47.0) 
(JIT enabled, AOT enabled)


 Mon, 04 Nov 2024 21:38:01 GMT

MAKE:
mv mandelbrot.openj9-8.openj9 mandelbrot.java
/opt/src/ibm-semeru-23/bin/javac -d . -cp .  mandelbrot.java

2.87s to complete and log all make actions

COMMAND LINE:
 /opt/src/ibm-semeru-23/bin/java -Xshareclasses -XX:SharedCacheHardLimit=200m -Xscmx60m -Xtune:virtualized  -cp . mandelbrot 16000

(BINARY) PROGRAM OUTPUT NOT SHOWN