Amol Chiplunkar's Weblog

All | Music | Personal | Sports | Sun | Systems Management
« Sun Fire T1000 Physi... | Main | ThreadGroup added to... »
20060911 Monday September 11, 2006

Fun with multi threaded java program on T1 Thought about having some fun with java and T1. Googled around to find some easy benchmarking tools but couldn't find one with a write-up on usage which I could understand within 5 mins. So thought let me write a basic multi threaded program and see how it behaves on T1 and the normal (sun4u) processor machines.
This is how it behaved on a single physical cpu sun4u box.

$ psrinfo -pv
The physical processor has 1 virtual processor (0)
  UltraSPARC-IIIi (portid 0 impl 0x16 ver 0x24 clock 1280 MHz)
$  time java TestCPU 10 5000 N Y
Threads: 10 Computes: 5000
IO: false Threading: true
done !

real        2.9
user        2.8
sys         0.0
$  time java TestCPU 10 5000 N Y
Threads: 10 Computes: 5000
IO: false Threading: true
done !

real        3.8
user        3.7
sys         0.0
$


And this is what it gave on a single physical cpu T1 box
$ psrinfo -pv
The physical processor has 24 virtual processors 
(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23)
  UltraSPARC-T1 (cpuid 0 clock 1000 MHz)
$  time java TestCPU 10 5000 N Y
Threads: 10 Computes: 5000
IO: false Threading: true
done !

real        1.3
user        9.5
sys         0.1
$  time java TestCPU 10 5000 N Y
Threads: 10 Computes: 5000
IO: false Threading: true
done !

real        1.3
user        9.4
sys         0.1
$

wonderful !! This is how it worked on two physical processor sun4u box
# psrinfo -pv
The physical processor has 1 virtual processor (4)
  UltraSPARC-III+ (portid 4 impl 0x15 ver 0xb1 clock 1200 MHz)
The physical processor has 1 virtual processor (6)
  UltraSPARC-III+ (portid 6 impl 0x15 ver 0xb1 clock 1200 MHz)
#  time java TestCPU 10 5000 N Y
Threads: 10 Computes: 5000
IO: false Threading: true
done !

real        1.7
user        2.9
sys         0.0
#  time java TestCPU 10 5000 N Y
Threads: 10 Computes: 5000
IO: false Threading: true
done !

real        2.1
user        3.5
sys         0.0
#

Still trying to read proper meanings out of it, and playing around occasionally to get more findings with threading on and off.
BTW, This is silly the program.

public class TestCPU implements Runnable {
    static int  threads,computes;
    static boolean io;
    static boolean threading;

    public static void main (String args[]) {
        TestCPU t = new TestCPU();

        try {
            threads = (new Integer(args[0])).intValue();
            computes = (new Integer(args[1])).intValue();

            if ( args[2].equals("Y") ) io = true;
            if ( args[3].equals("Y") ) threading = true;
        } catch (Exception nfe) {
            // either NumberFormat or ArrayIndexOutOfBounds
            System.err.println("Using defaults");
            threads=100;
            computes=100;
            io = false;
            threading = false;
        }

        System.out.println("Threads: " + threads + " Computes: " + computes );
        System.out.println("IO: " + io + " Threading: " + threading);

        for (int i=0;i<threads;i++) {
            if ( threading )
                (new Thread(t)).start();
            else
                compute();
        }

        System.out.println("done !");
    }

    public void run() {
        compute();
    }

    static void compute() {
        int load;
        for (int j=1; j<computes;j++)
          for (int k=1; k<computes;k++) {
            // do some computing
            load = threads + computes;

            if ( io ) System.out.println("Load: " + load);
          }
    }
}

... Not sure I am doing the right thing or not, but I am lovin' it. :)

Posted by chiplunkar ( Sep 11 2006, 06:00:00 PM IST ) Permalink Comments [0]

Trackback URL: http://blogs.sun.com/chiplunkar/entry/fun_with_multi_threaded_java
Comments:

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed

Calendar

RSS Feeds

Search

Links

Navigation

Referers

Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.