Laminfo:
[fedora@localhost lammpi]$ laminfo
LAM/MPI: 7.1.4
在我的主机文件中:
localhost
localhost
localhost
localhost
localhost
localhost
在搜索数小时后,我将代码减少到最低限度:
#include "mpi.h"
#include <stdio.h>
#include <stdlib.h>
int main(int argc,char *argv[]){
int rank;
int size;
MPI_Init(&argc,&argv);
MPI_Comm_size(MPI_COMM_WORLD,&size);
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
if(rank==0){
int buf1[2];
int buf2[2];
MPI_Request mr1;
MPI_Request mr2;
MPI_Status ms1;
MPI_Status ms2;
MPI_Isend(buf1,2,MPI_INT,1,0,MPI_COMM_WORLD,&mr1);
MPI_Isend(buf2,2,MPI_INT,2,0,MPI_COMM_WORLD,&mr2);
MPI_Cancel(&mr1);
MPI_Wait(&mr1,&ms1);
MPI_Cancel(&mr2);
MPI_Wait(&mr2,&ms2);
MPI_Isend(buf1,2,MPI_INT,1,0,MPI_COMM_WORLD,&mr1);
MPI_Isend(buf2,2,MPI_INT,2,0,MPI_COMM_WORLD,&mr2);
MPI_Cancel(&mr1);
MPI_Wait(&mr1,&ms1);
MPI_Cancel(&mr2);
MPI_Wait(&mr2,&ms2);
}
MPI_Finalize();
return EXIT_SUCCESS;
}
执行此代码时,有时会出现以下错误: mpirun因退出状态11
而失败我知道状态11是段错误。但我不知道为什么这段代码会产生段错!尽管如此,请在下次使用之前优先取消请求...您能帮助或更正代码吗?