Scatter is a collective operation.
You need to have all ranks in COMM_WORLD call it. Even though rank 0
is the one with the original data.
Remove the if(rank==0) block around it,
Brock Palen
www.umich.edu/~brockp
Center for Advanced Computing
bro...@umich.edu
(734)936-1985
On Dec 9, 2008, at 7:11 PM, Kevin Anthony Joy wrote:
Good Evening All,
I'm very new to using MPI; I seem to be struggling to get a basic
understanding of the MPI::Comm_World.Scatter Operation, It seem's
as though a may be misunderstanding how the scatter operation
works. Suppose i have an Array of x amount of doubles, let's say 3
doubles that i want to spread across three processes.
I have -
#include <iostream>
#include <mpi.h>
int main(int argc, char* argv[])
{
MPI_Init(&argc, &argv);
int rank, procs;
MPI_Comm_size(MPI_COMM_WORLD, &procs);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
double stat[3] ;
stat[0] = 1.2;
stat[1] = 65.3;
stat[2] = 45.3;
double test3[3];
if (rank==0) {
MPI::COMM_WORLD.Scatter(
stat,
1,
MPI::DOUBLE,
&test3,
1,
MPI::DOUBLE,
0);
}
std::cout << rank <<" rec'd " << test3[0] << std::endl;
MPI_Finalize();
}
Unfortunately, this doesn't output what i'd like. I'd like: Process
0 to output 1.2, process 1 to output 65.3 and process 2 to output
45.3 etc etc. I apologise if this question is very trivial.
Regards,
Win John Lewis vouchers with BigSnapSearch.com Search now
_______________________________________________
users mailing list
us...@open-mpi.org
http://www.open-mpi.org/mailman/listinfo.cgi/users