# HG changeset patch # User Merten Sach # Date 1305203237 -7200 # Node ID c5d77078740c81cd138f3d3145cef9a5d560925f # Parent 78d8bd6aadacdf61b80b4076799024d59e464900 fixed: uninitialized variable diff -r 78d8bd6aadac -r c5d77078740c src/Application/Matrix_Mult.h --- a/src/Application/Matrix_Mult.h Sun Nov 14 11:07:52 2010 -0800 +++ b/src/Application/Matrix_Mult.h Thu May 12 14:27:17 2011 +0200 @@ -1,77 +1,77 @@ -/* - * Copyright Oct 24, 2009 OpenSourceStewardshipFoundation.org - * Licensed under GNU General Public License version 2 - */ - -#ifndef MATRIX_MULT_H_ -#define MATRIX_MULT_H_ - -#include -#include -#include - -#include "../SSR_lib/VMS/VMS_primitive_data_types.h" -#include "ParamHelper/Param.h" - -//============================== Structures ============================== - -typedef -struct - { int32 numRows; - int32 numCols; - float32 *array; //2D, but dynamically sized, so use addr arith - } -Matrix; - -/* This is the "appSpecificPiece" that is carried inside a DKUPiece. - * In the DKUPiece data struc it is declared to be of type "void *". This - * allows the application to define any data structure it wants and put it - * into a DKUPiece. - * When the app specific info is used, it is in app code, so it is cast to - * the correct type to tell the compiler how to access fields. - * This keeps all app-specific things out of the DKU directory, as per the - * DKU standard. */ -typedef -struct - { - // pointers to shared data.. the result matrix must be created when the - // left and right matrices are put into the root ancestor DKUPiece. - Matrix * leftMatrix; - Matrix * rightMatrix; - Matrix * resultMatrix; - - // define the starting and ending boundaries for this piece of the - // result matrix. These are derivable from the left and right - // matrices, but included them for readability of code. - int prodStartRow, prodEndRow; - int prodStartCol, prodEndCol; - // Start and end of the portion of the left matrix that contributes to - // this piece of the product - int leftStartRow, leftEndRow; - int leftStartCol, leftEndCol; - // Start and end of the portion of the right matrix that contributes to - // this piece of the product - int rightStartRow, rightEndRow; - int rightStartCol, rightEndCol; - } -MatrixProdPiece; - -//============================== Functions ================================ -void readFile(); - -Matrix *makeMatrix( int32 numRows, int32 numCols ); -Matrix *makeMatrix_Flat( int32 numRows, int32 numCols ); -Matrix *makeMatrix_WithResMat( int32 numRows, int32 numCols ); -void freeMatrix_Flat( Matrix * matrix ); -void freeMatrix( Matrix * matrix ); -void printMatrix( Matrix *matrix ); - -void read_Matrix_From_File( Matrix *matrixStruc, char *matrixFileName ); - -void -initialize_Input_Matrices_Via( Matrix **leftMatrix, Matrix **rightMatrix, - ParamBag *paramBag ); - -//=========================================================================== - -#endif /*MATRIX_MULT_H_*/ +/* + * Copyright Oct 24, 2009 OpenSourceStewardshipFoundation.org + * Licensed under GNU General Public License version 2 + */ + +#ifndef MATRIX_MULT_H_ +#define MATRIX_MULT_H_ + +#include +#include +#include + +#include "../SSR_lib/VMS/VMS_primitive_data_types.h" +#include "ParamHelper/Param.h" + +//============================== Structures ============================== + +typedef +struct + { int32 numRows; + int32 numCols; + float32 *array; //2D, but dynamically sized, so use addr arith + } +Matrix; + +/* This is the "appSpecificPiece" that is carried inside a DKUPiece. + * In the DKUPiece data struc it is declared to be of type "void *". This + * allows the application to define any data structure it wants and put it + * into a DKUPiece. + * When the app specific info is used, it is in app code, so it is cast to + * the correct type to tell the compiler how to access fields. + * This keeps all app-specific things out of the DKU directory, as per the + * DKU standard. */ +typedef +struct + { + // pointers to shared data.. the result matrix must be created when the + // left and right matrices are put into the root ancestor DKUPiece. + Matrix * leftMatrix; + Matrix * rightMatrix; + Matrix * resultMatrix; + + // define the starting and ending boundaries for this piece of the + // result matrix. These are derivable from the left and right + // matrices, but included them for readability of code. + int prodStartRow, prodEndRow; + int prodStartCol, prodEndCol; + // Start and end of the portion of the left matrix that contributes to + // this piece of the product + int leftStartRow, leftEndRow; + int leftStartCol, leftEndCol; + // Start and end of the portion of the right matrix that contributes to + // this piece of the product + int rightStartRow, rightEndRow; + int rightStartCol, rightEndCol; + } +MatrixProdPiece; + +//============================== Functions ================================ +void readFile(); + +Matrix *makeMatrix( int32 numRows, int32 numCols ); +Matrix *makeMatrix_Flat( int32 numRows, int32 numCols ); +Matrix *makeMatrix_WithResMat( int32 numRows, int32 numCols ); +void freeMatrix_Flat( Matrix * matrix ); +void freeMatrix( Matrix * matrix ); +void printMatrix( Matrix *matrix ); + +void read_Matrix_From_File( Matrix *matrixStruc, char *matrixFileName ); + +void +initialize_Input_Matrices_Via( Matrix **leftMatrix, Matrix **rightMatrix, + ParamBag *paramBag ); + +//=========================================================================== + +#endif /*MATRIX_MULT_H_*/ diff -r 78d8bd6aadac -r c5d77078740c src/Application/SSR_Matrix_Mult/Divide_Pr.c --- a/src/Application/SSR_Matrix_Mult/Divide_Pr.c Sun Nov 14 11:07:52 2010 -0800 +++ b/src/Application/SSR_Matrix_Mult/Divide_Pr.c Thu May 12 14:27:17 2011 +0200 @@ -471,6 +471,9 @@ newSubMatrix->origStartCol = startCol; newSubMatrix->copySingleton = NULL; newSubMatrix->numUsesLeft = numUses; //can free after this many + //Prevent uninitialized memory + newSubMatrix->copySingleton = NULL; + newSubMatrix->copyTransSingleton = NULL; subMatrices[ rowOffset + colIdx ] = newSubMatrix; } diff -r 78d8bd6aadac -r c5d77078740c src/Application/SSR_Matrix_Mult/SSR_Matrix_Mult.h --- a/src/Application/SSR_Matrix_Mult/SSR_Matrix_Mult.h Sun Nov 14 11:07:52 2010 -0800 +++ b/src/Application/SSR_Matrix_Mult/SSR_Matrix_Mult.h Thu May 12 14:27:17 2011 +0200 @@ -1,97 +1,97 @@ -/* - * Copyright Oct 24, 2009 OpenSourceStewardshipFoundation.org - * Licensed under GNU General Public License version 2 - */ - -#ifndef _SSR_MATRIX_MULT_H_ -#define _SSR_MATRIX_MULT_H_ - -#include - -#include "../../SSR_lib/SSR.h" -#include "../Matrix_Mult.h" - - -//=============================== Defines ============================== -#define ROWS_IN_BLOCK 32 -#define COLS_IN_BLOCK 32 -#define VEC_IN_BLOCK 32 - -#define copyMatrixSingleton 1 -#define copyTransposeSingleton 2 - -//============================== Structures ============================== -typedef struct - { - Matrix *leftMatrix; - Matrix *rightMatrix; - Matrix *resultMatrix; - } -DividerParams; - -typedef struct - { - VirtProcr *dividerPr; - int numRows; - int numCols; - int numSubMatrixPairs; - float32 *resultArray; - } -ResultsParams; - -typedef -struct - { int32 numRows; - int32 numCols; - Matrix *origMatrix; - int32 origStartRow; - int32 origStartCol; - int32 alreadyCopied; - int32 numUsesLeft; //have update via message to avoid multiple writers - SSRSingleton *copySingleton; - SSRSingleton *copyTransSingleton; - float32 *array; //2D, but dynamically sized, so use addr arith - } -SubMatrix; - -typedef struct - { VirtProcr *resultPr; - SubMatrix *leftSubMatrix; - SubMatrix *rightSubMatrix; - float32 *partialResultArray; - } -SMPairParams; - -typedef -struct - { int32 numVals; - int32 *startVals; - } -SlicingStruc; - -typedef -struct - { - SlicingStruc *leftRowSlices; - SlicingStruc *vecSlices; - SlicingStruc *rightColSlices; - } -SlicingStrucCarrier; - -enum MMMsgType - { - RESULTS_MSG = 1 - }; - -//============================= Processor Functions ========================= -void divideWorkIntoSubMatrixPairProcrs( void *data, VirtProcr *animatingPr ); -void calcSubMatrixProduct( void *data, VirtProcr *animatingPr ); -void gatherResults( void *data, VirtProcr *animatingPr ); - - -//================================ Entry Point ============================== -Matrix * -multiplyTheseMatrices( Matrix *leftMatrix, Matrix *rightMatrix ); - - -#endif /*_SSR_MATRIX_MULT_H_*/ +/* + * Copyright Oct 24, 2009 OpenSourceStewardshipFoundation.org + * Licensed under GNU General Public License version 2 + */ + +#ifndef _SSR_MATRIX_MULT_H_ +#define _SSR_MATRIX_MULT_H_ + +#include + +#include "../../SSR_lib/SSR.h" +#include "../Matrix_Mult.h" + + +//=============================== Defines ============================== +#define ROWS_IN_BLOCK 32 +#define COLS_IN_BLOCK 32 +#define VEC_IN_BLOCK 32 + +#define copyMatrixSingleton 1 +#define copyTransposeSingleton 2 + +//============================== Structures ============================== +typedef struct + { + Matrix *leftMatrix; + Matrix *rightMatrix; + Matrix *resultMatrix; + } +DividerParams; + +typedef struct + { + VirtProcr *dividerPr; + int numRows; + int numCols; + int numSubMatrixPairs; + float32 *resultArray; + } +ResultsParams; + +typedef +struct + { int32 numRows; + int32 numCols; + Matrix *origMatrix; + int32 origStartRow; + int32 origStartCol; + int32 alreadyCopied; + int32 numUsesLeft; //have update via message to avoid multiple writers + SSRSingleton *copySingleton; + SSRSingleton *copyTransSingleton; + float32 *array; //2D, but dynamically sized, so use addr arith + } +SubMatrix; + +typedef struct + { VirtProcr *resultPr; + SubMatrix *leftSubMatrix; + SubMatrix *rightSubMatrix; + float32 *partialResultArray; + } +SMPairParams; + +typedef +struct + { int32 numVals; + int32 *startVals; + } +SlicingStruc; + +typedef +struct + { + SlicingStruc *leftRowSlices; + SlicingStruc *vecSlices; + SlicingStruc *rightColSlices; + } +SlicingStrucCarrier; + +enum MMMsgType + { + RESULTS_MSG = 1 + }; + +//============================= Processor Functions ========================= +void divideWorkIntoSubMatrixPairProcrs( void *data, VirtProcr *animatingPr ); +void calcSubMatrixProduct( void *data, VirtProcr *animatingPr ); +void gatherResults( void *data, VirtProcr *animatingPr ); + + +//================================ Entry Point ============================== +Matrix * +multiplyTheseMatrices( Matrix *leftMatrix, Matrix *rightMatrix ); + + +#endif /*_SSR_MATRIX_MULT_H_*/