view Matrix_Mult.h @ 29:8972c00c00dd

Merge with perf_tuning_paper branch, which grabs fixes and best performing version
author Sean Halle <seanhalle@yahoo.com>
date Sun, 15 Jul 2012 01:27:39 -0700
parents 1461ed1901cc
children
line source
1 /*
2 * Copyright Oct 24, 2009 OpenSourceStewardshipFoundation.org
3 * Licensed under GNU General Public License version 2
4 */
6 #ifndef MATRIX_MULT_H_
7 #define MATRIX_MULT_H_
9 #include <stdio.h>
10 #include <unistd.h>
11 #include <malloc.h>
13 #include "VMS_impl/VMS_primitive_data_types.h"
14 #include "ParamHelper/Param.h"
16 //============================== Structures ==============================
18 typedef struct
19 { int32 numRows;
20 int32 numCols;
21 float32 *array; //2D, but dynamically sized, so use addr arith
22 }
23 Matrix;
25 /* This is the "appSpecificPiece" that is carried inside a DKUPiece.
26 * In the DKUPiece data struc it is declared to be of type "void *". This
27 * allows the application to define any data structure it wants and put it
28 * into a DKUPiece.
29 * When the app specific info is used, it is in app code, so it is cast to
30 * the correct type to tell the compiler how to access fields.
31 * This keeps all app-specific things out of the DKU directory, as per the
32 * DKU standard. */
33 typedef struct
34 {
35 // pointers to shared data.. the result matrix must be created when the
36 // left and right matrices are put into the root ancestor DKUPiece.
37 Matrix * leftMatrix;
38 Matrix * rightMatrix;
39 Matrix * resultMatrix;
41 // define the starting and ending boundaries for this piece of the
42 // result matrix. These are derivable from the left and right
43 // matrices, but included them for readability of code.
44 int prodStartRow, prodEndRow;
45 int prodStartCol, prodEndCol;
46 // Start and end of the portion of the left matrix that contributes to
47 // this piece of the product
48 int leftStartRow, leftEndRow;
49 int leftStartCol, leftEndCol;
50 // Start and end of the portion of the right matrix that contributes to
51 // this piece of the product
52 int rightStartRow, rightEndRow;
53 int rightStartCol, rightEndCol;
54 }
55 MatrixProdPiece;
57 //============================== Functions ================================
58 void readFile();
60 Matrix *makeMatrix( int32 numRows, int32 numCols );
61 Matrix *makeMatrix_Flat( int32 numRows, int32 numCols );
62 Matrix *makeMatrix_WithResMat( int32 numRows, int32 numCols );
63 void freeMatrix_Flat( Matrix * matrix );
64 void freeMatrix( Matrix * matrix );
65 void printMatrix( Matrix *matrix );
67 void read_Matrix_From_File( Matrix *matrixStruc, char *matrixFileName );
69 void
70 initialize_Input_Matrices_Via( Matrix **leftMatrix, Matrix **rightMatrix,
71 ParamBag *paramBag );
73 //===========================================================================
75 #endif /*MATRIX_MULT_H_*/