- /* Create and load the arguments to alltoallv */
- sendcounts = (int *)malloc( size * sizeof(int) );
- recvcounts = (int *)malloc( size * sizeof(int) );
- rdispls = (int *)malloc( size * sizeof(int) );
- sdispls = (int *)malloc( size * sizeof(int) );
- sendtypes = (MPI_Datatype *)malloc( size * sizeof(MPI_Datatype) );
- recvtypes = (MPI_Datatype *)malloc( size * sizeof(MPI_Datatype) );
- if (!sendcounts || !recvcounts || !rdispls || !sdispls || !sendtypes || !recvtypes) {
- fprintf( stderr, "Could not allocate arg items!\n" );
- MPI_Abort( comm, 1 );
- }
- /* Note that process 0 sends no data (sendcounts[0] = 0) */
- for (i=0; i<size; i++) {
- sendcounts[i] = i;
- sdispls[i] = (((i+1) * (i))/2) * sizeof(int);
- sendtypes[i] = MPI_INT;
- recvcounts[i] = rank;
- rdispls[i] = i * rank * sizeof(int);
- recvtypes[i] = MPI_INT;
- }
- MPI_Alltoallw( sbuf, sendcounts, sdispls, sendtypes,
- rbuf, recvcounts, rdispls, recvtypes, comm );
-
- /* Check rbuf */
- for (i=0; i<size; i++) {
- p = rbuf + rdispls[i]/sizeof(int);
- for (j=0; j<rank; j++) {
- if (p[j] != i * 100 + (rank*(rank+1))/2 + j) {
- fprintf( stderr, "[%d] got %d expected %d for %dth\n",
- rank, p[j],(i*(i+1))/2 + j, j );
- err++;
- }
- }
- }
+ /* Check rbuf */
+ for (i = 0; i < size; i++) {
+ p = rbuf + rdispls[i] / sizeof(int);
+ for (j = 0; j < rank; j++) {
+ if (p[j] != i * 100 + (rank * (rank + 1)) / 2 + j) {
+ fprintf(stderr, "[%d] got %d expected %d for %dth\n",
+ rank, p[j], (i * (i + 1)) / 2 + j, j);
+ err++;
+ }
+ }
+ }