【发布时间】:2017-01-26 09:40:16
【问题描述】:
在 MPI 中,MPI_Abort() 主要用于中止异常行为。在我下面的程序中,在每次迭代时,ROOT 进程都会检查一个条件,而其余处理器在 MPI_Barrier 处等待以接收下一次迭代的数据。因此,如果达到阈值,我希望根终止整个循环并且其他处理器应该离开循环并终止。我的问题是:使用MPI_Abort() 让在屏障中等待的处理器终止是否有意义?
void kmeans() {
do{
// Step1: ROOT Broadcast the K centroids.
MPI_Bcast(&cluster_centroids, N, MPI_FLOAT, ROOT, MPI_COMM_WORLD);
MPI_Barrier(MPI_COMM_WORLD);
// Step2: Calculate the distances.
points_assignment(data, cluster_center);
// Step3: Update cluster centroid (Locally at each processor)
update_centroids_locally();
if(Rank == ROOT){
// Step4: ROOT checks the threshold
Flag = check_threshold(cluster_center);
if(Flag == 1){
// MPI_Abort(MPI_COMM_WORLD,0);
break;
}else{
continue;
}
}
} while(1);
}
【问题讨论】:
标签: c parallel-processing mpi