Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > SSR > SSR__Blocked_Matrix_Mult__Bench
changeset 0:b8b71da62a09
init commit of copy of sliced matrix mult
| author | Me |
|---|---|
| date | Tue, 05 Oct 2010 10:00:11 -0700 |
| parents | |
| children | 47802166a7ae |
| files | src/Application/Matrix_Mult.c src/Application/Matrix_Mult.h src/Application/SSR_Matrix_Mult/Divide_Pr.c src/Application/SSR_Matrix_Mult/EntryPoint.c src/Application/SSR_Matrix_Mult/Result_Pr.c src/Application/SSR_Matrix_Mult/SSR_Matrix_Mult.h src/Application/SSR_Matrix_Mult/Vector_Pr.c src/Application/main.c |
| diffstat | 8 files changed, 565 insertions(+), 0 deletions(-) [+] |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/Application/Matrix_Mult.c Tue Oct 05 10:00:11 2010 -0700 1.3 @@ -0,0 +1,165 @@ 1.4 +/* 1.5 + * Copyright 2009 OpenSourceStewardshipFoundation.org 1.6 + * Licensed under GNU General Public License version 2 1.7 + * 1.8 + * Author: seanhalle@yahoo.com 1.9 + * 1.10 + * Created on November 15, 2009, 2:35 AM 1.11 + */ 1.12 + 1.13 +#include <malloc.h> 1.14 +#include <stdlib.h> 1.15 + 1.16 +#include "Matrix_Mult.h" 1.17 +#include "ParamHelper/Param.h" 1.18 + 1.19 + 1.20 + 1.21 + void 1.22 +initialize_Input_Matrices_Via( Matrix **leftMatrix, Matrix **rightMatrix, 1.23 + ParamBag *paramBag ) 1.24 + { char *leftMatrixFileName, *rightMatrixFileName; 1.25 + int leftMatrixRows, leftMatrixCols, rightMatrixRows, rightMatrixCols; 1.26 + 1.27 + ParamStruc *param; 1.28 + param = getParamFromBag( "leftMatrixRows", paramBag ); 1.29 + leftMatrixRows = param->intValue; 1.30 + param = getParamFromBag( "leftMatrixCols", paramBag ); 1.31 + leftMatrixCols = param->intValue; 1.32 + *leftMatrix = makeMatrix_WithResMat( leftMatrixRows, leftMatrixCols ); 1.33 + 1.34 + param = getParamFromBag( "leftMatrixFileName", paramBag ); 1.35 + leftMatrixFileName = param->strValue; //no need to copy 1.36 + read_Matrix_From_File( *leftMatrix, leftMatrixFileName ); 1.37 + 1.38 + param = getParamFromBag( "rightMatrixRows", paramBag ); 1.39 + rightMatrixRows = param->intValue; 1.40 + param = getParamFromBag( "rightMatrixCols", paramBag ); 1.41 + rightMatrixCols = param->intValue; 1.42 + *rightMatrix = makeMatrix_WithResMat( rightMatrixRows, rightMatrixCols ); 1.43 + 1.44 + param = getParamFromBag( "rightMatrixFileName", paramBag ); 1.45 + rightMatrixFileName = param->strValue; 1.46 + read_Matrix_From_File( *rightMatrix, rightMatrixFileName ); 1.47 + } 1.48 + 1.49 + 1.50 +void parseLineIntoRow( char *line, float32* row ); 1.51 + 1.52 + 1.53 + void 1.54 +read_Matrix_From_File( Matrix *matrixStruc, char *matrixFileName ) 1.55 + { int row, maxRead, numRows, numCols; 1.56 + float32 *matrixStart; 1.57 + size_t lineSz = 0; 1.58 + FILE *file; 1.59 + char *line = NULL; 1.60 + 1.61 + lineSz = 50000; //max length of line in a matrix data file 1.62 + line = (char *) malloc( lineSz ); 1.63 + if( line == NULL ) printf( "no mem for matrix line" ); 1.64 + 1.65 + numRows = matrixStruc->numRows; 1.66 + numCols = matrixStruc->numCols; 1.67 + matrixStart = matrixStruc->matrix; 1.68 + 1.69 + file = fopen( matrixFileName, "r" ); 1.70 + if( file == NULL ) { printf( "\nCouldn't open file!!\n"); exit(1);} 1.71 + fseek( file, 0, SEEK_SET ); 1.72 + for( row = 0; row < numRows; row++ ) 1.73 + { 1.74 + if( feof( file ) ) printf( "file ran out too soon" ); 1.75 + maxRead = getline( &line, &lineSz, file ); 1.76 + if( maxRead == -1 ) printf( "prob reading mat line"); 1.77 + 1.78 + if( *line == '\n') continue; //blank line 1.79 + if( *line == '/' ) continue; //comment line 1.80 + 1.81 + parseLineIntoRow( line, matrixStart + row * numCols ); 1.82 + } 1.83 + free( line ); 1.84 + } 1.85 + 1.86 +/*This function relies on each line having the proper number of cols. It 1.87 + * doesn't check, nor enforce, so if the file is improperly formatted it 1.88 + * can write over unrelated memory 1.89 + */ 1.90 + void 1.91 +parseLineIntoRow( char *line, float32* row ) 1.92 + { 1.93 + char *valueStr, *searchPos; 1.94 + 1.95 + //read the float values 1.96 + searchPos = valueStr = line; //start 1.97 + 1.98 + for( ; *searchPos != 0; searchPos++) //bit dangerous, should use buff len 1.99 + { 1.100 + if( *searchPos == '\n' ) //last col.. relying on well-formatted file 1.101 + { *searchPos = 0; 1.102 + *row = atof( valueStr ); 1.103 + break; //end FOR loop 1.104 + } 1.105 + if( *searchPos == ',' ) 1.106 + { *searchPos = 0; //mark end of string 1.107 + *row = (float32) atof( valueStr ); 1.108 + row += 1; //address arith 1.109 + //skip any spaces before digits.. use searchPos + 1 to skip the 0 1.110 + for( ; *(searchPos + 1)== ' ' && *(searchPos + 1) !=0; searchPos++); 1.111 + valueStr = searchPos + 1; 1.112 + } 1.113 + } 1.114 + } 1.115 + 1.116 + //========================================================================== 1.117 + 1.118 +/*In the "_Flat" version of constructor, do only malloc of the top data struc 1.119 + * and set values in that top-level. Don't malloc any sub-structures. 1.120 + */ 1.121 + Matrix * 1.122 +makeMatrix_Flat( int32 numRows, int32 numCols ) 1.123 + { Matrix * retMatrix; 1.124 + retMatrix = malloc( sizeof( Matrix ) ); 1.125 + retMatrix->numRows = numRows; 1.126 + retMatrix->numCols = numCols; 1.127 + 1.128 + return retMatrix; 1.129 + } 1.130 + 1.131 + Matrix * 1.132 +makeMatrix_WithResMat( int32 numRows, int32 numCols ) 1.133 + { Matrix * retMatrix; 1.134 + retMatrix = malloc( sizeof( Matrix ) ); 1.135 + retMatrix->numRows = numRows; 1.136 + retMatrix->numCols = numCols; 1.137 + retMatrix->matrix = malloc( numRows * numCols * sizeof(float32) ); 1.138 + 1.139 + return retMatrix; 1.140 + } 1.141 + 1.142 + void 1.143 +freeMatrix_Flat( Matrix * matrix ) 1.144 + { //( matrix ); 1.145 + } 1.146 + void 1.147 +freeMatrix( Matrix * matrix ) 1.148 + { free( matrix->matrix ); 1.149 + free( matrix ); 1.150 + } 1.151 + 1.152 +void 1.153 +printMatrix( Matrix *matrix ) 1.154 + { int r, c, numRows, numCols; 1.155 + float32 *matrixArray; 1.156 + 1.157 + numRows = matrix->numRows; 1.158 + numCols = matrix->numCols; 1.159 + matrixArray = matrix->matrix; 1.160 + 1.161 + for( r = 0; r < numRows; r++ ) 1.162 + { for( c = 0; c < numCols; c++ ) 1.163 + { printf( "%f | ", *(matrixArray + r*numCols + c) ); 1.164 + } 1.165 + printf("\n"); 1.166 + } 1.167 + } 1.168 +
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/src/Application/Matrix_Mult.h Tue Oct 05 10:00:11 2010 -0700 2.3 @@ -0,0 +1,77 @@ 2.4 +/* 2.5 + * Copyright Oct 24, 2009 OpenSourceStewardshipFoundation.org 2.6 + * Licensed under GNU General Public License version 2 2.7 + */ 2.8 + 2.9 +#ifndef MATRIX_MULT_H_ 2.10 +#define MATRIX_MULT_H_ 2.11 + 2.12 +#include <stdio.h> 2.13 +#include <unistd.h> 2.14 +#include <malloc.h> 2.15 + 2.16 +#include "../SSR_lib/VMS/VMS_primitive_data_types.h" 2.17 +#include "ParamHelper/Param.h" 2.18 + 2.19 +//============================== Structures ============================== 2.20 + 2.21 +typedef 2.22 +struct 2.23 + { int32 numRows; 2.24 + int32 numCols; 2.25 + float32 *matrix; //2D, but dynamically sized, so use addr arith 2.26 + } 2.27 +Matrix; 2.28 + 2.29 +/* This is the "appSpecificPiece" that is carried inside a DKUPiece. 2.30 + * In the DKUPiece data struc it is declared to be of type "void *". This 2.31 + * allows the application to define any data structure it wants and put it 2.32 + * into a DKUPiece. 2.33 + * When the app specific info is used, it is in app code, so it is cast to 2.34 + * the correct type to tell the compiler how to access fields. 2.35 + * This keeps all app-specific things out of the DKU directory, as per the 2.36 + * DKU standard. */ 2.37 +typedef 2.38 +struct 2.39 + { 2.40 + // pointers to shared data.. the result matrix must be created when the 2.41 + // left and right matrices are put into the root ancestor DKUPiece. 2.42 + Matrix * leftMatrix; 2.43 + Matrix * rightMatrix; 2.44 + Matrix * resultMatrix; 2.45 + 2.46 + // define the starting and ending boundaries for this piece of the 2.47 + // result matrix. These are derivable from the left and right 2.48 + // matrices, but included them for readability of code. 2.49 + int prodStartRow, prodEndRow; 2.50 + int prodStartCol, prodEndCol; 2.51 + // Start and end of the portion of the left matrix that contributes to 2.52 + // this piece of the product 2.53 + int leftStartRow, leftEndRow; 2.54 + int leftStartCol, leftEndCol; 2.55 + // Start and end of the portion of the right matrix that contributes to 2.56 + // this piece of the product 2.57 + int rightStartRow, rightEndRow; 2.58 + int rightStartCol, rightEndCol; 2.59 + } 2.60 +MatrixProdPiece; 2.61 + 2.62 +//============================== Functions ================================ 2.63 +void readFile(); 2.64 + 2.65 +Matrix *makeMatrix( int32 numRows, int32 numCols ); 2.66 +Matrix *makeMatrix_Flat( int32 numRows, int32 numCols ); 2.67 +Matrix *makeMatrix_WithResMat( int32 numRows, int32 numCols ); 2.68 +void freeMatrix_Flat( Matrix * matrix ); 2.69 +void freeMatrix( Matrix * matrix ); 2.70 +void printMatrix( Matrix *matrix ); 2.71 + 2.72 +void read_Matrix_From_File( Matrix *matrixStruc, char *matrixFileName ); 2.73 + 2.74 +void 2.75 +initialize_Input_Matrices_Via( Matrix **leftMatrix, Matrix **rightMatrix, 2.76 + ParamBag *paramBag ); 2.77 + 2.78 +//=========================================================================== 2.79 + 2.80 +#endif /*MATRIX_MULT_H_*/
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/src/Application/SSR_Matrix_Mult/Divide_Pr.c Tue Oct 05 10:00:11 2010 -0700 3.3 @@ -0,0 +1,85 @@ 3.4 +/* 3.5 + * Copyright 2009 OpenSourceStewardshipFoundation.org 3.6 + * Licensed under GNU General Public License version 2 3.7 + * 3.8 + * Author: seanhalle@yahoo.com 3.9 + * 3.10 + */ 3.11 + 3.12 + 3.13 +#include "SSR_Matrix_Mult.h" 3.14 + 3.15 +/*Divider creates one processor for every row-col pair. 3.16 + * It hands them: 3.17 + * the name of the result processor that they should send their results to, 3.18 + * the left and right matrices, and the row and col they should multiply 3.19 + * the length of the vector 3.20 + * It first creates the result processor, then all the vector processors, 3.21 + * then does a receive of a message from the result processor that gives 3.22 + * the divider ownership of the result matrix. 3.23 + * Finally, the divider returns the result matrix out of the SSR system. 3.24 + */ 3.25 +void divideIntoVectors( void *_dividerParams, VirtProcr *animatingPr ) 3.26 + { VirtProcr *resultPr; 3.27 + DividerParams *dividerParams; 3.28 + ResultsParams *resultsParams; 3.29 + VectorParams *vectParams; 3.30 + Matrix *leftMatrix, *rightMatrix, *resultMatrix; 3.31 + void *msg; 3.32 + 3.33 +// printf("start divide\n"); fflush(stdin); 3.34 + 3.35 + dividerParams = (DividerParams *)_dividerParams; 3.36 + 3.37 + leftMatrix = dividerParams->leftMatrix; 3.38 + rightMatrix = dividerParams->rightMatrix; 3.39 + 3.40 + resultsParams = SSR__malloc_size_to( sizeof(ResultsParams), 3.41 + animatingPr ); 3.42 + resultsParams->dividerPr = animatingPr; 3.43 + resultsParams->numCols = rightMatrix->numCols; 3.44 + resultsParams->numRows = leftMatrix->numRows; 3.45 + 3.46 + resultPr = SSR__create_procr_with(&gatherResults, resultsParams, 3.47 + animatingPr); 3.48 + 3.49 + int row, col; 3.50 + for( row = 0; row < leftMatrix->numRows; row++ ) 3.51 + { for( col = 0; col < rightMatrix->numCols; col++ ) 3.52 + { 3.53 + vectParams = SSR__malloc_size_to(sizeof(VectorParams), 3.54 + animatingPr); 3.55 + vectParams->resultPr = resultPr; 3.56 + vectParams->myCol = col; 3.57 + vectParams->myRow = row; 3.58 + vectParams->vectLength = leftMatrix->numCols; 3.59 + vectParams->leftMatrix = leftMatrix; 3.60 + vectParams->rightMatrix = rightMatrix; 3.61 + 3.62 + SSR__create_procr_with( &calcVector, vectParams, animatingPr ); 3.63 + //vectParams ownership transferred to the newly created processor 3.64 + } 3.65 + } 3.66 + 3.67 + //Get result from result procr 3.68 + msg = SSR__receive_from_to( resultPr, animatingPr ); 3.69 + 3.70 + //prepare results to persist outside of SSR when return from entry pt 3.71 + //The results of the all the work have to be linked-to from the data 3.72 + // struc given to the seed procr -- this divide func is animated by 3.73 + // that seed procr, so have to link results to the _dividerParams. 3.74 + resultMatrix = SSR__malloc_size_to( sizeof(Matrix), 3.75 + animatingPr ); 3.76 + resultMatrix->numCols = rightMatrix->numCols; 3.77 + resultMatrix->numRows = leftMatrix->numRows; 3.78 + dividerParams->resultMatrix = resultMatrix; 3.79 + resultMatrix->matrix = (float32 *) msg; 3.80 + SSR__transfer_ownership_to_outside( msg ); //so not freed 3.81 + SSR__transfer_ownership_to_outside( resultMatrix ); 3.82 + 3.83 + //printf("end divide\n"); fflush(stdin); 3.84 + 3.85 + SSR__dissipate_procr( animatingPr ); //all procrs dissipate self at end 3.86 + //when all of the processors have dissipated, the "create seed and do 3.87 + // work" call in the entry point function returns 3.88 + }
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/src/Application/SSR_Matrix_Mult/EntryPoint.c Tue Oct 05 10:00:11 2010 -0700 4.3 @@ -0,0 +1,48 @@ 4.4 +/* 4.5 + * Copyright 2009 OpenSourceStewardshipFoundation.org 4.6 + * Licensed under GNU General Public License version 2 4.7 + * 4.8 + * Author: seanhalle@yahoo.com 4.9 + * 4.10 + */ 4.11 + 4.12 +#include <math.h> 4.13 + 4.14 +#include "SSR_Matrix_Mult.h" 4.15 + 4.16 + 4.17 + 4.18 +/*Every SSR system has an "entry point" function that creates the first 4.19 + * processor, which starts the chain of creating more processors.. 4.20 + * eventually all of the processors will dissipate themselves, and 4.21 + * return. 4.22 + * 4.23 + *This entry-point function follows the same pattern as all entry-point 4.24 + * functions do: 4.25 + *1) it creates the params for the seed processor, from the 4.26 + * parameters passed into the entry-point function 4.27 + *2) it calls SSR__create_seed_procr_and_do_work 4.28 + *3) it gets the return value from the params struc, frees the params struc, 4.29 + * and returns the value from the function 4.30 + * 4.31 + */ 4.32 +Matrix * 4.33 +multiplyTheseMatrices( Matrix *leftMatrix, Matrix *rightMatrix ) 4.34 + { Matrix *resMatrix; 4.35 + DividerParams *dividerParams; 4.36 + 4.37 + 4.38 + dividerParams = malloc( sizeof( DividerParams ) ); 4.39 + dividerParams->leftMatrix = leftMatrix; 4.40 + dividerParams->rightMatrix = rightMatrix; 4.41 + 4.42 + 4.43 + //create divider processor, start doing the work, and wait till done 4.44 + //This function is the "border crossing" between normal code and SSR 4.45 + SSR__create_seed_procr_and_do_work( ÷IntoVectors, dividerParams ); 4.46 + 4.47 + //get result matrix and return it 4.48 + resMatrix = dividerParams->resultMatrix; 4.49 + free( dividerParams ); 4.50 + return resMatrix; 4.51 + }
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/src/Application/SSR_Matrix_Mult/Result_Pr.c Tue Oct 05 10:00:11 2010 -0700 5.3 @@ -0,0 +1,51 @@ 5.4 +/* 5.5 + * Copyright 2009 OpenSourceStewardshipFoundation.org 5.6 + * Licensed under GNU General Public License version 2 5.7 + * 5.8 + * Author: seanhalle@yahoo.com 5.9 + * 5.10 + */ 5.11 + 5.12 +#include "SSR_Matrix_Mult.h" 5.13 + 5.14 +/*The Result Processor gets a message from each of the vector processors, 5.15 + * puts the result from the message in its location in the result- 5.16 + * matrix, and increments the count of results. 5.17 + * 5.18 + *After the count reaches the point that all results have been received, it 5.19 + * returns the result matrix and dissipates. 5.20 + */ 5.21 +void gatherResults( void *_params, VirtProcr *animatingPr ) 5.22 + { VirtProcr *dividerPr; 5.23 + ResultsParams *params; 5.24 + int numRows, numCols, numCells, count=0; 5.25 + float32 *resultMatrix; 5.26 + void *msg; 5.27 + VectorParams *aResult; 5.28 + 5.29 +// printf("start resultPr\n"); fflush(stdin); 5.30 + 5.31 + params = (ResultsParams *)_params; 5.32 + dividerPr = params->dividerPr; 5.33 + numCols = params->numCols; 5.34 + numRows = params->numRows; 5.35 + numCells = numRows * numCols; 5.36 + 5.37 + resultMatrix = SSR__malloc_size_to( numCells*sizeof( float32 ), animatingPr); 5.38 + 5.39 + while( count < numCells ) 5.40 + { 5.41 + msg = SSR__receive_type_to( RESULTS_MSG, animatingPr ); 5.42 + 5.43 + aResult = (VectorParams *)msg; 5.44 + *(resultMatrix + aResult->myRow * numCols + aResult->myCol) = 5.45 + aResult->result; 5.46 + count++; 5.47 + } 5.48 + //if were real lang, would have auto-nested transfer -- but HelloWorld 5.49 + // language, so have to transfer ownership of each allocated block of 5.50 + // locations separately 5.51 + SSR__transfer_ownership_of_from_to( resultMatrix, animatingPr, dividerPr ); 5.52 + SSR__send_from_to( resultMatrix, animatingPr, dividerPr ); 5.53 + SSR__dissipate_procr( animatingPr ); //frees any data owned by procr 5.54 + }
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/src/Application/SSR_Matrix_Mult/SSR_Matrix_Mult.h Tue Oct 05 10:00:11 2010 -0700 6.3 @@ -0,0 +1,58 @@ 6.4 +/* 6.5 + * Copyright Oct 24, 2009 OpenSourceStewardshipFoundation.org 6.6 + * Licensed under GNU General Public License version 2 6.7 + */ 6.8 + 6.9 +#ifndef _SSR_MATRIX_MULT_H_ 6.10 +#define _SSR_MATRIX_MULT_H_ 6.11 + 6.12 +#include <stdio.h> 6.13 + 6.14 +#include "../../SSR_lib/SSR.h" 6.15 +#include "../Matrix_Mult.h" 6.16 + 6.17 +//============================== Structures ============================== 6.18 +typedef struct 6.19 + { 6.20 + Matrix *leftMatrix; 6.21 + Matrix *rightMatrix; 6.22 + Matrix *resultMatrix; 6.23 + } 6.24 +DividerParams; 6.25 + 6.26 +typedef struct 6.27 + { 6.28 + VirtProcr *dividerPr; 6.29 + int numRows; 6.30 + int numCols; 6.31 + } 6.32 +ResultsParams; 6.33 + 6.34 +typedef struct 6.35 + { VirtProcr *resultPr; 6.36 + int myCol; 6.37 + int myRow; 6.38 + int vectLength; 6.39 + Matrix *leftMatrix; 6.40 + Matrix *rightMatrix; 6.41 + float32 result; 6.42 + } 6.43 +VectorParams; 6.44 + 6.45 +enum MMMsgType 6.46 + { 6.47 + RESULTS_MSG = 1 6.48 + }; 6.49 + 6.50 +//============================= Processor Functions ========================= 6.51 +void divideIntoVectors( void *data, VirtProcr *animatingPr ); 6.52 +void calcVector( void *data, VirtProcr *animatingPr ); 6.53 +void gatherResults( void *data, VirtProcr *animatingPr ); 6.54 + 6.55 + 6.56 +//================================ Entry Point ============================== 6.57 +Matrix * 6.58 +multiplyTheseMatrices( Matrix *leftMatrix, Matrix *rightMatrix ); 6.59 + 6.60 + 6.61 +#endif /*_SSR_MATRIX_MULT_H_*/
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 7.2 +++ b/src/Application/SSR_Matrix_Mult/Vector_Pr.c Tue Oct 05 10:00:11 2010 -0700 7.3 @@ -0,0 +1,47 @@ 7.4 +/* 7.5 + * Copyright 2009 OpenSourceStewardshipFoundation.org 7.6 + * Licensed under GNU General Public License version 2 7.7 + * 7.8 + * Author: SeanHalle@yahoo.com 7.9 + * 7.10 + */ 7.11 + 7.12 +#include "SSR_Matrix_Mult.h" 7.13 + 7.14 +/*A Vector processor is created with an environment that holds two matrices, 7.15 + * the row and col that it owns, and the name of a result gathering 7.16 + * processor. 7.17 + *It calculates its vector product then sends the result to the result 7.18 + * processor, which puts it into the result matrix and returns that matrix 7.19 + * when all is done. 7.20 + */ 7.21 + void 7.22 +calcVector( void *data, VirtProcr *animatingPr ) 7.23 + { 7.24 + VectorParams *params; 7.25 + VirtProcr *resultPr; 7.26 + int myRow, myCol, vectLength, pos; 7.27 + float32 *leftMatrixArray, *rightMatrixArray, result = 0.0; 7.28 + Matrix *leftMatrix, *rightMatrix; 7.29 + 7.30 +// printf("start vector\n"); fflush(stdin); 7.31 + 7.32 + params = (VectorParams *)data; 7.33 + resultPr = params->resultPr; 7.34 + myCol = params->myCol; 7.35 + myRow = params->myRow; 7.36 + vectLength = params->vectLength; 7.37 + leftMatrix = params->leftMatrix; 7.38 + rightMatrix = params->rightMatrix; 7.39 + leftMatrixArray = leftMatrix->matrix; 7.40 + rightMatrixArray = rightMatrix->matrix; 7.41 + 7.42 + for( pos = 0; pos < vectLength; pos++ ) 7.43 + { 7.44 + result += *(leftMatrixArray + myRow * vectLength + pos) * 7.45 + *(rightMatrixArray + pos * vectLength + myCol); 7.46 + } 7.47 + params->result = result; 7.48 + SSR__send_of_type_to( animatingPr, params, RESULTS_MSG, resultPr ); 7.49 + SSR__dissipate_procr( animatingPr ); 7.50 + }
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/src/Application/main.c Tue Oct 05 10:00:11 2010 -0700 8.3 @@ -0,0 +1,34 @@ 8.4 +/* 8.5 + * Copyright Oct 24, 2009 OpenSourceStewardshipFoundation.org 8.6 + * Licensed under GNU General Public License version 2 8.7 + * 8.8 + * author seanhalle@yahoo.com 8.9 + */ 8.10 + 8.11 +#include <malloc.h> 8.12 +#include <stdlib.h> 8.13 + 8.14 +#include "Matrix_Mult.h" 8.15 +#include "SSR_Matrix_Mult/SSR_Matrix_Mult.h" 8.16 + 8.17 +/** 8.18 + *Matrix multiply program written using VMS_HW piggy-back language 8.19 + * 8.20 + */ 8.21 +int main( int argc, char **argv ) 8.22 + { Matrix *leftMatrix, *rightMatrix, *resultMatrix; 8.23 + ParamBag *paramBag; 8.24 + 8.25 + paramBag = makeParamBag(); 8.26 + readParamFileIntoBag( argv[1], paramBag ); 8.27 + initialize_Input_Matrices_Via( &leftMatrix, &rightMatrix, paramBag ); 8.28 + 8.29 + resultMatrix = multiplyTheseMatrices( leftMatrix, rightMatrix ); 8.30 + 8.31 + printf("\nresult matrix: \n"); 8.32 + printMatrix( resultMatrix ); 8.33 + 8.34 +// SSR__print_stats(); 8.35 + 8.36 + exit(0); //cleans up 8.37 + }
