OOO and RCR are speparate targets in the master makefile, added runp scripts for...
[IRC.git] / Robust / src / Benchmarks / oooJava / micro4 / test.java
1 public class Foo {
2   public Foo() {}
3   int f;
4 }
5
6
7 public class test {
8
9   public static void main( String argv[] ) {
10     
11     long count  = 500;
12     int  numFoo = 1000;
13     
14     if( argv.length > 0 ) {
15       count = count * Integer.parseInt( argv[0] );
16     }
17
18     if( argv.length > 1 ) {
19       numFoo = numFoo * Integer.parseInt( argv[1] );
20     }
21             
22
23     long s = System.currentTimeMillis();
24     long e1;
25     long e2;
26
27     rblock parent {
28
29       Foo[] array = new Foo[numFoo];
30
31       for( int i = 0; i < numFoo; i++ ) {
32         array[i] = new Foo();
33       }
34                   
35       for( long j = 0; j < count; j++ ) {
36         for( int i = 0; i < numFoo; i++ ) {
37
38           rblock child1 {
39             int x = 2;
40           }
41
42           Foo foo = array[i];
43
44           // a variable fro sib
45           // AND memory dependence
46           rblock child2 {
47             foo.f += x;
48           }
49         }
50       }
51
52       // force a coarse grained conflict
53       //array[numFoo - 1].f++;
54       
55
56       e1 = System.currentTimeMillis();
57       long z = 1;
58     }
59     // just read vars so compile doesn't throw them out
60     // and force parent of parent to depend on z, for
61     // timing
62     System.out.println( "ignore: "+z );
63     e2 = System.currentTimeMillis();
64
65
66     double dt1 = ((double)e1-s)/(Math.pow( 10.0, 3.0 ) );
67     double dt2 = ((double)e2-s)/(Math.pow( 10.0, 3.0 ) );
68     System.out.println( "dt to parent done   ="+dt1+"s" );
69     System.out.println( "dt to parent retired="+dt2+"s" );
70
71   }
72 }