Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > VReo > Reo__Matrix_Mult
diff main.c @ 1:1b61e0c00512
almost working k=3, about to change to k=4
| author | Sean Halle <seanhalle@yahoo.com> |
|---|---|
| date | Wed, 19 Feb 2014 09:27:10 -0800 |
| parents | c4b1849c05ef |
| children | 96deb7b4502e a6b3cab179b1 |
line diff
1.1 --- a/main.c Sun Feb 02 17:58:41 2014 -0800 1.2 +++ b/main.c Wed Feb 19 09:27:10 2014 -0800 1.3 @@ -11,15 +11,25 @@ 1.4 1.5 int NUM_ITER; 1.6 1.7 -MatrixMultGlobals *globals; 1.8 1.9 int main(int argc, char **argv) 1.10 { Matrix *leftMatrix, *rightMatrix, *resultMatrix; 1.11 ParamBag *paramBag; 1.12 + MatrixMultWorkUnit **workUnits; 1.13 + VPParams *vpParams, **vpParamsArray; 1.14 +// ProdParams *prodParams; 1.15 +// ConsParams *consParams; 1.16 + int32 numUnitsToMake, vpIdx; 1.17 + PRProcess *matrixMultProcess; 1.18 1.19 - DEBUG__printf(TRUE, "arguments: %s | %s", argv[0], argv[1]); 1.20 - if(argc < 3) {printf("give num iter and path to param file on cmd line\n"); exit(1);} 1.21 + DEBUG__printf(TRUE, "arguments -- numIter: %s | path: %s", argv[1], argv[2] ); 1.22 + if(argc < 3) {printf("give: num iter and path to param file on cmd line\n"); exit(1);} 1.23 NUM_ITER = atoi(argv[1]); 1.24 + numUnitsToMake = NUM_PROD; //defined by Reo circuit generator 1.25 + 1.26 + printf("[reo] Settings: %i workers, %i iterations | file: %s \n", NUM_PROD, NUM_ITER, argv[2]); 1.27 + 1.28 + set_up_performance_counters(); 1.29 1.30 //read parameters, from file whose path is given on command line 1.31 paramBag = makeParamBag(); 1.32 @@ -27,25 +37,51 @@ 1.33 initialize_Input_Matrices_Via( &leftMatrix, &rightMatrix, paramBag ); 1.34 1.35 1.36 - printf("[reo] Settings: %i workers, %i iterations -- ", NUM_PROD, NUM_ITER); 1.37 - 1.38 - set_up_performance_counters(); 1.39 - 1.40 - PRProcess *matrixMultProcess; 1.41 - PR_Main__start(); 1.42 - PR_Main__set_app_info( "matrix multiply prod cons in Reo" ); 1.43 + PR__start(); 1.44 + PR__set_app_info( "matrix multiply prod cons in Reo" ); 1.45 + ParamStruc *inputInfo = getParamFromBag( "inputInfo", paramBag ); 1.46 + PR__set_input_info( inputInfo->strValue ); 1.47 1.48 - PR_Main__set_input_info( getParamFromBag( "inputInfo", paramBag ) ); 1.49 - 1.50 - params->resultMatrix = malloc( numRows * numCols * sizeof(double) ); 1.51 - params->workUnits = divideWork( leftInput, rightInput, numUnitsToMake ); 1.52 - 1.53 - matrixMultProcess = PR_Main__create_process(&matrix_mult__seed_Fn, params); 1.54 + resultMatrix = PR__malloc( sizeof(Matrix) ); 1.55 + resultMatrix->array = PR__malloc( leftMatrix->numRows * rightMatrix->numCols * sizeof(double) ); 1.56 + resultMatrix->numCols = rightMatrix->numCols; 1.57 + resultMatrix->numRows = leftMatrix->numRows; 1.58 + workUnits = divideWork( leftMatrix, rightMatrix, resultMatrix, 1.59 + numUnitsToMake ); 1.60 1.61 - PR_Main__wait_for_process_to_end(matrixMultProcess); 1.62 - PR__Main__wait_for_all_activity_to_end(); 1.63 +/* For now, don't need any params inside producer function other than 1.64 + * the work unit. Also, don't need any params at all inside cons function. 1.65 + * So, just send the array of work units to the seed Fn, which will pass it 1.66 + * along to the create_VP part of circuit creation, which will copy the 1.67 + * elements of the array into the param structs given as initData to the 1.68 + * VPs, as they are created. 1.69 + *Need a dummy work unit added to end of work-unit array, to avoid a seg 1.70 + * fault -- just did a bad hack inside divideWork. 1.71 + //Now, create params struct for each producer -- holds work unit 1.72 + for( vpIdx=0; vpIdx<numUnitsToMake; vpIdx++) 1.73 + { 1.74 + vpParams = PR__malloc( sizeof(VPParams) ); 1.75 + prodParams = PR__malloc( sizeof(ProdParams) ); 1.76 + 1.77 + vpParams->initData = prodParams; 1.78 + vpParamsArray[vpIdx] = vpParams; 1.79 + } 1.80 + //create params for consumer 1.81 + 1.82 + vpParams = PR__malloc( sizeof(VPParams) ); 1.83 + = malloc( sizeof(ProdParams) ); 1.84 + 1.85 + vpParams->initData = 1.86 + vpParamsArray[vpIdx] = vpParams; //this last entry is for the consumer 1.87 +*/ 1.88 + 1.89 + matrixMultProcess = PR__create_process( &matrix_mult__seed_Fn, 1.90 + workUnits ); 1.91 + 1.92 + PR__wait_for_process_to_end(matrixMultProcess); 1.93 + PR__wait_for_all_activity_to_end(); 1.94 fflush(stdout); 1.95 - PR_Main__shutdown(); 1.96 + PR__shutdown(); 1.97 1.98 exit(0); 1.99 }
