mpi - How do I use MPI_Allgather -
i'm testing out mpi_allgather, , i'm getting strange results... following code gives me output of: "p0 received: 0,42,-1780253336,42,". correct result there 1st one, they're sending ranks. output should be: "0, 1, 2, 3,". i'm @ loss why isn't working expected.
int main(int argc, char* argv[]) { int rank = 0; int size = 0; mpi_init(&argc,&argv); mpi_comm_rank(mpi_comm_world,&rank); mpi_comm_size(mpi_comm_world, &size); int* arr = new int[4]; mpi_allgather(&rank, 1, mpi_int, arr, 4, mpi_int, mpi_comm_world); if(rank == 0) { printf("p0 received: "); for(int i=0; i< 4; i++) printf("%i,", arr[i]); printf("\n"); } delete arr; mpi_finalize(); }
Comments
Post a Comment