From b8317ed3f57fe2692361d6da7d5adebc223e70fa Mon Sep 17 00:00:00 2001 From: adash Date: Tue, 5 Jan 2010 23:18:30 +0000 Subject: [PATCH] new rectaguler convolution for manual prefetch --- .../2DConv/ConvolutionRect.java | 1033 +++++++++++++++++ .../Prefetch/ManualPrefetch/2DConv/Makefile | 8 +- 2 files changed, 1039 insertions(+), 2 deletions(-) create mode 100644 Robust/src/Benchmarks/Prefetch/ManualPrefetch/2DConv/ConvolutionRect.java diff --git a/Robust/src/Benchmarks/Prefetch/ManualPrefetch/2DConv/ConvolutionRect.java b/Robust/src/Benchmarks/Prefetch/ManualPrefetch/2DConv/ConvolutionRect.java new file mode 100644 index 00000000..28f998bd --- /dev/null +++ b/Robust/src/Benchmarks/Prefetch/ManualPrefetch/2DConv/ConvolutionRect.java @@ -0,0 +1,1033 @@ +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() { + int kernelHeight=14; + int kernelWidth=kernelHeight; + + float[][] kernel = new float[kernelHeight][kernelWidth]; + initKernel14(kernel); + //initKernel15(kernel); + //initKernel13(kernel); + //initKernel12(kernel); + int myx0, myy0, myx1, myy1; + atomic { + myx0 = x0; + myy0 = y0; + myx1 = x1; + myy1 = y1; + } + + //Add manual prefetch this.img.inputImage[] the first 32 objects + 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) myx0; + offsets[5] = (short) 31; + System.rangePrefetch(this, offsets); + + //Prefetch this.img.outputImage[] the first 32 objects + offsets[2] = getoffset{Image, outputImage}; + offsets[3] = (short) 0; + System.rangePrefetch(this, offsets); + + atomic { + float tempinput[][] = img.inputImage; + float tempout[][] = img.outputImage; + + float tinput1[] = tempinput[myx0+0]; + float tinput2[] = tempinput[myx0+1]; + float tinput3[] = tempinput[myx0+2]; + float tinput4[] = tempinput[myx0+3]; + float tinput5[] = tempinput[myx0+4]; + float tinput6[] = tempinput[myx0+5]; + float tinput7[] = tempinput[myx0+6]; + float tinput8[] = tempinput[myx0+7]; + float tinput9[] = tempinput[myx0+8]; + float tinput10[] = tempinput[myx0+9]; + float tinput11[] = tempinput[myx0+10]; + float tinput12[] = tempinput[myx0+11]; + float tinput13[] = tempinput[myx0+12]; + float tinput14[] = tempinput[myx0+13]; + float tinput0[] = tinput1; + short[] offsets2 = new short[2]; + + int l; + if(kernelHeight==15){ + l=14; + for(int i=myx0;i0) { + NUM_THREADS = Integer.parseInt(args[0]); + if(args.length>1) { + WIDTH = Integer.parseInt(args[1]); + if(args.length>2) + HEIGHT = Integer.parseInt(args[2]); + } + } + + int[] mid = new int[8]; + mid[0] = (128<<24)|(195<<16)|(136<<8)|162; //dc-1 + mid[1] = (128<<24)|(195<<16)|(136<<8)|163; //dc-2 + mid[2] = (128<<24)|(195<<16)|(136<<8)|164; //dc-3 + mid[3] = (128<<24)|(195<<16)|(136<<8)|165; //dc-4 + mid[4] = (128<<24)|(195<<16)|(136<<8)|166; //dc-5 + mid[5] = (128<<24)|(195<<16)|(136<<8)|167; //dc-6 + mid[6] = (128<<24)|(195<<16)|(136<<8)|168; //dc-7 + mid[7] = (128<<24)|(195<<16)|(136<<8)|169; //dc-8 + + Image img; + Convolution[] conv; + Convolution tmp; + + atomic { + img = global new Image(HEIGHT,WIDTH,kernelHeight,kernelWidth); + img.setValues(); + conv = global new Convolution[NUM_THREADS]; + int increment=HEIGHT/NUM_THREADS; + int base = 0; + for(int i = 0; i