- #1
FunkyDwarf
- 489
- 0
Hey gang,
I'm trying to use MPIBcast to distribute a user entered value across all nodes, but it seems like only the root node is working (i.e. no broadcast).
I'm using OpenMPI 1.5.4 with the following code:
Unfortunately the other node never gets a non-zero value of N and just keeps looping :\ I have a feeling my Bcast syntax or usage is wrong but I don't know why/how. Any help would be great! (I know I could use the wait function instead of a loop but this was quicker :) )
Cheers,
-FD
I'm trying to use MPIBcast to distribute a user entered value across all nodes, but it seems like only the root node is working (i.e. no broadcast).
I'm using OpenMPI 1.5.4 with the following code:
Code:
A=0;
std::clock_t start;
double duration;
start = std::clock();
MPI::Status status;
MPI::Init(argc, argv);
N=0;
numnodes = MPI::COMM_WORLD.Get_size();
mynode = MPI::COMM_WORLD.Get_rank();
if(mynode==0){
cout<<"Enter number of sections: "<<endl;
cin>>N;
MPI::COMM_WORLD.Bcast(&N, 1, MPI::INT, 0);
}
MPI::COMM_WORLD.Barrier();
if(mynode!=0) {
while(N==0) {
//Loop until Bcast received
}
}
if(mynode==0) {
cout<<"root node: "<<N<<endl;
} else {
cout<<"other nodes: "<<N<<endl;
}
Unfortunately the other node never gets a non-zero value of N and just keeps looping :\ I have a feeling my Bcast syntax or usage is wrong but I don't know why/how. Any help would be great! (I know I could use the wait function instead of a loop but this was quicker :) )
Cheers,
-FD