--- /dev/null
+public class Composer {
+
+ flag compose;
+
+ int numCore;
+ int num_composed;
+ int image[][];
+ int heightPerCore;
+
+ public Composer(int numCore,
+ int size) {
+ this.numCore = numCore;
+ this.num_composed = 0;
+ heightPerCore = size/this.numCore;
+
+ // set image size
+ this.image=new int[size][];
+ }
+
+ public boolean compose(TestRunner tr) {
+ this.num_composed++;
+ int startidx=heightPerCore * tr.id;
+ int endidx=startidx + heightPerCore;
+ for(int i = startidx; i < endidx; i++) {
+ //this.image[i] = tr.image[i];
+ }
+ return this.num_composed == this.numCore;
+ }
+}
\ No newline at end of file
--- /dev/null
+/**************************************************************************
+ * *
+ * Java Grande Forum Benchmark Suite - Version 2.0 *
+ * *
+ * produced by *
+ * *
+ * Java Grande Benchmarking Project *
+ * *
+ * at *
+ * *
+ * Edinburgh Parallel Computing Centre *
+ * *
+ * email: epcc-javagrande@epcc.ed.ac.uk *
+ * *
+ * Original version of this code by *
+ * Florian Doyon (Florian.Doyon@sophia.inria.fr) *
+ * and Wilfried Klauser (wklauser@acm.org) *
+ * *
+ * This version copyright (c) The University of Edinburgh, 1999. *
+ * All rights reserved. *
+ * *
+ **************************************************************************/
+
+
+public class Interval {
+
+ public final int number;
+ public final int width;
+ public final int height;
+ public final int yfrom;
+ public final int yto;
+ public final int total;
+
+ public Interval(int number, int width, int height, int yfrom, int yto, int total)
+ {
+ this.number = number;
+ this.width = width;
+ this.height = height;
+ this.yfrom = yfrom;
+ this.yto = yto;
+ this.total = total;
+ }
+}
--- /dev/null
+/**************************************************************************
+ * *
+ * Java Grande Forum Benchmark Suite - Version 2.0 *
+ * *
+ * produced by *
+ * *
+ * Java Grande Benchmarking Project *
+ * *
+ * at *
+ * *
+ * Edinburgh Parallel Computing Centre *
+ * *
+ * email: epcc-javagrande@epcc.ed.ac.uk *
+ * *
+ * Original version of this code by *
+ * Florian Doyon (Florian.Doyon@sophia.inria.fr) *
+ * and Wilfried Klauser (wklauser@acm.org) *
+ * *
+ * This version copyright (c) The University of Edinburgh, 1999. *
+ * All rights reserved. *
+ * *
+ **************************************************************************/
+
+
+public class Isect {
+ public float t;
+ public int enter;
+ public Sphere prim;
+ public Surface surf;
+
+ public Isect(){
+ t=0;
+ enter=0;
+ }
+
+}
--- /dev/null
+/**************************************************************************
+ * *
+ * Java Grande Forum Benchmark Suite - Version 2.0 *
+ * *
+ * produced by *
+ * *
+ * Java Grande Benchmarking Project *
+ * *
+ * at *
+ * *
+ * Edinburgh Parallel Computing Centre *
+ * *
+ * email: epcc-javagrande@epcc.ed.ac.uk *
+ * *
+ * Original version of this code by *
+ * Florian Doyon (Florian.Doyon@sophia.inria.fr) *
+ * and Wilfried Klauser (wklauser@acm.org) *
+ * *
+ * This version copyright (c) The University of Edinburgh, 1999. *
+ * All rights reserved. *
+ * *
+ **************************************************************************/
+
+
+public class Light
+//implements java.io.Serializable
+{
+ public Vec pos;
+ public float brightness;
+
+ public Light() {
+ }
+
+ public Light(float x, float y, float z, float brightness) {
+ this.pos = new Vec(x, y, z);
+ this.brightness = brightness;
+ }
+}
--- /dev/null
+/**************************************************************************
+ * *
+ * Java Grande Forum Benchmark Suite - Version 2.0 *
+ * *
+ * produced by *
+ * *
+ * Java Grande Benchmarking Project *
+ * *
+ * at *
+ * *
+ * Edinburgh Parallel Computing Centre *
+ * *
+ * email: epcc-javagrande@epcc.ed.ac.uk *
+ * *
+ * Original version of this code by *
+ * Florian Doyon (Florian.Doyon@sophia.inria.fr) *
+ * and Wilfried Klauser (wklauser@acm.org) *
+ * *
+ * This version copyright (c) The University of Edinburgh, 1999. *
+ * All rights reserved. *
+ * *
+ **************************************************************************/
+
+
+public class Primitive
+{
+ public Surface surf;
+
+ public Primitive(){
+ surf=new Surface();
+ }
+
+ public void setColor(float r, float g, float b) {
+ surf.color = new Vec(r, g, b);
+ }
+
+ public /*abstract*/ Vec normal(Vec pnt);
+ public /*abstract*/ Isect intersect(Ray ry);
+ public /*abstract*/ String toString();
+ public /*abstract*/ Vec getCenter();
+ public /*abstract*/ void setCenter(Vec c);
+
+}
--- /dev/null
+/**************************************************************************
+ * *
+ * Java Grande Forum Benchmark Suite - Version 2.0 *
+ * *
+ * produced by *
+ * *
+ * Java Grande Benchmarking Project *
+ * *
+ * at *
+ * *
+ * Edinburgh Parallel Computing Centre *
+ * *
+ * email: epcc-javagrande@epcc.ed.ac.uk *
+ * *
+ * Original version of this code by *
+ * Florian Doyon (Florian.Doyon@sophia.inria.fr) *
+ * and Wilfried Klauser (wklauser@acm.org) *
+ * *
+ * This version copyright (c) The University of Edinburgh, 1999. *
+ * All rights reserved. *
+ * *
+ **************************************************************************/
+
+
+
+final public class Ray {
+ public Vec P, D;
+
+ public Ray(Vec pnt, Vec dir) {
+ P = new Vec(pnt.x, pnt.y, pnt.z);
+ D = new Vec(dir.x, dir.y, dir.z);
+ D.normalize();
+ }
+
+ public Ray() {
+ P = new Vec();
+ D = new Vec();
+ }
+
+ public Vec point(float t) {
+ return new Vec(P.x + D.x * t, P.y + D.y * t, P.z + D.z * t);
+ }
+
+ public String toString() {
+ return "{" + P.toString() + " -> " + D.toString() + "}";
+ }
+}
--- /dev/null
+
+/**************************************************************************
+ * * Java Grande Forum Benchmark Suite - Version 2.0 * * produced by * * Java
+ * Grande Benchmarking Project * * at * * Edinburgh Parallel Computing Centre *
+ * * email: epcc-javagrande@epcc.ed.ac.uk * * Original version of this code by *
+ * Florian Doyon (Florian.Doyon@sophia.inria.fr) * and Wilfried Klauser
+ * (wklauser@acm.org) * * This version copyright (c) The University of
+ * Edinburgh, 1999. * All rights reserved. * *
+ **************************************************************************/
+
+public class RayTracer {
+
+ public int image[][];
+
+ Scene scene;
+ /**
+ * Lights for the rendering scene
+ */
+ Light lights[];
+
+ /**
+ * Objects (spheres) for the rendering scene
+ */
+ Primitive prim[];
+
+ /**
+ * The view for the rendering scene
+ */
+ View view;
+
+ /**
+ * Temporary ray
+ */
+ // Ray tRay= new Ray();
+ // Ray tRay;
+
+ /**
+ * Alpha channel
+ */
+ // static final int alpha = 255 << 24;
+ static final int alpha;
+
+ /**
+ * Null vector (for speedup, instead of <code>new Vec(0,0,0)</code>
+ */
+ // static final Vec voidVec = new Vec();
+ // static final Vec voidVec;
+
+ /**
+ * Temporary vect
+ */
+ // Vec L = new Vec();
+ // Vec L;
+
+ /**
+ * Current intersection instance (only one is needed!)
+ */
+ // Isect inter = new Isect();
+ // Isect inter;
+
+ /**
+ * Height of the <code>Image</code> to be rendered
+ */
+ int height;
+
+ /**
+ * Width of the <code>Image</code> to be rendered
+ */
+ int width;
+
+ // int datasizes[] = { 150, 500 };
+ int datasizes[];
+
+ long checksum;
+
+ int size;
+
+ int numobjects;
+
+ public RayTracer() {
+ // tRay = new Ray();
+ alpha = 255 << 24;
+ // voidVec = new Vec();
+ // L = new Vec();
+ // inter = new Isect();
+ checksum = 0;
+ datasizes = new int[2];
+ datasizes[0] = 150;
+ datasizes[1] = 500;
+ numobjects = 0;
+ width = 0;
+ height = 0;
+ size = 0;
+ }
+
+ /**
+ * Create and initialize the scene for the rendering picture.
+ *
+ * @return The scene just created
+ */
+
+ Scene createScene() {
+ int x = 0;
+ int y = 0;
+
+ Scene scene = new Scene();
+
+ /* create spheres */
+
+ Primitive p;
+ int nx = 4;
+ int ny = 4;
+ int nz = 4;
+ for (int i = 0; i < nx; i++) {
+ for (int j = 0; j < ny; j++) {
+ for (int k = 0; k < nz; k++) {
+ float xx = (float) (20.0f / (nx - 1) * i - 10.0);
+ float yy = (float) (20.0f / (ny - 1) * j - 10.0);
+ float zz = (float) (20.0f / (nz - 1) * k - 10.0);
+
+ p = new Sphere(new Vec(xx, yy, zz), 3);
+ // p.setColor(i/(float) (nx-1), j/(float)(ny-1),
+ // k/(float) (nz-1));
+ p.setColor(0, 0, (i + j) / (float) (nx + ny - 2));
+ p.surf.shine = (float) 15.0;
+ p.surf.ks = (float) (1.5 - 1.0);
+ p.surf.kt = (float) (1.5 - 1.0);
+ scene.addObject(p);
+ }
+ }
+ }
+
+ /* Creates five lights for the scene */
+ scene.addLight(new Light((float) 100, (float) 100, (float) -50, (float) 1.0));
+ scene.addLight(new Light((float) -100, (float) 100, (float) -50, (float) 1.0));
+ scene.addLight(new Light((float) 100, (float) -100, (float) -50, (float) 1.0));
+ scene.addLight(new Light((float) -100, (float) -100, (float) -50, (float) 1.0));
+ scene.addLight(new Light((float) 200, (float) 200, (float) 0, (float) 1.0));
+
+ /* Creates a View (viewing point) for the rendering scene */
+ View v = new View(new Vec(x, 20, -30), new Vec(x, y, 0), new Vec(0, 1,
+ 0),(float) 1.0, (float)(35.0 * 3.14159265 / 180.0), (float)1.0);
+ /*
+ * v.from = new Vec(x, y, -30); v.at = new Vec(x, y, -15); v.up = new
+ * Vec(0, 1, 0); v.angle = 35.0 * 3.14159265 / 180.0; v.aspect = 1.0;
+ * v.dist = 1.0;
+ */
+ scene.setView(v);
+
+ return scene;
+ }
+
+ public void setScene(Scene scene) {
+ // Get the objects count
+ int nLights = scene.getLights();
+ int nObjects = scene.getObjects();
+
+ lights = new Light[nLights];
+ prim = new Primitive[nObjects];
+
+ // Get the lights
+ for (int l = 0; l < nLights; l++) {
+ lights[l] = scene.getLight(l);
+ }
+
+ // Get the primitives
+ for (int o = 0; o < nObjects; o++) {
+ prim[o] = scene.getObject(o);
+ }
+
+ // Set the view
+ view = scene.getView();
+ }
+
+ public void render(Interval interval) {
+
+ // Screen variables
+ int pixCounter = 0; // iterator
+
+ Vec viewVec;
+ viewVec = Vec.sub(view.at, view.from);
+ viewVec.normalize();
+ Vec tmpVec = new Vec(viewVec);
+ tmpVec.scale(Vec.dot(view.up, viewVec));
+ Vec upVec = Vec.sub(view.up, tmpVec);
+ upVec.normalize();
+ Vec leftVec = Vec.cross(view.up, viewVec);
+ leftVec.normalize();
+ float frustrumwidth = (float) (view.dist * Math.tan(view.angle));
+ upVec.scale(-frustrumwidth);
+ leftVec.scale((float) (view.aspect * frustrumwidth));
+
+ // For each line
+ for (int y = interval.yfrom; y < interval.yto; y++) {
+
+ float ylen = (float) (2.0 * y) / (float) interval.width -(float) 1.0;
+
+ // For each pixel of the line
+ int row[]=new int[interval.width];
+ int line_checksum=0;
+ Ray tRay = new Ray();
+ Ray r = new Ray(view.from, new Vec(0,0,0));
+
+ for (int x = 0; x < interval.width; x++) {
+ Vec col = new Vec();
+
+ float xlen = (float) (2.0 * x) / (float) interval.width - (float) 1.0;
+
+ r.D = Vec.comb(xlen, leftVec, ylen, upVec);
+ r.D.add(viewVec);
+ r.D.normalize();
+
+ col = trace( 0, (float) 1.0, r,new Isect(),new Ray(),new Vec());
+
+ // computes the color of the ray
+
+ int red = (int) (col.x * 255.0);
+ if (red > 255)
+ red = 255;
+ int green = (int) (col.y * 255.0);
+ if (green > 255)
+ green = 255;
+ int blue = (int) (col.z * 255.0);
+ if (blue > 255)
+ blue = 255;
+
+ checksum += red;
+ checksum += green;
+ checksum += blue;
+
+ // Sets the pixels
+ row[x]= alpha | (red << 16) | (green << 8) | (blue);
+ } // end for (x)
+
+ image[y]=row;
+ } // end for (y)
+
+
+ }
+
+ boolean intersect(Ray r, float maxt, Isect inter) {
+ Isect tp;
+ int i, nhits;
+
+ nhits = 0;
+ inter.t = (float) 1e9;
+ for (i = 0; i < prim.length; i++) {
+ // uses global temporary Prim (tp) as temp.object for speedup
+ tp = prim[i].intersect(r);
+ if (tp != null && tp.t < inter.t) {
+ inter.t = tp.t;
+ inter.prim = tp.prim;
+ inter.surf = tp.surf;
+ inter.enter = tp.enter;
+ nhits++;
+ }
+ }
+ return nhits > 0 ? true : false;
+ }
+
+ /**
+ * Checks if there is a shadow
+ *
+ * @param r
+ * The ray
+ * @return Returns 1 if there is a shadow, 0 if there isn't
+ */
+ int Shadow(Ray r, float tmax, Isect inter) {
+ if (intersect(r, tmax, inter))
+ return 0;
+ return 1;
+ }
+
+ /**
+ * Return the Vector's reflection direction
+ *
+ * @return The specular direction
+ */
+ Vec SpecularDirection(Vec I, Vec N) {
+ Vec r;
+ r = Vec.comb((float) (1.0 / Math.abs(Vec.dot(I, N))), I, (float) 2.0, N);
+ r.normalize();
+ return r;
+ }
+
+ /**
+ * Return the Vector's transmission direction
+ */
+ Vec TransDir(Surface m1, Surface m2, Vec I, Vec N) {
+ float n1, n2, eta, c1, cs2;
+ Vec r;
+ n1 = m1 == null ? (float) 1.0 : m1.ior;
+ n2 = m2 == null ? (float) 1.0 : m2.ior;
+ eta = n1 / n2;
+ c1 = -Vec.dot(I, N);
+ cs2 =(float) ( 1.0 - eta * eta * (1.0 - c1 * c1));
+ if (cs2 < 0.0)
+ return null;
+ r = Vec.comb((float) eta, I,(float) ( eta * c1 - Math.sqrt(cs2)), N);
+ r.normalize();
+ return r;
+ }
+
+ /**
+ * Returns the shaded color
+ *
+ * @return The color in Vec form (rgb)
+ */
+ Vec shade(int level, float weight, Vec P, Vec N, Vec I, Isect hit,
+ Ray tRay, Vec L) {
+ float n1, n2, eta, c1, cs2;
+ Vec r;
+ Vec tcol;
+ Vec R;
+ float t, diff, spec;
+ Surface surf;
+ Vec col;
+ int l;
+
+ col = new Vec();
+ surf = hit.surf;
+ R = new Vec();
+ if (surf.shine > 1e-6) {
+ R = SpecularDirection(I, N);
+ }
+
+ // Computes the effectof each light
+ for (l = 0; l < lights.length; l++) {
+ // L.sub2(lights[l].pos, P);
+
+ L.x = lights[l].pos.x - P.x;
+ L.y = lights[l].pos.y - P.y;
+ L.z = lights[l].pos.z - P.z;
+
+ if (Vec.dot(N, L) >= 0.0) {
+ t = L.normalize();
+
+ tRay.P = P;
+ tRay.D = L;
+
+ // Checks if there is a shadow
+ if (Shadow(tRay, t, hit) > 0) {
+ diff = Vec.dot(N, L) * surf.kd * lights[l].brightness;
+
+ col.adds(diff, surf.color);
+ if (surf.shine > 1e-6) {
+ spec = Vec.dot(R, L);
+ if (spec > 1e-6) {
+ spec = (float) (Math.pow(spec, surf.shine));
+ col.x += spec;
+ col.y += spec;
+ col.z += spec;
+ }
+ }
+ }
+ } // if
+ } // for
+
+ tRay.P = P;
+ if (surf.ks * weight > 1e-3) {
+ tRay.D = SpecularDirection(I, N);
+ tcol = trace(level + 1, surf.ks * weight, tRay, hit, tRay, L);
+ col.adds(surf.ks, tcol);
+ }
+ if (surf.kt * weight > 1e-3) {
+ if (hit.enter > 0)
+ tRay.D = TransDir(null, surf, I, N);
+ else
+ tRay.D = TransDir(surf, null, I, N);
+ tcol = trace(level + 1, surf.kt * weight, tRay, hit, tRay, L);
+ col.adds(surf.kt, tcol);
+ }
+
+ // garbaging...
+ tcol = null;
+ surf = null;
+
+ return col;
+ }
+
+ /**
+ * Launches a ray
+ */
+ Vec trace(int level, float weight, Ray r, Isect inter, Ray tRay, Vec L) {
+
+ Vec P, N;
+ boolean hit;
+
+ // Checks the recursion level
+ if (level > 6) {
+ return new Vec();
+ }
+ hit = intersect(r, (float) 1e6, inter);
+ if (hit) {
+ P = r.point(inter.t);
+ N = inter.prim.normal(P);
+ if (Vec.dot(r.D, N) >= 0.0) {
+ N.negate();
+ }
+ return shade(level, weight, P, N, r.D, inter, tRay, L);
+ }
+
+ // no intersection --> col = 0,0,0
+ return new Vec(0, 0, 0);
+ }
+
+}
--- /dev/null
+task t1(StartupObject s{initialstate}) {
+ //System.printString("task t1\n");
+
+ int threadnum = 62;
+ int size = threadnum * 20;
+ Composer comp = new Composer(threadnum, size){compose};
+ for(int i = 0; i < threadnum; ++i) {
+ TestRunner tr = new TestRunner(i, threadnum, size){run};
+ }
+
+ taskexit(s{!initialstate});
+}
+
+task t2(TestRunner tr{run}) {
+ //System.printString("task t2\n");
+ tr.run();
+ taskexit(tr{!run, compose});
+}
+
+task t3(Composer comp{compose}, TestRunner tr{compose}) {
+ //System.printString("task t3\n");
+ if(comp.compose(tr)) {
+ taskexit(comp{!compose}, tr{!compose});
+ } else {
+ taskexit(tr{!compose});
+ }
+}
--- /dev/null
+/**************************************************************************
+ * *
+ * Java Grande Forum Benchmark Suite - Version 2.0 *
+ * *
+ * produced by *
+ * *
+ * Java Grande Benchmarking Project *
+ * *
+ * at *
+ * *
+ * Edinburgh Parallel Computing Centre *
+ * *
+ * email: epcc-javagrande@epcc.ed.ac.uk *
+ * *
+ * Original version of this code by *
+ * Florian Doyon (Florian.Doyon@sophia.inria.fr) *
+ * and Wilfried Klauser (wklauser@acm.org) *
+ * *
+ * This version copyright (c) The University of Edinburgh, 1999. *
+ * All rights reserved. *
+ * *
+ **************************************************************************/
+
+
+
+import java.util.Vector;
+
+public class Scene
+//implements java.io.Serializable
+{
+ public final Vector lights;
+ public final Vector objects;
+ private View view;
+
+ public Scene ()
+ {
+ this.lights = new Vector ();
+ this.objects = new Vector ();
+ }
+
+ public void addLight(Light l)
+ {
+ this.lights.addElement(l);
+ }
+
+ public void addObject(Primitive object)
+ {
+ this.objects.addElement(object);
+ }
+
+ public void setView(View view)
+ {
+ this.view = view;
+ }
+
+ public View getView()
+ {
+ return this.view;
+ }
+
+ public Light getLight(int number)
+ {
+ return (Light) this.lights.elementAt(number);
+ }
+
+ public Primitive getObject(int number)
+ {
+ return (Primitive) objects.elementAt(number);
+ }
+
+ public int getLights()
+ {
+ return this.lights.size();
+ }
+
+ public int getObjects()
+ {
+ return this.objects.size();
+ }
+
+ public void setObject(Primitive object, int pos)
+ {
+ this.objects.setElementAt(object, pos);
+ }
+}
+
+
+
+
--- /dev/null
+/**************************************************************************
+ * *
+ * Java Grande Forum Benchmark Suite - Version 2.0 *
+ * *
+ * produced by *
+ * *
+ * Java Grande Benchmarking Project *
+ * *
+ * at *
+ * *
+ * Edinburgh Parallel Computing Centre *
+ * *
+ * email: epcc-javagrande@epcc.ed.ac.uk *
+ * *
+ * Original version of this code by *
+ * Florian Doyon (Florian.Doyon@sophia.inria.fr) *
+ * and Wilfried Klauser (wklauser@acm.org) *
+ * *
+ * This version copyright (c) The University of Edinburgh, 1999. *
+ * All rights reserved. *
+ * *
+ **************************************************************************/
+
+
+
+public class Sphere extends Primitive
+//implements java.io.Serializable
+{
+ Vec c;
+ float r, r2;
+//Vec v,b; // temporary vecs used to minimize the memory load
+
+
+ public Sphere(Vec center, float radius) {
+ super();
+ c = center;
+ r = radius;
+ r2 = r*r;
+// v=new Vec();
+// b=new Vec();
+ }
+
+ public float dot(float x1, float y1, float z1, float x2, float y2, float z2){
+
+ return x1*x2 + y1*y2 + z1*z2;
+
+ }
+
+ public Isect intersect(Ray ry) {
+
+
+ float b, disc, t;
+ Isect ip;
+
+ float x=c.x-ry.P.x;
+ float y=c.y-ry.P.y;
+ float z=c.z-ry.P.z;
+
+ b=dot( x, y, z, ry.D.x, ry.D.y, ry.D.z);
+ disc = (float) (b*b -dot(x,y,z,x,y,z) + r2);
+ if (disc < 0.0) {
+ return null;
+ }
+ disc = (float) Math.sqrt(disc);
+ t = (b - disc < 1e-6) ? b + disc : b - disc;
+ if (t < 1e-6) {
+ return null;
+ }
+ ip = new Isect();
+ ip.t = t;
+ ip.enter = dot(x,y,z,x,y,z) > r2 + 1e-6 ? 1 : 0;
+// ip.enter = Vec.dot(v, v) > r2 + 1e-6 ? 1 : 0;
+ ip.prim = this;
+ ip.surf = surf;
+ return ip;
+
+ }
+
+ public Vec normal(Vec p) {
+ Vec r;
+ r = Vec.sub(p, c);
+ r.normalize();
+ return r;
+ }
+
+ public String toString() {
+ return "Sphere {" + c.toString() + "," + r + "}";
+ }
+
+ public Vec getCenter() {
+ return c;
+ }
+ public void setCenter(Vec c) {
+ this.c = c;
+ }
+}
+
--- /dev/null
+/**************************************************************************
+ * *
+ * Java Grande Forum Benchmark Suite - Version 2.0 *
+ * *
+ * produced by *
+ * *
+ * Java Grande Benchmarking Project *
+ * *
+ * at *
+ * *
+ * Edinburgh Parallel Computing Centre *
+ * *
+ * email: epcc-javagrande@epcc.ed.ac.uk *
+ * *
+ * Original version of this code by *
+ * Florian Doyon (Florian.Doyon@sophia.inria.fr) *
+ * and Wilfried Klauser (wklauser@acm.org) *
+ * *
+ * This version copyright (c) The University of Edinburgh, 1999. *
+ * All rights reserved. *
+ * *
+ **************************************************************************/
+
+
+
+public class Surface
+//implements java.io.Serializable
+{
+ public Vec color;
+ public float kd;
+ public float ks;
+ public float shine;
+ public float kt;
+ public float ior;
+ public boolean isnull;
+
+ public Surface() {
+ color = new Vec(1, 0, 0);
+ kd =(float) 1.0;
+ ks = (float) 0.0;
+ shine = (float) 0.0;
+ kt = (float) 0.0;
+ ior = (float) 1.0;
+ isnull=false;
+ }
+
+ public String toString() {
+ return "Surface { color=" + color + "}";
+ }
+}
+
+
--- /dev/null
+/**************************************************************************
+ * * Java Grande Forum Benchmark Suite - Version 2.0 * * produced by * * Java
+ * Grande Benchmarking Project * * at * * Edinburgh Parallel Computing Centre *
+ * * email: epcc-javagrande@epcc.ed.ac.uk * * * This version copyright (c) The
+ * University of Edinburgh, 1999. * All rights reserved. * *
+ **************************************************************************/
+
+public class TestRunner extends RayTracer {
+
+ flag run;
+ flag compose;
+
+ int numCore;
+ public int id;
+
+ public TestRunner(int id,
+ int numCore,
+ int size) {
+ super();
+ this.id = id;
+ this.numCore = numCore;
+ this.size = size;
+
+ // set image size
+ width=size;
+ height=size;
+ this.image=new int[size][];
+
+ // create the objects to be rendered
+ scene = createScene();
+
+ // get lights, objects etc. from scene.
+ setScene(scene);
+
+ numobjects = scene.getObjects();
+ }
+
+ public void JGFvalidate() {
+ // long refval[] = {2676692,29827635};
+// long refval[] = new long[2];
+// refval[0] = 2676692;
+// refval[1] = 29827635;
+// long dev = checksum - refval[size];
+// if (dev != 0) {
+// System.out.println("Validation failed");
+// System.out.println("Pixel checksum = " + checksum);
+// System.out.println("Reference value = " + refval[size]);
+// }
+ }
+
+ public void JGFtidyup() {
+// scene = null;
+// lights = null;
+// prim = null;
+// tRay = null;
+// inter = null;
+ // System.gc();
+ }
+
+ public void run() {
+
+ int heightPerCore=height/numCore;
+ int startidx=heightPerCore * this.id;
+ int endidx=startidx + heightPerCore;
+ Interval interval = new Interval(0, width, height, startidx, endidx, 1);
+ render(interval);
+
+ //System.out.println("CHECKSUM="+checksum);
+
+ }
+
+
+}
--- /dev/null
+/**************************************************************************
+ * *
+ * Java Grande Forum Benchmark Suite - Version 2.0 *
+ * *
+ * produced by *
+ * *
+ * Java Grande Benchmarking Project *
+ * *
+ * at *
+ * *
+ * Edinburgh Parallel Computing Centre *
+ * *
+ * email: epcc-javagrande@epcc.ed.ac.uk *
+ * *
+ * Original version of this code by *
+ * Florian Doyon (Florian.Doyon@sophia.inria.fr) *
+ * and Wilfried Klauser (wklauser@acm.org) *
+ * *
+ * This version copyright (c) The University of Edinburgh, 1999. *
+ * All rights reserved. *
+ * *
+ **************************************************************************/
+
+
+
+
+/**
+ * This class reflects the 3d vectors used in 3d computations
+ */
+public class Vec
+//implements java.io.Serializable
+{
+
+ /**
+ * The x coordinate
+ */
+ public float x;
+
+ /**
+ * The y coordinate
+ */
+ public float y;
+
+ /**
+ * The z coordinate
+ */
+ public float z;
+
+ /**
+ * Constructor
+ * @param a the x coordinate
+ * @param b the y coordinate
+ * @param c the z coordinate
+ */
+ public Vec(float a, float b, float c) {
+ x = a;
+ y = b;
+ z = c;
+ }
+
+ /**
+ * Copy constructor
+ */
+ public Vec(Vec a) {
+ x = a.x;
+ y = a.y;
+ z = a.z;
+ }
+ /**
+ * Default (0,0,0) constructor
+ */
+ public Vec() {
+ x = (float) 0.0;
+ y = (float) 0.0;
+ z = (float) 0.0;
+ }
+
+ /**
+ * Add a vector to the current vector
+ * @param: a The vector to be added
+ */
+ public final void add(Vec a) {
+ x+=a.x;
+ y+=a.y;
+ z+=a.z;
+ }
+
+ /**
+ * adds: Returns a new vector such as
+ * new = sA + B
+ */
+ public static Vec adds(float s, Vec a, Vec b) {
+ return new Vec(s * a.x + b.x, s * a.y + b.y, s * a.z + b.z);
+ }
+
+ /**
+ * Adds vector such as:
+ * this+=sB
+ * @param: s The multiplier
+ * @param: b The vector to be added
+ */
+ public final void adds(float s,Vec b){
+ x+=s*b.x;
+ y+=s*b.y;
+ z+=s*b.z;
+ }
+
+ /**
+ * Substracs two vectors
+ */
+ public static Vec sub(Vec a, Vec b) {
+ return new Vec(a.x - b.x, a.y - b.y, a.z - b.z);
+ }
+
+ /**
+ * Substracts two vects and places the results in the current vector
+ * Used for speedup with local variables -there were too much Vec to be gc'ed
+ * Consumes about 10 units, whether sub consumes nearly 999 units!!
+ * cf thinking in java p. 831,832
+ */
+ public final void sub2(Vec a,Vec b) {
+ this.x=a.x-b.x;
+ this.y=a.y-b.y;
+ this.z=a.z-b.z;
+ }
+
+ public static Vec mult(Vec a, Vec b) {
+ return new Vec(a.x * b.x, a.y * b.y, a.z * b.z);
+ }
+
+ public static Vec cross(Vec a, Vec b) {
+ return
+ new Vec(a.y*b.z - a.z*b.y,
+ a.z*b.x - a.x*b.z,
+ a.x*b.y - a.y*b.x);
+ }
+
+ public static float dot(Vec a, Vec b) {
+ return a.x*b.x + a.y*b.y + a.z*b.z;
+ }
+
+ public static Vec comb(float a, Vec A, float b, Vec B) {
+ return
+ new Vec(a * A.x + b * B.x,
+ a * A.y + b * B.y,
+ a * A.z + b * B.z);
+ }
+
+ public final void comb2(float a,Vec A,float b,Vec B) {
+ x=a * A.x + b * B.x;
+ y=a * A.y + b * B.y;
+ z=a * A.z + b * B.z;
+ }
+
+ public final void scale(float t) {
+ x *= t;
+ y *= t;
+ z *= t;
+ }
+
+ public final void negate() {
+ x = -x;
+ y = -y;
+ z = -z;
+ }
+
+ public final float normalize() {
+ float len;
+ len =(float) Math.sqrt(x*x + y*y + z*z);
+ if (len > 0.0) {
+ x /= len;
+ y /= len;
+ z /= len;
+ }
+ return len;
+ }
+
+ public final String toString() {
+ return "<" + x + "," + y + "," + z + ">";
+ }
+}
--- /dev/null
+/**************************************************************************
+ * *
+ * Java Grande Forum Benchmark Suite - Version 2.0 *
+ * *
+ * produced by *
+ * *
+ * Java Grande Benchmarking Project *
+ * *
+ * at *
+ * *
+ * Edinburgh Parallel Computing Centre *
+ * *
+ * email: epcc-javagrande@epcc.ed.ac.uk *
+ * *
+ * Original version of this code by *
+ * Florian Doyon (Florian.Doyon@sophia.inria.fr) *
+ * and Wilfried Klauser (wklauser@acm.org) *
+ * *
+ * This version copyright (c) The University of Edinburgh, 1999. *
+ * All rights reserved. *
+ * *
+ **************************************************************************/
+
+
+
+public class View
+//implements java.io.Serializable
+{
+ /* public Vec from;
+ public Vec at;
+ public Vec up;
+ public float dist;
+ public float angle;
+ public float aspect;*/
+ public final Vec from;
+ public final Vec at;
+ public final Vec up;
+ public final float dist;
+ public final float angle;
+ public final float aspect;
+
+ public View (Vec from, Vec at, Vec up, float dist, float angle, float aspect)
+ {
+ this.from = from;
+ this.at = at;
+ this.up = up;
+ this.dist = dist;
+ this.angle = angle;
+ this.aspect = aspect;
+ }
+}
+
+
+
--- /dev/null
+#raytracer
+PROGRAM=test
+
+SOURCE_FILES=test.java
+
+BUILDSCRIPT=~/eclipse/workspaces/irvine_sep09/Robust/src/buildscript
+
+USEMLP= -mlp 8 2 # -mlpdebug # use to turn mlp on and off and make sure rest of build not broken
+BSFLAGS= -32bit -nooptimize -mainclass test -debug -garbagestats
+OWNERSHIP= -ownership -ownallocdepth 1 -enable-assertions -methodeffects -flatirusermethods -ownwritedots final -ownaliasfile aliases.txt
+
+default:
+ ../../../buildscript -nojava $(USEMLP) $(BSFLAGS) $(OWNERSHIP) -o $(PROGRAM) $(SOURCE_FILES)
+
+single:
+ ../../../buildscript $(BSFLAGS) -o $(PROGRAM) $(SOURCE_FILES)
+
+java:
+ ../../../buildscript $(USEMLP) $(BSFLAGS) $(OWNERSHIP) -o $(PROGRAM) $(SOURCE_FILES)
+
+clean:
+ rm -f $(PROGRAM).bin
+ rm -fr tmpbuilddirectory
+ rm -f *~
+ rm -f *.dot
+ rm -f *.png
+ rm -f *.txt
+ rm -f aliases.txt
+ rm -f mlpReport*txt
+ rm -f results*txt