Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in irecv for derived datatypes #53

Closed
jedwards4b opened this issue Jan 12, 2018 · 1 comment
Closed

Bug in irecv for derived datatypes #53

jedwards4b opened this issue Jan 12, 2018 · 1 comment

Comments

@jedwards4b
Copy link
Contributor

The following demonstrates a bug in using mpi derived types in the receive buffer, this is showing up when running (cesm) cam-se using mpi-serial. @gold2718 reported to pio, but it's an mpi-serial bug. Run using mpi on a single processor the result is:
-1 0 -1 1 -1 2 -1 3

however with mpi-serial the derived type is not respected and you get
0 1 2 3 -1 -1 -1 -1

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

int main(int argc, char **argv)
{
  int mpierr;
  int blocksize=1;
  int len=4;
  int displace[len];
  MPI_Datatype mtype;
  int sbuf[8];
  int rbuf[8];
  int i;
  MPI_Request rcvid;
  MPI_Status status;

  mpierr = MPI_Init(&argc, &argv);

  for (i=0;i<8;i++){
    sbuf[i] = i;
  }
  for (i=0;i<8;i++){
    rbuf[i] = -1;
  }
  for (i=0;i<len;i++)
    displace[i]=1+i*2;

  mpierr = MPI_Type_create_indexed_block(len, blocksize, displace,
					 MPI_INT, &mtype);
  mpierr = MPI_Type_commit(&mtype);

  mpierr = MPI_Irecv(rbuf, 1, mtype,
		     0, 1, MPI_COMM_WORLD, &rcvid);
  mpierr = MPI_Send(sbuf, 4, MPI_INT,
		    0, 1, MPI_COMM_WORLD);

  mpierr = MPI_Wait(&rcvid, &status);

  for (i=0;i<8;i++)
    printf(" %d",rbuf[i]);
  printf("\n");

  mpierr = MPI_Finalize();

}
@gold2718
Copy link

Moved to ESMCI/mpi-serial#11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants