1
我很難弄清楚如何在c中使用OpenMPI打破循環。OpenMPI突破循環
這裏是我的循環
for(i=1; i<=steps;i++) {
do_calculation(psi,new_psi,&mydiff,i1,i2,j1,j2);
if (breakNow == 1) {
break;
}
diff = find_difference();
if(myid == mpi_master && i % iout == 0){
printf("%8d %15.5f\n",i,diff);
if (diff == 0.00) {
printf("DONE!");
breakNow = 1;
MPI_Bcast(&breakNow, 1, MPI_INT, mpi_master, MPI_COMM_WORLD);
}
}
}
我需要打破所有處理器的出循環時,有0.00的差異,但好像breakNow變量沒有被廣播到所有的處理器。我錯過了什麼嗎?