Using mpi.h in C, with 4 processors, each processor has allocated a buffer (integer) of 8 elements, and another array (p) of 6 elements.
I initialize each p array of each processor in a way that it contains an increasing sequence of numbers (processor 0 has 0,1,2,3,4,5 ; processor 2 has 6,7,etc…).
Now I want to use MPI_Alltoallv to send each piece of the matrix in an unique array (buffer), but since the matric is 4×6, I want to send 8 elements to processor 0, 8 elements to processor 1, 4 elements to processor 2 and 4 elements to processor 3.
So i tried to do that in my code, which I link:
But it fails to achieve what I want to do: it just receive in buffer a 4×4 matrix, ignoring elements of index bigger than 4.
According to specification of alltoallv:
sendcountsinteger array equal to the group size specifying the number of elements to send to each processorso you should set send buffer different for each processor
say
and displacement array accordingly.
Currently you have setted each value as 1, so all processors are getting 1 value from each processor. Thus 4 values in all.