From: jzhou Date: Fri, 13 Feb 2009 21:34:59 +0000 (+0000) Subject: add new benchmark Fractal for Bamboo X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=0f1eb151fc8dc5ef3b776b21fb32e022e15e33a2;p=IRC.git add new benchmark Fractal for Bamboo --- diff --git a/Robust/src/Benchmarks/Scheduling/Fractal/Fractal.java b/Robust/src/Benchmarks/Scheduling/Fractal/Fractal.java new file mode 100644 index 00000000..3668146a --- /dev/null +++ b/Robust/src/Benchmarks/Scheduling/Fractal/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 = 160; + int height = 160; + int group = 16; + + 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/Scheduling/Fractal/c/Fractal.c b/Robust/src/Benchmarks/Scheduling/Fractal/c/Fractal.c new file mode 100644 index 00000000..07cf888e --- /dev/null +++ b/Robust/src/Benchmarks/Scheduling/Fractal/c/Fractal.c @@ -0,0 +1,103 @@ +/* Draw a Mandelbrot set, maximum magnification 10000000 times; + */ +#include +#ifdef RAW +#include +#else +#include +#include +#include +#endif + +const int AppletWidth = 160; +const int AppletHeight = 160; +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; + + while ((option = getopt(argc, argv, "i:")) != -1) { + switch(option) { + case 'i': + numiters = atoi(optarg); + } + } + + 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 = (1<<32) - 1; + 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/Scheduling/Fractal/c/Makefile b/Robust/src/Benchmarks/Scheduling/Fractal/c/Makefile new file mode 100644 index 00000000..f8b9f8e2 --- /dev/null +++ b/Robust/src/Benchmarks/Scheduling/Fractal/c/Makefile @@ -0,0 +1,19 @@ +TOPDIR=/home/jzhou/starsearch +include $(TOPDIR)/Makefile.include + +RGCCFLAGS += -O2 +RGCCFLAGS += -DRAW + +USE_SLGCC=1 + +SIM-CYCLES = 10000 + +ATTRIBUTES += HWIC + +TILES = 00 + +OBJECT_FILES_00 = Fractal.o + +# this is for a multi-tile test +include $(COMMONDIR)/Makefile.all +#include $(COMMONDIR)/Makefile.single