Re: [OMPI users] MPI_Reduce problem

2007-07-11 Thread anyi li
Hi Jelena, int* ttt = (int*)malloc(2 * sizeof(int)); ttt[0] = myworldrank + 1; ttt[1] = myworldrank * 2; if(myworldrank == 0) MPI_Reduce(MPI_IN_PLACE, ttt, 2, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD); //sum all logdetphi from different nodes else MPI_Reduce(ttt, NULL, 2, MPI_INT, MPI_SUM,

Re: [OMPI users] MPI_Reduce problem

2007-07-11 Thread Jelena Pjesivac-Grbovic
Hi Anyi, you are using reduce incorrectly: you cannot use the same buffer as input and output. If you want to do operation in place, you must specify "MPI_IN_PLACE" as send buffer at the root process. Thus, your code should look something like: int* ttt = (int*)malloc(2 * sizeof(int

[OMPI users] MPI_Reduce problem

2007-07-11 Thread anyili
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_