+ /* Assign a sub matrix of A and B to the job */
+ jobs[node]->A =
+ xbt_matrix_new_sub(A, NODE_MATRIX_SIZE, NODE_MATRIX_SIZE,
+ NODE_MATRIX_SIZE * row, NODE_MATRIX_SIZE * col,
+ NULL);
+ jobs[node]->B =
+ xbt_matrix_new_sub(B, NODE_MATRIX_SIZE, NODE_MATRIX_SIZE,
+ NODE_MATRIX_SIZE * row, NODE_MATRIX_SIZE * col,
+ NULL);
+
+ if (++col >= GRID_SIZE){
+ col = 0;
+ row++;
+ }
+ }
+}
+
+static void receive_results(result_t *results){
+ int node;
+ msg_comm_t comms[GRID_NUM_NODES-1] = {0};
+ m_task_t tasks[GRID_NUM_NODES-1] = {0};
+
+ XBT_VERB("Receive Results.");
+
+ /* Get the result from the nodes in the GRID */
+ for (node = 1; node < GRID_NUM_NODES; node++){
+ comms[node-1] = MSG_task_irecv(&tasks[node-1], "0");
+ }
+
+ MSG_comm_waitall(comms, GRID_NUM_NODES - 1, -1);
+
+ /* Reconstruct the result matrix */
+ for (node = 1; node < GRID_NUM_NODES; node++){
+ results[node] = (result_t)MSG_task_get_data(tasks[node-1]);
+ MSG_task_destroy(tasks[node-1]);
+ }
+}