From 049b3154af7d47d1c2d265f20eca183d0b435089 Mon Sep 17 00:00:00 2001 From: adash Date: Mon, 9 Mar 2009 20:30:56 +0000 Subject: [PATCH] Manual prefetcing for 2DConv --- .../2DConv/ConvolutionSizeC.java | 459 ++++++++++++++++++ .../Prefetch/ManualPrefetch/2DConv/Makefile | 10 + .../Prefetch/ManualPrefetch/2DConv/README.txt | 8 + 3 files changed, 477 insertions(+) create mode 100644 Robust/src/Benchmarks/Prefetch/ManualPrefetch/2DConv/ConvolutionSizeC.java create mode 100644 Robust/src/Benchmarks/Prefetch/ManualPrefetch/2DConv/Makefile create mode 100644 Robust/src/Benchmarks/Prefetch/ManualPrefetch/2DConv/README.txt diff --git a/Robust/src/Benchmarks/Prefetch/ManualPrefetch/2DConv/ConvolutionSizeC.java b/Robust/src/Benchmarks/Prefetch/ManualPrefetch/2DConv/ConvolutionSizeC.java new file mode 100644 index 00000000..12784155 --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/ManualPrefetch/2DConv/ConvolutionSizeC.java @@ -0,0 +1,459 @@ +public class Convolution extends Thread { + Image img; + int x0,x1,y0,y1; + + public Convolution(Image img, int x0, int x1, int y0, int y1) { + this.img = img; + this.x0 = x0; + this.x1 = x1; + this.y0 = y0; + this.y1 = y1; + } + + public void run() { + + // + //Prefetch this.img.inputImage[] the first 32 objects + // Generates compiler error ??? + Object o = this; + short[] offsets = new short[6]; + offsets[0] = getoffset{Convolution, img}; + offsets[1] = (short) 0; + offsets[2] = getoffset{Image, inputImage}; + offsets[3] = (short) 0; + offsets[4] = (short) x0; + offsets[5] = (short) 32; + System.rangePrefetch(o, offsets); + + //Prefetch this.img.outputImage[] the first 32 objects + // Generates compiler error ??? + Object o1 = this; + short[] offsets1 = new short[6]; + offsets1[0] = getoffset{Convolution, img}; + offsets1[1] = (short) 0; + offsets1[2] = getoffset{Image, outputImage}; + offsets1[3] = (short) 0; + offsets1[4] = (short) x0; + offsets1[5] = (short) 32; + System.rangePrefetch(o1, offsets1); + + int kernelHeight=15; + int kernelWidth=15; + + double[][] kernel = new double[kernelHeight][kernelWidth]; + initKernel15(kernel); + + atomic { + double tempinput[][] = img.inputImage; + double tempout[][] = img.outputImage; + + double tinput1[] = tempinput[x0]; + double tinput2[] = tempinput[x0+1]; + double tinput3[] = tempinput[x0+2]; + double tinput4[] = tempinput[x0+3]; + double tinput5[] = tempinput[x0+4]; + double tinput6[] = tempinput[x0+5]; + double tinput7[] = tempinput[x0+6]; + double tinput8[] = tempinput[x0+7]; + double tinput9[] = tempinput[x0+8]; + double tinput10[] = tempinput[x0+9]; + double tinput11[] = tempinput[x0+10]; + double tinput12[] = tempinput[x0+11]; + double tinput13[] = tempinput[x0+12]; + double tinput14[] = tempinput[x0+13]; + double tinput0[] = tinput1; + + int l=x0+14; + for(int i=x0;i0) { + NUM_THREADS = Integer.parseInt(args[0]); + if(args.length>1) { + SIZE = Integer.parseInt(args[1]); + } + } + + int[] mid = new int[8]; + mid[0] = (128<<24)|(195<<16)|(136<<8)|162; //dw-10 + mid[1] = (128<<24)|(195<<16)|(136<<8)|163; //dw-11 + mid[2] = (128<<24)|(195<<16)|(136<<8)|164; //dw-12 + mid[3] = (128<<24)|(195<<16)|(136<<8)|165; //dw-13 + mid[4] = (128<<24)|(195<<16)|(136<<8)|166; //dw-14 + mid[5] = (128<<24)|(195<<16)|(136<<8)|167; //dw-15 + mid[6] = (128<<24)|(195<<16)|(136<<8)|168; //dw-16 + mid[7] = (128<<24)|(195<<16)|(136<<8)|169; //dw-17 + + Image img; + Convolution[] conv; + Convolution tmp; + + atomic { + img = global new Image(SIZE,SIZE,kernelHeight,kernelWidth); + img.setValues(); + conv = global new Convolution[NUM_THREADS]; + int increment=SIZE/NUM_THREADS; + int base = 0; + for(int i = 0; i