- gras_msg_send(socket[j],gras_msgtype_by_name("init_data"),&mydata);
- j++;
- } // end init Data Send
-
- /******************************* multiplication ********************************/
- INFO0("begin Multiplication");
- for (step=1; step <= MATRIX_SIZE; step++){
- for (i=0; i< SENSOR_NBR; i++){
- TRY {
- gras_msg_send(socket[i], gras_msgtype_by_name("step"), &step); /* initialize Mycol, MyRow, mydataA,mydataB*/
- // myrow,mycol,mydataA,mydataB
- } CATCH(e) {
- gras_socket_close(socket[i]);
- RETHROW0("Unable to send the msg : %s");
- }
- }
- INFO1("send to sensor to begin a %d th step",step);
- /* wait for computing and sensor messages exchange */
- i=0;
- while ( i< SENSOR_NBR){
- TRY {
- gras_msg_wait(600,gras_msgtype_by_name("step_ack"),&from,&mydata);
- } CATCH(e) {
- RETHROW0("I Can't get a init Data message from Maestro : %s");
- }
- i++;
- INFO1("Recive Ack step ack from %s",gras_socket_peer_name(from));
- }
- }
- /********************************* gather ***************************************/
-
- ask_result=0;
- for( i=1;i< argc;i++){
- gras_msg_send(socket[i],gras_msgtype_by_name("ask_result"),&ask_result);
- INFO1("Send (Ask Result) message to %s",gras_socket_peer_name(socket[i]));
- }
- /* wait for results */
- for( i=1;i< argc;i++){
- gras_msg_wait(600,gras_msgtype_by_name("result"),&from,&result);
- C.data[(result.i-1)*MATRIX_SIZE+(result.j-1)]=result.value;
- }
- /* end of gather */
- INFO0 ("The Result of Multiplication is :");
- display(C);
-
-return 0;
-} /* end_of_maestro */
+ gras_msg_send(socket[i],gras_msgtype_by_name("assignment"),&assignment);
+ xbt_matrix_free(assignment.A);
+ xbt_matrix_free(assignment.B);
+ }
+ // end assignment
+
+ /******************************* multiplication ********************************/
+ /* wait for results */
+ for( i=0;i< SLAVE_COUNT;i++){
+ gras_msg_wait(6000,gras_msgtype_by_name("result"),&from,&result);
+ xbt_matrix_copy_values(C,result.C, submatrix_size,submatrix_size,
+ submatrix_size*result.linepos,
+ submatrix_size*result.rowpos,
+ 0,0,NULL);
+ xbt_matrix_free(result.C);
+ }
+ /* end of gather */
+ if (DATA_MATRIX_SIZE < 50) {
+ INFO0 ("The Result of Multiplication is :");
+ xbt_matrix_dump(C,"C:res",0,xbt_matrix_dump_display_double);
+ } else {
+ INFO1("Matrix size too big (%d>50) to be displayed here",DATA_MATRIX_SIZE);
+ }
+
+ for(i=0; i<SLAVE_COUNT; i++) {
+ gras_socket_close(socket[i]);
+ xbt_host_free(grid[i]);
+ }
+
+ xbt_matrix_free(A);
+ xbt_matrix_free(B);
+ xbt_matrix_free(C);
+ gras_exit();
+ return 0;
+} /* end_of_master */