Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > SSR > SSR__Blocked_Matrix_Mult__Bench
changeset 7:c5d77078740c
fixed: uninitialized variable
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Thu, 12 May 2011 14:27:17 +0200 |
| parents | 78d8bd6aadac |
| children | 4e9d98d0e9d2 |
| files | src/Application/Matrix_Mult.h src/Application/SSR_Matrix_Mult/Divide_Pr.c src/Application/SSR_Matrix_Mult/SSR_Matrix_Mult.h |
| diffstat | 3 files changed, 177 insertions(+), 174 deletions(-) [+] |
line diff
1.1 --- a/src/Application/Matrix_Mult.h Sun Nov 14 11:07:52 2010 -0800 1.2 +++ b/src/Application/Matrix_Mult.h Thu May 12 14:27:17 2011 +0200 1.3 @@ -1,77 +1,77 @@ 1.4 -/* 1.5 - * Copyright Oct 24, 2009 OpenSourceStewardshipFoundation.org 1.6 - * Licensed under GNU General Public License version 2 1.7 - */ 1.8 - 1.9 -#ifndef MATRIX_MULT_H_ 1.10 -#define MATRIX_MULT_H_ 1.11 - 1.12 -#include <stdio.h> 1.13 -#include <unistd.h> 1.14 -#include <malloc.h> 1.15 - 1.16 -#include "../SSR_lib/VMS/VMS_primitive_data_types.h" 1.17 -#include "ParamHelper/Param.h" 1.18 - 1.19 -//============================== Structures ============================== 1.20 - 1.21 -typedef 1.22 -struct 1.23 - { int32 numRows; 1.24 - int32 numCols; 1.25 - float32 *array; //2D, but dynamically sized, so use addr arith 1.26 - } 1.27 -Matrix; 1.28 - 1.29 -/* This is the "appSpecificPiece" that is carried inside a DKUPiece. 1.30 - * In the DKUPiece data struc it is declared to be of type "void *". This 1.31 - * allows the application to define any data structure it wants and put it 1.32 - * into a DKUPiece. 1.33 - * When the app specific info is used, it is in app code, so it is cast to 1.34 - * the correct type to tell the compiler how to access fields. 1.35 - * This keeps all app-specific things out of the DKU directory, as per the 1.36 - * DKU standard. */ 1.37 -typedef 1.38 -struct 1.39 - { 1.40 - // pointers to shared data.. the result matrix must be created when the 1.41 - // left and right matrices are put into the root ancestor DKUPiece. 1.42 - Matrix * leftMatrix; 1.43 - Matrix * rightMatrix; 1.44 - Matrix * resultMatrix; 1.45 - 1.46 - // define the starting and ending boundaries for this piece of the 1.47 - // result matrix. These are derivable from the left and right 1.48 - // matrices, but included them for readability of code. 1.49 - int prodStartRow, prodEndRow; 1.50 - int prodStartCol, prodEndCol; 1.51 - // Start and end of the portion of the left matrix that contributes to 1.52 - // this piece of the product 1.53 - int leftStartRow, leftEndRow; 1.54 - int leftStartCol, leftEndCol; 1.55 - // Start and end of the portion of the right matrix that contributes to 1.56 - // this piece of the product 1.57 - int rightStartRow, rightEndRow; 1.58 - int rightStartCol, rightEndCol; 1.59 - } 1.60 -MatrixProdPiece; 1.61 - 1.62 -//============================== Functions ================================ 1.63 -void readFile(); 1.64 - 1.65 -Matrix *makeMatrix( int32 numRows, int32 numCols ); 1.66 -Matrix *makeMatrix_Flat( int32 numRows, int32 numCols ); 1.67 -Matrix *makeMatrix_WithResMat( int32 numRows, int32 numCols ); 1.68 -void freeMatrix_Flat( Matrix * matrix ); 1.69 -void freeMatrix( Matrix * matrix ); 1.70 -void printMatrix( Matrix *matrix ); 1.71 - 1.72 -void read_Matrix_From_File( Matrix *matrixStruc, char *matrixFileName ); 1.73 - 1.74 -void 1.75 -initialize_Input_Matrices_Via( Matrix **leftMatrix, Matrix **rightMatrix, 1.76 - ParamBag *paramBag ); 1.77 - 1.78 -//=========================================================================== 1.79 - 1.80 -#endif /*MATRIX_MULT_H_*/ 1.81 +/* 1.82 + * Copyright Oct 24, 2009 OpenSourceStewardshipFoundation.org 1.83 + * Licensed under GNU General Public License version 2 1.84 + */ 1.85 + 1.86 +#ifndef MATRIX_MULT_H_ 1.87 +#define MATRIX_MULT_H_ 1.88 + 1.89 +#include <stdio.h> 1.90 +#include <unistd.h> 1.91 +#include <malloc.h> 1.92 + 1.93 +#include "../SSR_lib/VMS/VMS_primitive_data_types.h" 1.94 +#include "ParamHelper/Param.h" 1.95 + 1.96 +//============================== Structures ============================== 1.97 + 1.98 +typedef 1.99 +struct 1.100 + { int32 numRows; 1.101 + int32 numCols; 1.102 + float32 *array; //2D, but dynamically sized, so use addr arith 1.103 + } 1.104 +Matrix; 1.105 + 1.106 +/* This is the "appSpecificPiece" that is carried inside a DKUPiece. 1.107 + * In the DKUPiece data struc it is declared to be of type "void *". This 1.108 + * allows the application to define any data structure it wants and put it 1.109 + * into a DKUPiece. 1.110 + * When the app specific info is used, it is in app code, so it is cast to 1.111 + * the correct type to tell the compiler how to access fields. 1.112 + * This keeps all app-specific things out of the DKU directory, as per the 1.113 + * DKU standard. */ 1.114 +typedef 1.115 +struct 1.116 + { 1.117 + // pointers to shared data.. the result matrix must be created when the 1.118 + // left and right matrices are put into the root ancestor DKUPiece. 1.119 + Matrix * leftMatrix; 1.120 + Matrix * rightMatrix; 1.121 + Matrix * resultMatrix; 1.122 + 1.123 + // define the starting and ending boundaries for this piece of the 1.124 + // result matrix. These are derivable from the left and right 1.125 + // matrices, but included them for readability of code. 1.126 + int prodStartRow, prodEndRow; 1.127 + int prodStartCol, prodEndCol; 1.128 + // Start and end of the portion of the left matrix that contributes to 1.129 + // this piece of the product 1.130 + int leftStartRow, leftEndRow; 1.131 + int leftStartCol, leftEndCol; 1.132 + // Start and end of the portion of the right matrix that contributes to 1.133 + // this piece of the product 1.134 + int rightStartRow, rightEndRow; 1.135 + int rightStartCol, rightEndCol; 1.136 + } 1.137 +MatrixProdPiece; 1.138 + 1.139 +//============================== Functions ================================ 1.140 +void readFile(); 1.141 + 1.142 +Matrix *makeMatrix( int32 numRows, int32 numCols ); 1.143 +Matrix *makeMatrix_Flat( int32 numRows, int32 numCols ); 1.144 +Matrix *makeMatrix_WithResMat( int32 numRows, int32 numCols ); 1.145 +void freeMatrix_Flat( Matrix * matrix ); 1.146 +void freeMatrix( Matrix * matrix ); 1.147 +void printMatrix( Matrix *matrix ); 1.148 + 1.149 +void read_Matrix_From_File( Matrix *matrixStruc, char *matrixFileName ); 1.150 + 1.151 +void 1.152 +initialize_Input_Matrices_Via( Matrix **leftMatrix, Matrix **rightMatrix, 1.153 + ParamBag *paramBag ); 1.154 + 1.155 +//=========================================================================== 1.156 + 1.157 +#endif /*MATRIX_MULT_H_*/
2.1 --- a/src/Application/SSR_Matrix_Mult/Divide_Pr.c Sun Nov 14 11:07:52 2010 -0800 2.2 +++ b/src/Application/SSR_Matrix_Mult/Divide_Pr.c Thu May 12 14:27:17 2011 +0200 2.3 @@ -471,6 +471,9 @@ 2.4 newSubMatrix->origStartCol = startCol; 2.5 newSubMatrix->copySingleton = NULL; 2.6 newSubMatrix->numUsesLeft = numUses; //can free after this many 2.7 + //Prevent uninitialized memory 2.8 + newSubMatrix->copySingleton = NULL; 2.9 + newSubMatrix->copyTransSingleton = NULL; 2.10 2.11 subMatrices[ rowOffset + colIdx ] = newSubMatrix; 2.12 }
3.1 --- a/src/Application/SSR_Matrix_Mult/SSR_Matrix_Mult.h Sun Nov 14 11:07:52 2010 -0800 3.2 +++ b/src/Application/SSR_Matrix_Mult/SSR_Matrix_Mult.h Thu May 12 14:27:17 2011 +0200 3.3 @@ -1,97 +1,97 @@ 3.4 -/* 3.5 - * Copyright Oct 24, 2009 OpenSourceStewardshipFoundation.org 3.6 - * Licensed under GNU General Public License version 2 3.7 - */ 3.8 - 3.9 -#ifndef _SSR_MATRIX_MULT_H_ 3.10 -#define _SSR_MATRIX_MULT_H_ 3.11 - 3.12 -#include <stdio.h> 3.13 - 3.14 -#include "../../SSR_lib/SSR.h" 3.15 -#include "../Matrix_Mult.h" 3.16 - 3.17 - 3.18 -//=============================== Defines ============================== 3.19 -#define ROWS_IN_BLOCK 32 3.20 -#define COLS_IN_BLOCK 32 3.21 -#define VEC_IN_BLOCK 32 3.22 - 3.23 -#define copyMatrixSingleton 1 3.24 -#define copyTransposeSingleton 2 3.25 - 3.26 -//============================== Structures ============================== 3.27 -typedef struct 3.28 - { 3.29 - Matrix *leftMatrix; 3.30 - Matrix *rightMatrix; 3.31 - Matrix *resultMatrix; 3.32 - } 3.33 -DividerParams; 3.34 - 3.35 -typedef struct 3.36 - { 3.37 - VirtProcr *dividerPr; 3.38 - int numRows; 3.39 - int numCols; 3.40 - int numSubMatrixPairs; 3.41 - float32 *resultArray; 3.42 - } 3.43 -ResultsParams; 3.44 - 3.45 -typedef 3.46 -struct 3.47 - { int32 numRows; 3.48 - int32 numCols; 3.49 - Matrix *origMatrix; 3.50 - int32 origStartRow; 3.51 - int32 origStartCol; 3.52 - int32 alreadyCopied; 3.53 - int32 numUsesLeft; //have update via message to avoid multiple writers 3.54 - SSRSingleton *copySingleton; 3.55 - SSRSingleton *copyTransSingleton; 3.56 - float32 *array; //2D, but dynamically sized, so use addr arith 3.57 - } 3.58 -SubMatrix; 3.59 - 3.60 -typedef struct 3.61 - { VirtProcr *resultPr; 3.62 - SubMatrix *leftSubMatrix; 3.63 - SubMatrix *rightSubMatrix; 3.64 - float32 *partialResultArray; 3.65 - } 3.66 -SMPairParams; 3.67 - 3.68 -typedef 3.69 -struct 3.70 - { int32 numVals; 3.71 - int32 *startVals; 3.72 - } 3.73 -SlicingStruc; 3.74 - 3.75 -typedef 3.76 -struct 3.77 - { 3.78 - SlicingStruc *leftRowSlices; 3.79 - SlicingStruc *vecSlices; 3.80 - SlicingStruc *rightColSlices; 3.81 - } 3.82 -SlicingStrucCarrier; 3.83 - 3.84 -enum MMMsgType 3.85 - { 3.86 - RESULTS_MSG = 1 3.87 - }; 3.88 - 3.89 -//============================= Processor Functions ========================= 3.90 -void divideWorkIntoSubMatrixPairProcrs( void *data, VirtProcr *animatingPr ); 3.91 -void calcSubMatrixProduct( void *data, VirtProcr *animatingPr ); 3.92 -void gatherResults( void *data, VirtProcr *animatingPr ); 3.93 - 3.94 - 3.95 -//================================ Entry Point ============================== 3.96 -Matrix * 3.97 -multiplyTheseMatrices( Matrix *leftMatrix, Matrix *rightMatrix ); 3.98 - 3.99 - 3.100 -#endif /*_SSR_MATRIX_MULT_H_*/ 3.101 +/* 3.102 + * Copyright Oct 24, 2009 OpenSourceStewardshipFoundation.org 3.103 + * Licensed under GNU General Public License version 2 3.104 + */ 3.105 + 3.106 +#ifndef _SSR_MATRIX_MULT_H_ 3.107 +#define _SSR_MATRIX_MULT_H_ 3.108 + 3.109 +#include <stdio.h> 3.110 + 3.111 +#include "../../SSR_lib/SSR.h" 3.112 +#include "../Matrix_Mult.h" 3.113 + 3.114 + 3.115 +//=============================== Defines ============================== 3.116 +#define ROWS_IN_BLOCK 32 3.117 +#define COLS_IN_BLOCK 32 3.118 +#define VEC_IN_BLOCK 32 3.119 + 3.120 +#define copyMatrixSingleton 1 3.121 +#define copyTransposeSingleton 2 3.122 + 3.123 +//============================== Structures ============================== 3.124 +typedef struct 3.125 + { 3.126 + Matrix *leftMatrix; 3.127 + Matrix *rightMatrix; 3.128 + Matrix *resultMatrix; 3.129 + } 3.130 +DividerParams; 3.131 + 3.132 +typedef struct 3.133 + { 3.134 + VirtProcr *dividerPr; 3.135 + int numRows; 3.136 + int numCols; 3.137 + int numSubMatrixPairs; 3.138 + float32 *resultArray; 3.139 + } 3.140 +ResultsParams; 3.141 + 3.142 +typedef 3.143 +struct 3.144 + { int32 numRows; 3.145 + int32 numCols; 3.146 + Matrix *origMatrix; 3.147 + int32 origStartRow; 3.148 + int32 origStartCol; 3.149 + int32 alreadyCopied; 3.150 + int32 numUsesLeft; //have update via message to avoid multiple writers 3.151 + SSRSingleton *copySingleton; 3.152 + SSRSingleton *copyTransSingleton; 3.153 + float32 *array; //2D, but dynamically sized, so use addr arith 3.154 + } 3.155 +SubMatrix; 3.156 + 3.157 +typedef struct 3.158 + { VirtProcr *resultPr; 3.159 + SubMatrix *leftSubMatrix; 3.160 + SubMatrix *rightSubMatrix; 3.161 + float32 *partialResultArray; 3.162 + } 3.163 +SMPairParams; 3.164 + 3.165 +typedef 3.166 +struct 3.167 + { int32 numVals; 3.168 + int32 *startVals; 3.169 + } 3.170 +SlicingStruc; 3.171 + 3.172 +typedef 3.173 +struct 3.174 + { 3.175 + SlicingStruc *leftRowSlices; 3.176 + SlicingStruc *vecSlices; 3.177 + SlicingStruc *rightColSlices; 3.178 + } 3.179 +SlicingStrucCarrier; 3.180 + 3.181 +enum MMMsgType 3.182 + { 3.183 + RESULTS_MSG = 1 3.184 + }; 3.185 + 3.186 +//============================= Processor Functions ========================= 3.187 +void divideWorkIntoSubMatrixPairProcrs( void *data, VirtProcr *animatingPr ); 3.188 +void calcSubMatrixProduct( void *data, VirtProcr *animatingPr ); 3.189 +void gatherResults( void *data, VirtProcr *animatingPr ); 3.190 + 3.191 + 3.192 +//================================ Entry Point ============================== 3.193 +Matrix * 3.194 +multiplyTheseMatrices( Matrix *leftMatrix, Matrix *rightMatrix ); 3.195 + 3.196 + 3.197 +#endif /*_SSR_MATRIX_MULT_H_*/
