I have a distributed matrix over 4 nodes and I want every node to send its part of the matrix and also receive, one at a time, every other part of the matrix from other nodes. The block matrices have different dimensions.
I tried to write some code, but it's not working as expected.
/* send my part of the matrix */
for (int i = 0; i < numtasks; i++){
if (i == taskid) continue;
MPI_Isend(matrix_block, size, MPI_INT, i, 0,
MPI_COMM_WORLD, &rNull);
}
/* receive everyone's part of the matrix */
for (int i = 0; i < numtasks; i++){
if (i == taskid) continue;
MPI_Irecv(brec, lenghts_recv[i], MPI_INT, i, 0,
MPI_COMM_WORLD, &request[i]);
}
for (int i = 0; i < numtasks - 1; i++){
int index;
MPI_Waitany(numtasks-1, request, &index, &status);
}
I supposed every node will first send the block it has and after that it will receive what has been send to him by other nodes, but obviously something it's wrong.
Also, solutions like MPI_Alltoall do not work in my case because the matrix it's supposed to be huge and it won't fit inside one node.
Can you suggest me a way of performing the all to all operation but with one part of the matrix at a time?