comparison 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
comparison
equal deleted inserted replaced
0:0d7f42c6c623 1:56c459606eb1
9 9
10 // ============================================================================= 10 // =============================================================================
11 11
12 int NUM_ITER; 12 int NUM_ITER;
13 13
14 MatrixMultGlobals *globals;
15 14
16 int main(int argc, char **argv) 15 int main(int argc, char **argv)
17 { Matrix *leftMatrix, *rightMatrix, *resultMatrix; 16 { Matrix *leftMatrix, *rightMatrix, *resultMatrix;
18 ParamBag *paramBag; 17 ParamBag *paramBag;
18 MatrixMultWorkUnit **workUnits;
19 VPParams *vpParams, **vpParamsArray;
20 // ProdParams *prodParams;
21 // ConsParams *consParams;
22 int32 numUnitsToMake, vpIdx;
23 PRProcess *matrixMultProcess;
19 24
20 DEBUG__printf(TRUE, "arguments: %s | %s", argv[0], argv[1]); 25 DEBUG__printf(TRUE, "arguments -- numIter: %s | path: %s", argv[1], argv[2] );
21 if(argc < 3) {printf("give num iter and path to param file on cmd line\n"); exit(1);} 26 if(argc < 3) {printf("give: num iter and path to param file on cmd line\n"); exit(1);}
22 NUM_ITER = atoi(argv[1]); 27 NUM_ITER = atoi(argv[1]);
28 numUnitsToMake = NUM_PROD; //defined by Reo circuit generator
29
30 printf("[reo] Settings: %i workers, %i iterations | file: %s \n", NUM_PROD, NUM_ITER, argv[2]);
31
32 set_up_performance_counters();
23 33
24 //read parameters, from file whose path is given on command line 34 //read parameters, from file whose path is given on command line
25 paramBag = makeParamBag(); 35 paramBag = makeParamBag();
26 readParamFileIntoBag( argv[2], paramBag ); 36 readParamFileIntoBag( argv[2], paramBag );
27 initialize_Input_Matrices_Via( &leftMatrix, &rightMatrix, paramBag ); 37 initialize_Input_Matrices_Via( &leftMatrix, &rightMatrix, paramBag );
28 38
29 39
30 printf("[reo] Settings: %i workers, %i iterations -- ", NUM_PROD, NUM_ITER); 40 PR__start();
31 41 PR__set_app_info( "matrix multiply prod cons in Reo" );
32 set_up_performance_counters(); 42 ParamStruc *inputInfo = getParamFromBag( "inputInfo", paramBag );
33 43 PR__set_input_info( inputInfo->strValue );
34 PRProcess *matrixMultProcess;
35 PR_Main__start();
36 PR_Main__set_app_info( "matrix multiply prod cons in Reo" );
37 44
38 PR_Main__set_input_info( getParamFromBag( "inputInfo", paramBag ) ); 45 resultMatrix = PR__malloc( sizeof(Matrix) );
39 46 resultMatrix->array = PR__malloc( leftMatrix->numRows * rightMatrix->numCols * sizeof(double) );
40 params->resultMatrix = malloc( numRows * numCols * sizeof(double) ); 47 resultMatrix->numCols = rightMatrix->numCols;
41 params->workUnits = divideWork( leftInput, rightInput, numUnitsToMake ); 48 resultMatrix->numRows = leftMatrix->numRows;
42 49 workUnits = divideWork( leftMatrix, rightMatrix, resultMatrix,
43 matrixMultProcess = PR_Main__create_process(&matrix_mult__seed_Fn, params); 50 numUnitsToMake );
44 51
45 PR_Main__wait_for_process_to_end(matrixMultProcess); 52 /* For now, don't need any params inside producer function other than
46 PR__Main__wait_for_all_activity_to_end(); 53 * the work unit. Also, don't need any params at all inside cons function.
54 * So, just send the array of work units to the seed Fn, which will pass it
55 * along to the create_VP part of circuit creation, which will copy the
56 * elements of the array into the param structs given as initData to the
57 * VPs, as they are created.
58 *Need a dummy work unit added to end of work-unit array, to avoid a seg
59 * fault -- just did a bad hack inside divideWork.
60 //Now, create params struct for each producer -- holds work unit
61 for( vpIdx=0; vpIdx<numUnitsToMake; vpIdx++)
62 {
63 vpParams = PR__malloc( sizeof(VPParams) );
64 prodParams = PR__malloc( sizeof(ProdParams) );
65
66 vpParams->initData = prodParams;
67 vpParamsArray[vpIdx] = vpParams;
68 }
69 //create params for consumer
70
71 vpParams = PR__malloc( sizeof(VPParams) );
72 = malloc( sizeof(ProdParams) );
73
74 vpParams->initData =
75 vpParamsArray[vpIdx] = vpParams; //this last entry is for the consumer
76 */
77
78 matrixMultProcess = PR__create_process( &matrix_mult__seed_Fn,
79 workUnits );
80
81 PR__wait_for_process_to_end(matrixMultProcess);
82 PR__wait_for_all_activity_to_end();
47 fflush(stdout); 83 fflush(stdout);
48 PR_Main__shutdown(); 84 PR__shutdown();
49 85
50 exit(0); 86 exit(0);
51 } 87 }
52 88
53 // ============================================================================= 89 // =============================================================================