changeset 4:16a32ca59bef

free before use & made hardware independent
author Merten Sach <msach@mailbox.tu-berlin.de>
date Thu, 16 Jun 2011 14:37:48 +0200
parents 4007d97740a5
children 359626c70e98
files src/Application/VPThread__Matrix_Mult/Divide_Pr.c src/Application/VPThread__Matrix_Mult/subMatrix_Pr.c
diffstat 2 files changed, 22 insertions(+), 17 deletions(-) [+]
line diff
     1.1 --- a/src/Application/VPThread__Matrix_Mult/Divide_Pr.c	Thu Jun 02 14:43:18 2011 +0200
     1.2 +++ b/src/Application/VPThread__Matrix_Mult/Divide_Pr.c	Thu Jun 16 14:37:48 2011 +0200
     1.3 @@ -10,6 +10,7 @@
     1.4  #include "VPThread__Matrix_Mult.h"
     1.5  #include <math.h>
     1.6  #include <string.h>
     1.7 +#include "../../VPThread_lib/VPThread.h"
     1.8  
     1.9     //The time to compute this many result values should equal the time to
    1.10     // perform this division on a matrix of size gives that many result calcs
    1.11 @@ -118,8 +119,7 @@
    1.12   { VirtProcr       *resultPr;
    1.13     DividerParams   *dividerParams;
    1.14     ResultsParams   *resultsParams;
    1.15 -   Matrix          *leftMatrix, *rightMatrix, *resultMatrix;
    1.16 -   void            *msg;
    1.17 +   Matrix          *leftMatrix, *rightMatrix;
    1.18     SlicingStrucCarrier *slicingStrucCarrier;
    1.19     float32             *resultArray; //points to array inside result matrix
    1.20     MatrixMultGlobals   *globals;
    1.21 @@ -162,8 +162,9 @@
    1.22           //transpose the right matrix
    1.23        float32 *
    1.24        transRightArray  = 
    1.25 -         VPThread__malloc( rightMatrix->numRows * rightMatrix->numCols *
    1.26 -                           sizeof(float32), animatingThd );
    1.27 +         VPThread__malloc( (size_t)rightMatrix->numRows * 
    1.28 +                                (size_t)rightMatrix->numCols *
    1.29 +                                sizeof(float32), animatingThd );
    1.30  
    1.31           //copy values from orig matrix to local
    1.32        copyTranspose( rightMatrix->numRows, rightMatrix->numCols,
    1.33 @@ -289,7 +290,7 @@
    1.34        (float64)minWorkUnitCycles / (float64)primitiveCycles;
    1.35  
    1.36        //take cubed root -- that's number of these in a "side" of sub-matrix
    1.37 -      // then multiply by 5 because the primitive is 5x5
    1.38 +      // 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’
    1.39     idealSizeOfSide1 = 5 * cbrt( numPrimitiveOpsInMinWorkUnit );
    1.40  
    1.41     idealNumWorkUnits = VPThread__giveIdealNumWorkUnits();
    1.42 @@ -357,9 +358,6 @@
    1.43        createSubMatrices( vecSlices, rightColSlices, leftRowSlices->numVals,
    1.44                           rightMatrix, animPr );
    1.45  
    1.46 -   freeSlicingStruc( leftRowSlices, animPr );
    1.47 -   freeSlicingStruc( vecSlices, animPr );
    1.48 -   freeSlicingStruc( rightColSlices, animPr );
    1.49  
    1.50     //==============  pair the sub-matrices and make processors ==============
    1.51     int32 numRowIdxs, numColIdxs, numVecIdxs;
    1.52 @@ -367,6 +365,11 @@
    1.53     numRowIdxs = leftRowSlices->numVals;
    1.54     numColIdxs = rightColSlices->numVals;
    1.55     numVecIdxs = vecSlices->numVals;
    1.56 +   
    1.57 +   freeSlicingStruc( leftRowSlices, animPr );
    1.58 +   freeSlicingStruc( vecSlices, animPr );
    1.59 +   freeSlicingStruc( rightColSlices, animPr );
    1.60 +   
    1.61     pairUpSubMatricesAndMakeProcessors( leftSubMatrices,
    1.62                                         rightSubMatrices,
    1.63                                         numRowIdxs, numColIdxs,
    1.64 @@ -454,7 +457,7 @@
    1.65               { coreToScheduleOnto += 1;
    1.66               }
    1.67            }
    1.68 - 
    1.69 +
    1.70         }
    1.71      }
    1.72   }
    1.73 @@ -479,8 +482,8 @@
    1.74     rowStartVals = rowSlices->startVals;
    1.75     colStartVals = colSlices->startVals;
    1.76  
    1.77 -   subMatrices = VPThread__malloc(numRowIdxs * numColIdxs * sizeof(SubMatrix*),
    1.78 -                                 animPr );
    1.79 +   subMatrices = VPThread__malloc((size_t)numRowIdxs *
    1.80 +                            (size_t)numColIdxs * sizeof(SubMatrix*),animPr );
    1.81  
    1.82     for( rowIdx = 0; rowIdx < numRowIdxs; rowIdx++ )
    1.83      {
    1.84 @@ -550,7 +553,7 @@
    1.85        //calc size of matrix need to hold start vals --
    1.86     numSlices = (int32)( (float32)(endVal -startVal +1) / idealSizeOfSide);
    1.87  
    1.88 -   startVals = VPThread__malloc( (numSlices + 1) * sizeof(int32), animPr );
    1.89 +   startVals = VPThread__malloc( ((size_t)numSlices + 1) * sizeof(int32), animPr );
    1.90  
    1.91        //Calc the upper limit of start value -- when get above this, end loop
    1.92        // by saving highest value of the matrix dimension to access, plus 1
     2.1 --- a/src/Application/VPThread__Matrix_Mult/subMatrix_Pr.c	Thu Jun 02 14:43:18 2011 +0200
     2.2 +++ b/src/Application/VPThread__Matrix_Mult/subMatrix_Pr.c	Thu Jun 16 14:37:48 2011 +0200
     2.3 @@ -73,8 +73,8 @@
     2.4     leftArray      = leftSubMatrix->array;
     2.5     rightArray     = rightSubMatrix->array;
     2.6  
     2.7 -   int32
     2.8 -   resSize = leftSubMatrix->numRows * rightSubMatrix->numCols * sizeof(float32);
     2.9 +   size_t resSize = (size_t)leftSubMatrix->numRows * 
    2.10 +                        (size_t)rightSubMatrix->numCols * sizeof(float32);
    2.11     resArray = VPThread__malloc( resSize, animatingPr );
    2.12     memset( resArray, 0, resSize );
    2.13  
    2.14 @@ -234,7 +234,7 @@
    2.15  
    2.16  void inline
    2.17  copyTransposeFromOrig( SubMatrix *subMatrix, VirtProcr *animPr )
    2.18 - { int numCols, numRows, origStartRow, origStartCol, origStride, stride;
    2.19 + { int numCols, numRows, origStartRow, origStartCol, origStride;
    2.20     Matrix *origMatrix;
    2.21     float32 *origArray, *subArray;
    2.22  
    2.23 @@ -248,7 +248,8 @@
    2.24     origStartCol = subMatrix->origStartCol;
    2.25     origStride   = origMatrix->numCols;
    2.26  
    2.27 -   subArray    = VPThread__malloc( numRows * numCols *sizeof(float32),animPr);
    2.28 +   subArray    = VPThread__malloc( (size_t)numRows * 
    2.29 +                                        (size_t)numCols *sizeof(float32),animPr);
    2.30     subMatrix->array = subArray;
    2.31  
    2.32        //copy values from orig matrix to local
    2.33 @@ -285,7 +286,8 @@
    2.34     origStartCol  = subMatrix->origStartCol;
    2.35     origStride    = origMatrix->numCols;
    2.36  
    2.37 -   subArray    = VPThread__malloc( numRows * numCols *sizeof(float32),animPr);
    2.38 +   subArray    = VPThread__malloc( (size_t)numRows * 
    2.39 +                                        (size_t)numCols *sizeof(float32),animPr);
    2.40     subMatrix->array = subArray;
    2.41  
    2.42        //copy values from orig matrix to local