Hi,
  I have a code which have a identical vector on each node,  I am going to do
the vector sum and return result to root.  Such like this,

  int* ttt = (int*)malloc(2 * sizeof(int));
  ttt[0] = myworldrank + 1;
  ttt[1] = myworldrank * 2;
   MPI_Allreduce(ttt, ttt, 2, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
  FOR_WORLDNODE0 printf("%d, %d\n" , ttt[0],ttt[1]);

  myworldrank is the rank of local node, if I run this code under 4 nodes, what
I expect  return is 10,12. But what I got is 18,24. So I'm confused here on
MPI_Reduce, is that supposed to do the vector sum ?
  I tried MPI_Allreduce, it gave me the correct answer 10, 12.

  Is there someone met the same problems or I am wrong on calling MPI_Reduce()

  Thanks.
Anyi





Reply via email to