MPI僵局具有集体功能
MPI deadlock with collective functions
我正在用MPI库在C 中编写一个程序。发生僵局只有一个节点可行!我不使用发送或接收集体操作,而是仅使用两个集体功能(MPI_Allreduce
和MPI_Bcast
(。如果有节点等待其他节点发送某些东西或接收,我实际上不明白这是什么原因。
void ParaStochSimulator::first_reacsimulator() {
SimulateSingleRun();
}
double ParaStochSimulator::deterMinTau() {
//calcualte minimum tau for this process
l_nLocalMinTau = calc_tau(); //min tau for each node
MPI_Allreduce(&l_nLocalMinTau, &l_nGlobalMinTau, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD);
//min tau for all nodes
//check if I have the min value
if (l_nLocalMinTau <= l_nGlobalMinTau && m_nCurrentTime < m_nOutputEndPoint) {
FireTransition(m_nMinTransPos);
CalculateAllHazardValues();
}
return l_nGlobalMinTau;
}
void ParaStochSimulator::SimulateSingleRun() {
//prepare a run
PrepareRun();
while ((m_nCurrentTime < m_nOutputEndPoint) && IsSimulationRunning()) {
deterMinTau();
if (mnprocess_id == 0) { //master
SimulateSingleStep();
std::cout << "current time:*****" << m_nCurrentTime << std::endl;
broad_casting(m_nMinTransPos);
MPI_Bcast(&l_anMarking, l_nMinplacesPos.size(), MPI_DOUBLE, 0, MPI_COMM_WORLD);
//std::cout << "size of mani place :" << l_nMinplacesPos.size() << std::endl;
}
}
MPI_Bcast(&l_anMarking, l_nMinplacesPos.size(), MPI_DOUBLE, 0, MPI_COMM_WORLD);
PostProcessRun();
}
作为您的"主"进程正在执行mpi_bcast,其他所有程序仍在运行循环,然后输入cesterintau,然后执行mpi_allreduce。
这是一个死锁
我相信您正在寻找的是:
void ParaStochSimulator::SimulateSingleRun() {
//prepare a run
PrepareRun();
while ((m_nCurrentTime < m_nOutputEndPoint) && IsSimulationRunning()) {
//All the nodes reduce tau at the same time
deterMinTau();
if (mnprocess_id == 0) { //master
SimulateSingleStep();
std::cout << "current time:*****" << m_nCurrentTime << std::endl;
broad_casting(m_nMinTransPos);
//Removed bordcast for master here
}
//All the nodes broadcast at every loop iteration
MPI_Bcast(&l_anMarking, l_nMinplacesPos.size(), MPI_DOUBLE, 0, MPI_COMM_WORLD);
}
PostProcessRun();
}
相关文章:
- 在执行其他功能的同时播放动画(LED矩阵和Arduino/ESP8266)
- 多态性和功能结合
- 带内存和隔离功能的SQLite
- 在CMakeLists.txt的安装功能中使用.cmake文件有什么用
- 类模板的成员功能的定义在单独的TU中完全专业化
- 有没有一种方法可以创建一个带有哈希表的数据库,该哈希表具有恒定时间查找功能
- 如何在C++中获得"静态纯虚拟"功能?
- 两个文件使用彼此的功能-如何解决
- 我应该实现右值推送功能吗?我应该使用std::move吗
- QML按钮点击功能执行顺序
- 无法理解此 return 语句的功能,没有它就会发生运行时错误
- 有没有可能有一个只有ADL才能找到的非好友功能
- 功能样式转换从 'int' 到 'ItemType' 的匹配转换
- 文件系统:复制功能的速度秘诀是什么
- 在用于格式4的arm模拟器中实现功能时的一个问题
- 如何在Directwrite中获得给定字体的可用OpenType功能
- 对可变参数使用声明.如何选择正确的功能
- 询问在设计我的手臂模拟器功能表示格式1
- 功能原型的目的
- MPI僵局具有集体功能