[MPICH] Problem with MPI_Gather
Jonathan Patterson
jo at jo.net
Fri Dec 14 13:39:35 CST 2007
Hello!
I've recently put mpich2-1.0.6p1 on a machine running Scientific Linux 5.0.
One of my users is having a problem with MPI_Gather - it's working fine for
<7 processes, but anything more and the MPI_Gather function seems to mess up
the ordering of the data coming back from the non-root processes. The
resulting memory does not therefore contain what it should - the gathering of
data has got jumbled up. The error happens regardless of wether all processes
are on the same machine, or each are on a seperate machine.
The test programs included with mpich2 for allgather do work, but they use
MPI_Type_vector to make a different datatype for the call to MPI_Gather. From
the documentation, though, this doesn't seem needed.
I've put together a program to reproduce the problem, which works fine with
the original mpich (ie. not mpich2).
My question is basically this - should the below program work? Am I using the
right method to gather the data? Because it doesn't work - for anything >7
processes, it fails to gather the data properly. Though if you reduce
DATASIZE enough, it works.
Any help gratefully appreciated!
#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
#define DATASIZE 500
#define MAX_PROCESSES 20
// -----------------------------------------------------------------------
MAIN
int main(int argc,char *argv[])
{
int myid,np;
MPI_Init (&argc,&argv);
MPI_Comm_rank(MPI_COMM_WORLD,&myid);
MPI_Comm_size(MPI_COMM_WORLD,&np);
printf("I am %i of %i\n",myid+1,np);
fflush(stdout);
MPI_Barrier(MPI_COMM_WORLD);
// Test MPI_Gather
int fakeData[DATASIZE];
int recvData[DATASIZE*MAX_PROCESSES];
int c;
// Initialise fake data
for(c=0;c<DATASIZE;c++) { fakeData[c]=c+(myid*DATASIZE); };
for(c=0;c<DATASIZE*MAX_PROCESSES;c++) { recvData[c]=-1; };
printf("%i: Sending %i -> %i\n",myid,fakeData[0],fakeData[DATASIZE-1]);
MPI_Gather(fakeData,DATASIZE,MPI_INT,recvData,DATASIZE,MPI_INT,0,MPI_COMM_WORLD);
MPI_Barrier(MPI_COMM_WORLD);
if (myid==0)
{ printf("Checking...\n");
for(c=0;c<DATASIZE*np;c++)
{ if (recvData[c]!=c) { printf("%i=%i ",c,recvData[c]);
fflush(stdout); };
};
printf("Check done.\n"); fflush(stdout);
};
fflush(stdout);
MPI_Finalize();
}
More information about the mpich-discuss
mailing list