One of our users makes use of the MPI_IN_PLACE option, but there appears to be 
a bug in the MPI_Alltoall.  According to the specification -


The “in place” option for intracommunicators is specified by passing 
MPI_IN_PLACE to
the argument sendbuf at all processes. In such a case, sendcount and sendtype 
are ignored.
The data to be sent is taken from the recvbuf and replaced by the received 
data. Data sent
and received must have the same type map as specified by recvcount and recvtype.

The application fails with 


[prod-0002:12156] *** An error occurred in MPI_Alltoall
[prod-0002:12156] *** on communicator MPI_COMM_WORLD
[prod-0002:12156] *** MPI_ERR_ARG: invalid argument of some other kind
[prod-0002:12156] *** MPI_ERRORS_ARE_FATAL (your MPI job will now abort)

The file below shows the potential bug:

================================================================================================================

//
//  test program for the potential invalid argument bug
//
//  David Race
//  18 Jan 2012
//

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
//
//  mpi
//
#include "mpi.h"
#define  MAX_SIZE 32
//
//
//
int main ( int argc, char *argv[] )
{
        //
        //  definitions
        //
        int     mpierror, isize, myRank; 
        int     typeSize;
        int     valA[MAX_SIZE], valB[MAX_SIZE];
        int     i, j;
        int     commRoot;
        //
        //  start processing
        //
        printf("Start of program\n");
        printf("SIZE OF VALA %ld\n",sizeof(valA));

        mpierror = MPI_Init ( &argc, &argv );
        mpierror = MPI_Comm_rank ( MPI_COMM_WORLD, &myRank );
        mpierror = MPI_Comm_size ( MPI_COMM_WORLD, &isize );
        MPI_Barrier(MPI_COMM_WORLD);
        //
        //  test the mpi_type_size using MPI_Alltoall
        //
        if (myRank == 0) {
                
printf("=====================================================\n");
                printf("               Alltoall : Should work                
\n");
                
printf("=====================================================\n");
        }
        fflush(stdout);
        for(i=0;i<isize;i++) {
                valA[i] = i;
                valB[i] = -1;
        }
        commRoot = 0;
        MPI_Barrier(MPI_COMM_WORLD);
        mpierror = MPI_Alltoall(valA, 1, MPI_INT, valB, 1, MPI_INT, 
MPI_COMM_WORLD);
        MPI_Barrier(MPI_COMM_WORLD);
        for (j=0;j<isize;j++) {
                MPI_Barrier(MPI_COMM_WORLD);
                if (myRank == j) {
                        for(i=0;i<isize;i++) printf("ALLTOALL NODE %d\tValue 
from node %d is %d\n",myRank, i, valA[i]);
                }
                fflush(stdout);
        }
        //
        //  test the mpi_type_size using MPI_Alltoall
        //
        MPI_Barrier(MPI_COMM_WORLD);
        if (myRank == 0) {
                
printf("=====================================================\n");
                printf("                Alltoall : ????                      
\n");
                
printf("=====================================================\n");
        }
        fflush(stdout);
        for(i=0;i<isize;i++) valA[i] = i;
        commRoot = 0;
        MPI_Barrier(MPI_COMM_WORLD);
        //
        //  The error occurs here
        //
        mpierror = MPI_Alltoall(MPI_IN_PLACE, 1, MPI_INT, valA, 1, MPI_INT, 
MPI_COMM_WORLD);
        MPI_Barrier(MPI_COMM_WORLD);
        if (myRank == 0) {
                for(i=0;i<isize;i++) printf("ALLTOALL NODE %d\tValue from node 
%d is %d\n",myRank, i,valA[i]);
        }
        fflush(stdout);
        MPI_Barrier(MPI_COMM_WORLD);
        if (myRank == 1) {
                for(i=0;i<isize;i++) printf("ALLTOALL NODE %d\tValue from node 
%d is %d\n",myRank, i, valA[i]);
        }
        fflush(stdout);
        MPI_Barrier(MPI_COMM_WORLD);
        //
        //  test the mpi_type_size using MPI_Alltoall
        //
        if (myRank == 0) {
                
printf("=====================================================\n");
                printf("       Alltoall : Failure with some MPI              
\n");
                
printf("=====================================================\n");
        }
        fflush(stdout);
        for(i=0;i<isize;i++) valA[i] = i;
        commRoot = 0;
        MPI_Barrier(MPI_COMM_WORLD);
        //
        //  The error occurs here
        //
        mpierror = MPI_Alltoall(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL, valA, 1, 
MPI_INT, MPI_COMM_WORLD);
        MPI_Barrier(MPI_COMM_WORLD);
        if (myRank == 0) {
                for(i=0;i<isize;i++) printf("ALLTOALL NODE %d\tValue from node 
%d is %d\n",myRank, i,valA[i]);
        }
        fflush(stdout);
        MPI_Barrier(MPI_COMM_WORLD);
        if (myRank == 1) {
                for(i=0;i<isize;i++) printf("ALLTOALL NODE %d\tValue from node 
%d is %d\n",myRank, i, valA[i]);
        }
        fflush(stdout);
        MPI_Barrier(MPI_COMM_WORLD);
        mpierror = MPI_Finalize();
        fflush(stdout);
        printf("End of Program\n");

}

Reply via email to