From d90a0efd8a2efe979bde7ce7a2ddefc88c23d5cf Mon Sep 17 00:00:00 2001 From: Anthony C Date: Tue, 29 Jan 2013 07:28:51 -0500 Subject: [PATCH] GenDataMP6 is giving better numbers --- CMakeLists.txt | 2 +- GenDataMP6.cc | 43 +++++++++++++++++++++++++++++++++---------- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2fe3c60..38ac7bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ add_custom_command(OUTPUT vecA.txt vecB.txt vecC.txt COMMAND GenDataMP1 90 DEPE add_custom_command(OUTPUT matA.txt matB.txt matC.txt COMMAND GenDataMP2 90 10 39 DEPENDS GenDataMP2) add_custom_command(OUTPUT vecSumA.txt vecSumResult.txt vecSumResult.txt COMMAND GenDataMP4 1000 DEPENDS GenDataMP4) add_custom_command(OUTPUT vecCumSumA.txt vecCumSumResult.txt vecCumSumResult.txt COMMAND GenDataMP5 100 DEPENDS GenDataMP5) -add_custom_command(OUTPUT imageInput.txt convolutionMatrix.txt imageOutput.txt COMMAND GenDataMP6 10 10 3 5 5 DEPENDS GenDataMP6) +add_custom_command(OUTPUT imageInput.txt convolutionMatrix.txt imageOutput.txt COMMAND GenDataMP6 10 10 3 5 5 bl DEPENDS GenDataMP6) add_custom_target(run1 mp1 vecA.txt vecB.txt vecC.txt DEPENDS vecA.txt vecB.txt vecC.txt ) add_custom_target(run2 mp2 matA.txt matB.txt matC.txt DEPENDS matA.txt matB.txt matC.txt) diff --git a/GenDataMP6.cc b/GenDataMP6.cc index 0c5b2d2..385dc26 100644 --- a/GenDataMP6.cc +++ b/GenDataMP6.cc @@ -9,8 +9,12 @@ typedef std::vector< float > FloatVec; +bool g_generateSmallInt=false; + float genRandomFloat() { + if ( g_generateSmallInt) + return rand() %10; return ( (float) rand() / RAND_MAX ); } @@ -32,21 +36,30 @@ void genMatrix( FloatVec&mat, int rows, int cols ) float sumAt( FloatVec& in,FloatVec& mask, int xC, int yC, int cC, int xMax, int yMax, int cMax) { float sum=0; - for (int x = max(xC -2, 0); x < min(xMax,xC+2); x++) { - for (int y =max(yC -2,0); y < min(yMax,yC+2); y++) { - int index = (y*xMax +x)*cMax + cC; - sum+= in[index]*mask[y*5+x]; + int mY=0; + for (int y =yC-2; y < min(yMax,yC+3); y++) { + int mX=0; + for (int x = xC-2; x < min(xMax,xC+3); x++) { + if (y >=0 && x >=0) { + int index = (y*xMax +x)*cMax + cC; + // std::cout << "at x=" << x << " y=" << y << " c=" << cC << " adding " << sum << " to " << in[index]*mask[mY*5+mX] << " in[index]=" << in[index]<< " mask[mY*5+mX] =" < argc ) { std::cout << "Error! Wrong number of arguments to program.\n"; return 0; } + if (7 == argc) + g_generateSmallInt=true; + + // Create vectors