MPI send/recv bug

David Skinner <[email protected]>
Newsgroups gmane.network.myrinet.general
Message-ID <[email protected]>
Hi,

Anyone else experiencing the following bug?

MPI_Send/Recv work from statically allocated memory but are unreliable 
from dynamically allocated memory.

test case:

MPI task 0 sends a vector of doubles to all other tasks for a variety of 
vector lengths. The following code works fine compiled with statically 
allocated memory, but fails when compiled with -DMALLOC  for message 
length in and around 16053. I find no errors running the code either way 
on a variety of other Linux/mpich setups.

software levels: mpich/1.2.1..7/gm-1.5_Linux_beta3-2.4.13-ac2

Is this a known issue with GM? Any help appreciated.

Regards,

David Skinner

sndrcv.c

#include <stdio.h>
#include <mpi.h>

#define MAXDATA 50000

int main (int argc, char *argv[]) {
 int     i,j;
 int     rank,size;
 int     ndata,maxdata,niter,maxiter;
 int     bad_start,bad_end,bad_last;

#ifdef MALLOC
 double *data;
#else
 double data[MAXDATA];
#endif
 MPI_Status ierr;

 MPI_Init(&argc,&argv);
 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 MPI_Comm_size(MPI_COMM_WORLD, &size);

 maxdata = MAXDATA;
 maxiter = 2;

 for(ndata=0;ndata<maxdata;ndata++) {
  printf("starting ndata=%d\n",ndata);

#ifdef MALLOC
  data = (double *)malloc(ndata*sizeof(double));
#endif

  for(niter=0;niter<maxiter;niter++) {
   bad_start = bad_end = -1;
   if(!rank) {
    for(i=0;i<ndata;i++) data[i] = niter;
    for(j=1; j<size; j++)
    MPI_Send(data,ndata,MPI_DOUBLE,j,0,MPI_COMM_WORLD);
   } else {
    MPI_Recv(data,ndata,MPI_DOUBLE,0,0,MPI_COMM_WORLD,&ierr);
   }
   for(i=0;i<ndata;i++) {
    if(data[i] == niter) {     /* GOOD */
    } else {            /* BAD */
     printf("err niter=%d ndata=%d rank=%d i=%d % .3e\n",
    niter,ndata,rank,i,data[i]);
    }
   }
  }
  MPI_Barrier(MPI_COMM_WORLD);
#ifdef MALLOC
  free(data);
#endif
 }

 MPI_Finalize();
 return 0;
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.