fix bugs
[IRC.git] / Robust / src / Benchmarks / Scheduling / GC / NON_BAMBOO / RayTracer / TestRunner.p
1 package RayTracer;
2
3 /**************************************************************************
4  * * Java Grande Forum Benchmark Suite - Version 2.0 * * produced by * * Java
5  * Grande Benchmarking Project * * at * * Edinburgh Parallel Computing Centre *
6  * * email: epcc-javagrande@epcc.ed.ac.uk * * * This version copyright (c) The
7  * University of Edinburgh, 1999. * All rights reserved. * *
8  **************************************************************************/
9
10 public class TestRunner extends RayTracer {
11
12   int numCore;
13   public int id;
14
15   public TestRunner(int id, 
16       int numCore,
17       int size,
18       int image[][],                                    
19       Scene scene) {
20     super();
21     this.id = id;
22     this.numCore = numCore;
23     this.size = size;
24     this.image=image;
25     // create the objects to be rendered
26     this.scene = scene; //createScene();
27
28     // set image size
29     width=size;
30     height=size;
31     // get lights, objects etc. from scene.
32     setScene(this.scene);
33
34     numobjects = this.scene.getObjects();
35     /*this.image=new int[size][];
36
37     // get lights, objects etc. from scene.
38     setScene(scene);
39
40     numobjects = scene.getObjects();*/
41   }
42
43   public void init() {
44
45   }
46
47   public void JGFvalidate() {
48     // long refval[] = {2676692,29827635};
49     //  long refval[] = new long[2];
50     //  refval[0] = 2676692;
51     //  refval[1] = 29827635;
52     //  long dev = checksum - refval[size];
53     //  if (dev != 0) {
54     //  System.out.println("Validation failed");
55     //  System.out.println("Pixel checksum = " + checksum);
56     //  System.out.println("Reference value = " + refval[size]);
57     //  }
58   }
59
60   public void JGFtidyup() {
61     //  scene = null;
62     //  lights = null;
63     //  prim = null;
64     //  tRay = null;
65     //  inter = null;
66     // System.gc();
67   }
68
69   public void run() {
70                     this.init();
71                     float heightPerCore=height/numCore;
72                     int startidx=(height*this.id)/numCore;
73                     int endidx=(height*(this.id+1))/numCore;
74                     if (id==(THREADNUM-1))
75                     endidx=height;
76                     Interval interval = new Interval(0, width, height, startidx, endidx, 1);
77                     render(interval);
78     //System.out.println("CHECKSUM="+checksum);
79
80   }
81   public static void main(String[] args) {
82     int threadnum = THREADNUM; // 56;
83     int size = 500; //threadnum * 25;
84     System.setgcprofileflag();
85     Composer comp = new Composer(threadnum, size);
86     RayTracer rt = new RayTracer();
87     Scene scene = rt.createScene();
88     int image[][]=new int[size][];
89     TestRunner trarray[]=new TestRunner[threadnum];                                      
90     for(int i = 1; i < threadnum; ++i) {
91       TestRunner tr = new TestRunner(i, threadnum, size, image, scene);
92       tr.start();
93                                        trarray[i]=tr;
94                                        }
95              TestRunner tr0 = new TestRunner(0, threadnum, size, image, scene);
96       tr0.run();
97     for(int i = 1; i < threadnum; ++i) {
98                                        trarray[i].join();
99                                        }
100 }
101 }