From 9c94e410d274e76c4289062409738cec525c5df1 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Sat, 14 Feb 2009 00:30:54 +0000 Subject: [PATCH] Performance benchmark for Bristlecone --- .../src/Benchmarks/Performance/Dispatch.java | 21 ++ Robust/src/Benchmarks/Performance/Fractal.c | 96 ++++++++++ .../src/Benchmarks/Performance/Fractal.java | 180 ++++++++++++++++++ Robust/src/Benchmarks/Performance/makefile | 11 ++ 4 files changed, 308 insertions(+) create mode 100644 Robust/src/Benchmarks/Performance/Dispatch.java create mode 100644 Robust/src/Benchmarks/Performance/Fractal.c create mode 100644 Robust/src/Benchmarks/Performance/Fractal.java create mode 100644 Robust/src/Benchmarks/Performance/makefile diff --git a/Robust/src/Benchmarks/Performance/Dispatch.java b/Robust/src/Benchmarks/Performance/Dispatch.java new file mode 100644 index 00000000..b3fe20fc --- /dev/null +++ b/Robust/src/Benchmarks/Performance/Dispatch.java @@ -0,0 +1,21 @@ +task start(StartupObject s {initialstate}) { + Foo f=new Foo(){run}; + + taskexit(s{!initialstate}); +} + +task DoOperation(Foo f{run}) { + if (f.count==1000000) + taskexit(f{!run}); + else { + f.count++; + taskexit(f{run}); + } +} + +public class Foo { + flag run; + int count; + public Foo() { + } +} \ No newline at end of file diff --git a/Robust/src/Benchmarks/Performance/Fractal.c b/Robust/src/Benchmarks/Performance/Fractal.c new file mode 100644 index 00000000..95e87213 --- /dev/null +++ b/Robust/src/Benchmarks/Performance/Fractal.c @@ -0,0 +1,96 @@ +/* Draw a Mandelbrot set, maximum magnification 10000000 times; + */ +#include +#ifdef RAW +#include +#else +#include +#include +#include +#endif + +const int AppletWidth = 3200; +const int AppletHeight = 3200; +int length; +const float amin = (float)-2.0; +const float amax = (float)1.0; +const float bmin = (float)-1.5; +const float bmax = (float)1.5; +const float alen = (float)3.0; +const float blen = (float)3.0; +const int times = 255; +int alpha = 0xff; +int red = 0xff; +int green = 0xff; +int blue = 0xff; +int* pixels; + +void begin(void); +void run(void); + +#ifndef RAW +int main(int argc, char **argv) { + int option; + + begin(); + return 0; +} +#endif + +void begin(void){ + length = AppletWidth * AppletHeight; + pixels = (int*)malloc(sizeof(int) * length);; + int incr=0; + while (incr < length) { + pixels[incr++] = alpha<<24 | 0x00<<16 | 0x00<<8 | 0xff; + } + int maxint = RAND_MAX; + red = (int)(((float)rand()/maxint)*255); + green = (int)(((float)rand()/maxint)*255); + blue = (int)(((float)rand()/maxint)*255); + run(); + + free(pixels); + +#ifdef RAW + raw_test_pass(raw_get_cycle()); + raw_test_done(1); +#endif +} + +void run () { + float a,b,x,y; //a--width, b--height + int scaleda,scaledb; + float adelta = (float)(alen/AppletWidth); + float bdelta = (float)(blen/AppletHeight); + for(a=amin;a0) { + scaleda=(int)((a - amin)*AppletWidth/(amax - amin)); + scaledb=(int)((b - bmin)*AppletHeight/(bmax - bmin)); + int index = scaledb * AppletWidth + scaleda; + pixels[index] = alpha<<24 | red<<16 | iteration<<8 | blue; + } + } + } + + // output image +} diff --git a/Robust/src/Benchmarks/Performance/Fractal.java b/Robust/src/Benchmarks/Performance/Fractal.java new file mode 100644 index 00000000..f885354b --- /dev/null +++ b/Robust/src/Benchmarks/Performance/Fractal.java @@ -0,0 +1,180 @@ +/* Draw a Mandelbrot set, maximum magnification 10000000 times; + */ +task t1(StartupObject s{initialstate}) { + //System.printString("task t1\n"); + + int width = 3200; + int height = 3200; + int group = 640; + + int h = height / group; + for(int i = 0; i < group; i++) { + Fractal fratal = new Fractal(i, + group, + width, + height){run}; + } + Image image = new Image(group){!finish}; + + taskexit(s{!initialstate}); +} + +task t2(Fractal fractal{run}) { + //System.printString("task t2\n"); + + // Now do the computation. + fractal.run(); + + taskexit(fractal{!run, output}); +} + +//task t3(Image image{!finish}, Fractal fractal{output}) { + //System.printString("task t3\n"); + +// if(image.outputImage(fractal.pixels, fractal.id)) { + //System.printString("Finish!\n"); +// taskexit(image{finish}, fractal{!output}); +// } else { +// taskexit(fractal{!output}); +// } +//} + +public class Fractal { + flag run; + flag output; + + public int id; + public int group; + public int AppletWidth; + private int AppletHeight; + private float amin; + private float amax; + private float bmin; + private float bmax; + private float alen, blen; + public int[] pixels; + int alpha; + int red; + int green; + int blue; + int times; + + public Fractal(int index, + int group, + int width, + int height) { + this.id = index; + this.group = group; + this.AppletWidth = width; + this.AppletHeight = height; + this.amin = (float)-2.0; + this.amax = (float)1.0; + this.bmin = (float)-1.5; + this.bmax = (float)1.5; + this.alen = (float)3.0;//this.amax - this.amin; + this.blen = (float)3.0;//this.bmax - this.bmin; + this.alpha = 0xff; + this.red = 0xff; + this.green = 0xff; + this.blue = 0xff; + this.times = 255; + int length = this.AppletWidth * this.AppletHeight / this.group; + this.pixels = new int[length]; + int[] ps = this.pixels; + int incr=0; + while (incr < length) { + ps[incr++] = this.alpha<<24 | 0x00<<16 | 0x00<<8 | 0xff; + } + Random rnd = new Random(); + int maxint = (1<<32) - 1; + red = (int)(((float)rnd.nextInt()/maxint)*255); + green = (int)(((float)rnd.nextInt()/maxint)*255); + blue = (int)(((float)rnd.nextInt()/maxint)*255); + } + + public void run () { + float amin = this.amin; + float amax = this.amax; + float bmin = this.bmin; + float bmax = this.bmax; + int appletWidth = this.AppletWidth; + int appletHeight = this.AppletHeight; + int times = this.times; + int alpha = this.alpha; + int red = this.red; + int blue = this.blue; + float a,b,x,y; //a--width, b--height + int scaleda,scaledb; + float adelta = (this.alen/appletWidth); + float bdelta = (this.blen/appletHeight); + int[] ps = this.pixels; + int length = ps.length; + int id = this.id; + int group = this.group; + float startb = bmin + bdelta * id; + float endb = bmax - bdelta * (group - id); + float bspan = bdelta * group; + for(a=amin;a0) { + scaleda=(int)((a - amin)*appletWidth/(amax - amin)); + scaledb=(int)((b - bmin)*appletHeight/(bmax - bmin)); + int index = (scaledb * appletWidth + scaleda - id) / group; + if(index < length) { + ps[index] = alpha<<24 | red<<16 | iteration<<8 | blue; + } + } + } + } + } +} + +public class Image { + flag finish; + + private int group; + private int counter; + private int[][] pixels; + private String outputfile; + + public Image(int g) { + this.group = g; + this.counter = 0; + this.pixels = new int[g][]; + this.outputfile = new String("/scratch/fractal/image.dat"); + } + + public boolean outputImage(int[] pixels, int index) { + this.counter++; + + this.pixels[index] = pixels; + + boolean isFinish = (this.group == this.counter); + if(isFinish) { + // output the image + /*FileOutputStream oStream = new FileOutputStream(outputfile, true); + //System.printString(new String(ps, 0, ps.length) + "\n"); + oStream.write(ps, 0, ps.length); + oStream.close();*/ + } + return isFinish; + } +} \ No newline at end of file diff --git a/Robust/src/Benchmarks/Performance/makefile b/Robust/src/Benchmarks/Performance/makefile new file mode 100644 index 00000000..59ab097b --- /dev/null +++ b/Robust/src/Benchmarks/Performance/makefile @@ -0,0 +1,11 @@ +FLAGS=-optimize -recover + +default: + ../../buildscript ${FLAGS} -o FractalBR Fractal.java + ../../buildscript ${FLAGS} -o Dispatch Dispatch.java + gcc -O9 Fractal.c -o FractalC + + +clean: + rm -rf tmpbuilddirectory + rm *.bin -- 2.34.1