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

Concurrency error in your implementation of Allgatherv? #5

Open
mquinson opened this issue May 27, 2021 · 0 comments
Open

Concurrency error in your implementation of Allgatherv? #5

mquinson opened this issue May 27, 2021 · 0 comments

Comments

@mquinson
Copy link
Contributor

Hello,

I get an 'Invalid write' error in any code that contains a call to MPI_Allgatherv(), such as the following. This code is supposed to be correct.

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

#define buff_size 128

int main(int argc, char **argv) {
  int nprocs = -1;
  int rank = -1;

  MPI_Init(&argc, &argv);
  MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  printf("Hello from rank %d \n", rank);

  if (nprocs < 2)
    printf("MBI ERROR: This test needs at least 2 processes to produce a bug.\n");

  int dbs = sizeof(int)*nprocs; /* Size of the dynamic buffers for alltoall and friends */
  int *rbuf1 = malloc(dbs), *rcounts1=malloc(dbs),  *displs1=malloc(dbs);
  for (int i = 0; i < nprocs; i++) {
    rcounts1[i] = 1;
    displs1[i] = 2 * (nprocs - (i + 1));
  }

  if (rank % 2) {
    MPI_Allgatherv(&rank, 1, MPI_INT, rbuf1, rcounts1, displs1, MPI_INT, MPI_COMM_WORLD);  
  } else {
    MPI_Allgatherv(&rank, 1, MPI_INT, rbuf1, rcounts1, displs1, MPI_INT, MPI_COMM_WORLD);
    
  }

  free(rbuf1);free(rcounts1);free(displs1);
  
  
  MPI_Finalize();
  printf("Rank %d finished normally\n", rank);
  return 0;
}

The produced stack trace (in the HTML) reads as follows:

0x10CF47: aislinn_call (aislinn.c:61)
0x10B9EE: MPI_Allgatherv (mpi_generated.c:643)
0x108CD9: main (CollCorrect_Allgatherv.c:59)
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

1 participant