Syntax:
Die Größe sämtlicher Felder muß der Anzahl der Elemente in der Gruppe entsprechen. Das Ergebnis eines Aufrufs von MPI_Alltoallv ist dasselbe, wie wenn jeder Prozeß an jeden sendet und von jedem empfängt mit:
MPI_Send(sendbuf+sdispls[i]*extent(sendtype), scounts[i], sendtype, i, ...) MPI_Recv(recvbuf+rdispls[i]*extent(recvtype), rcounts[i], recvtype, i, ...)Die Datenmengen zwischen Sender und Empfänger müssen paarweise übereinstimmen, ebenso die Reihenfolge der Basisdatentypen.
Aufruf:
#include "mpi.h"
...
int numprocs;
int *scounts, *rcounts, *sdispls, *rdispls;
void *sendbuf, *recvbuf;
MPI_Datatype sendtype, recvtype;
MPI_Comm comm;
...
MPI_Comm_size(comm, &numprocs);
...
scounts=(* int)malloc(numprocs*sizeof(int));
sdispls=(* int)malloc(numprocs*sizeof(int));
rcounts=(* int)malloc(numprocs*sizeof(int));
rdispls=(* int)malloc(numprocs*sizeof(int));
for (i=0; i<numprocs; i++) {
scounts[i]= ...
sdispls[i]= ...
rcounts[i]= ...
rdispls[i]= ...
}
MPI_Alltoallv(sendbuf, scounts, sdispls, sendtype,
recvbuf, rcounts, rdispls, recvtype,
comm);
...