# HG changeset patch # User Merten Sach # Date 1308227868 -7200 # Node ID 16a32ca59bef02f35f23137cbc326a8a71fcee3d # Parent 4007d97740a5d58cbd582c8f026cc65153ca8e18 free before use & made hardware independent diff -r 4007d97740a5 -r 16a32ca59bef src/Application/VPThread__Matrix_Mult/Divide_Pr.c --- a/src/Application/VPThread__Matrix_Mult/Divide_Pr.c Thu Jun 02 14:43:18 2011 +0200 +++ b/src/Application/VPThread__Matrix_Mult/Divide_Pr.c Thu Jun 16 14:37:48 2011 +0200 @@ -10,6 +10,7 @@ #include "VPThread__Matrix_Mult.h" #include #include +#include "../../VPThread_lib/VPThread.h" //The time to compute this many result values should equal the time to // perform this division on a matrix of size gives that many result calcs @@ -118,8 +119,7 @@ { VirtProcr *resultPr; DividerParams *dividerParams; ResultsParams *resultsParams; - Matrix *leftMatrix, *rightMatrix, *resultMatrix; - void *msg; + Matrix *leftMatrix, *rightMatrix; SlicingStrucCarrier *slicingStrucCarrier; float32 *resultArray; //points to array inside result matrix MatrixMultGlobals *globals; @@ -162,8 +162,9 @@ //transpose the right matrix float32 * transRightArray = - VPThread__malloc( rightMatrix->numRows * rightMatrix->numCols * - sizeof(float32), animatingThd ); + VPThread__malloc( (size_t)rightMatrix->numRows * + (size_t)rightMatrix->numCols * + sizeof(float32), animatingThd ); //copy values from orig matrix to local copyTranspose( rightMatrix->numRows, rightMatrix->numCols, @@ -289,7 +290,7 @@ (float64)minWorkUnitCycles / (float64)primitiveCycles; //take cubed root -- that's number of these in a "side" of sub-matrix - // then multiply by 5 because the primitive is 5x5 + // then multiply by 5 because the primitive is 5x5src/Application/VPThread__Matrix_Mult/Divide_Pr.c:403: warning: implicit declaration of function ‘VPThread__give_number_of_cores_to_schedule_onto’ idealSizeOfSide1 = 5 * cbrt( numPrimitiveOpsInMinWorkUnit ); idealNumWorkUnits = VPThread__giveIdealNumWorkUnits(); @@ -357,9 +358,6 @@ createSubMatrices( vecSlices, rightColSlices, leftRowSlices->numVals, rightMatrix, animPr ); - freeSlicingStruc( leftRowSlices, animPr ); - freeSlicingStruc( vecSlices, animPr ); - freeSlicingStruc( rightColSlices, animPr ); //============== pair the sub-matrices and make processors ============== int32 numRowIdxs, numColIdxs, numVecIdxs; @@ -367,6 +365,11 @@ numRowIdxs = leftRowSlices->numVals; numColIdxs = rightColSlices->numVals; numVecIdxs = vecSlices->numVals; + + freeSlicingStruc( leftRowSlices, animPr ); + freeSlicingStruc( vecSlices, animPr ); + freeSlicingStruc( rightColSlices, animPr ); + pairUpSubMatricesAndMakeProcessors( leftSubMatrices, rightSubMatrices, numRowIdxs, numColIdxs, @@ -454,7 +457,7 @@ { coreToScheduleOnto += 1; } } - + } } } @@ -479,8 +482,8 @@ rowStartVals = rowSlices->startVals; colStartVals = colSlices->startVals; - subMatrices = VPThread__malloc(numRowIdxs * numColIdxs * sizeof(SubMatrix*), - animPr ); + subMatrices = VPThread__malloc((size_t)numRowIdxs * + (size_t)numColIdxs * sizeof(SubMatrix*),animPr ); for( rowIdx = 0; rowIdx < numRowIdxs; rowIdx++ ) { @@ -550,7 +553,7 @@ //calc size of matrix need to hold start vals -- numSlices = (int32)( (float32)(endVal -startVal +1) / idealSizeOfSide); - startVals = VPThread__malloc( (numSlices + 1) * sizeof(int32), animPr ); + startVals = VPThread__malloc( ((size_t)numSlices + 1) * sizeof(int32), animPr ); //Calc the upper limit of start value -- when get above this, end loop // by saving highest value of the matrix dimension to access, plus 1 diff -r 4007d97740a5 -r 16a32ca59bef src/Application/VPThread__Matrix_Mult/subMatrix_Pr.c --- a/src/Application/VPThread__Matrix_Mult/subMatrix_Pr.c Thu Jun 02 14:43:18 2011 +0200 +++ b/src/Application/VPThread__Matrix_Mult/subMatrix_Pr.c Thu Jun 16 14:37:48 2011 +0200 @@ -73,8 +73,8 @@ leftArray = leftSubMatrix->array; rightArray = rightSubMatrix->array; - int32 - resSize = leftSubMatrix->numRows * rightSubMatrix->numCols * sizeof(float32); + size_t resSize = (size_t)leftSubMatrix->numRows * + (size_t)rightSubMatrix->numCols * sizeof(float32); resArray = VPThread__malloc( resSize, animatingPr ); memset( resArray, 0, resSize ); @@ -234,7 +234,7 @@ void inline copyTransposeFromOrig( SubMatrix *subMatrix, VirtProcr *animPr ) - { int numCols, numRows, origStartRow, origStartCol, origStride, stride; + { int numCols, numRows, origStartRow, origStartCol, origStride; Matrix *origMatrix; float32 *origArray, *subArray; @@ -248,7 +248,8 @@ origStartCol = subMatrix->origStartCol; origStride = origMatrix->numCols; - subArray = VPThread__malloc( numRows * numCols *sizeof(float32),animPr); + subArray = VPThread__malloc( (size_t)numRows * + (size_t)numCols *sizeof(float32),animPr); subMatrix->array = subArray; //copy values from orig matrix to local @@ -285,7 +286,8 @@ origStartCol = subMatrix->origStartCol; origStride = origMatrix->numCols; - subArray = VPThread__malloc( numRows * numCols *sizeof(float32),animPr); + subArray = VPThread__malloc( (size_t)numRows * + (size_t)numCols *sizeof(float32),animPr); subMatrix->array = subArray; //copy values from orig matrix to local