Here's how my code should work. Slave nodes will perform some computations, and each node will send a value, minE with a corresponding linear array, phi. Root node will then receive, 2 values. I'm trying to figure out on how I will store N-1 (number of slaves) phi in root node. I tried accepting phi in a 2D array but it doesn't work. Or maybe, I'm doing it wrong. So this code simply receives the values of phi from the last node to send.
if (world_rank == root) {
for(i=1; i<world_size; i++) {
MPI_Irecv(&local_minE[i], 1, MPI_FLOAT, MPI_ANY_SOURCE, 1, MPI_COMM_WORLD, &rcv_request[i]);
MPI_Irecv(phi, len, MPI_INT, MPI_ANY_SOURCE, 1, MPI_COMM_WORLD, &rcv_request[i]);
MPI_Waitall(world_size-1, &rcv_request[1], &status[1]);
}
MPI_Waitall(world_size-1, &rcv_request[1], &status[1]);
}
else {
//after computations, node will send a value, minE with a corresponding array phi
MPI_Isend(&minE, 1, MPI_FLOAT, 0, 1, MPI_COMM_WORLD,&send_request[0]);
MPI_Isend(phi, len, MPI_INT, root, 1, MPI_COMM_WORLD, &send_request[0]);
MPI_Wait(&send_request[0], &status[0]);
}