所以我有一个我正在编写的光线追踪器,它编译得很好,但是当我进入 MPI_Gather() 函数时,我得到了这个错误集。如果我写入文件,整个事情就可以完成,但是我不能在分布式计算系统上运行它。
Fatal error in PMPI_Gather: Internal MPI error!, error stack:
PMPI_Gather(856)......:
MPI_Gather(sbuf=0x8e05468, scount=882000, MPI_BYTE, rbuf=0x8df7628, rcount=882000, MPI_BYTE, root=0, MPI_COMM_WORLD) failed
MPIR_Gather_impl(681).:
MPIR_Gather(641)......:
MPIR_Gather_intra(152):
MPIR_Localcopy(378)...:
memcpy arguments alias each other, dst=0x8df7628 src=0x8e05468 len=882000
===================================================================================
= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
= EXIT CODE: 1
= CLEANING UP REMAINING PROCESSES
= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
===================================================================================
我不确定这个错误是什么意思,所以很难绕过它。
这是主要功能的来源:
int main(int argc, char **argv) {
clock_t total_time = clock(), otime;
init_MPI(argc, argv); //Initialize OpenMPI
glutInit(&argc,argv);
get_params(argc, argv); //Get parameters from command line
if (buildScene(scene, cam) == -1) MPI_Abort(MPI_COMM_WORLD,rc); exit(1);
samples = samples > 0 ? whitted ? 1 : samples : 1;
if (numprocs == 1) {
scn = new RGBApixmap(h,w);
raytrace(h,scn);
if (smult > 1) *scn = scaleImage(scn,smult);
} else {
int rows = h / numprocs;
subscn = new RGBApixmap(rows,w);
raytrace(rows, subscn);
if (smult > 1) *subscn = scaleImage(subscn,smult);
if (pid == MASTER) scn = new RGBApixmap(h/smult,w/smult);
MPI_Gather(subscn,rows/smult*w,MPI_BYTE,scn,rows/smult*w,MPI_BYTE,MASTER,MPI_COMM_WORLD);
}
if (pid == MASTER) {
initGlut(argc, argv);
glutMainLoop();
}
MPI_Finalize();
return 0;
}
编辑:
我已经解决了这个问题并在下面发布了更新的代码:
int main(int argc, char **argv) {
clock_t total_time = clock(), otime;
init_MPI(argc, argv);
glutInit(&argc,argv);
bool OK = get_params(argc, argv);
if (buildScene(scene, cam) == -1) { MPI_Abort(MPI_COMM_WORLD,rc); exit(1); }
samples = samples > 0 ? whitted ? 1 : samples : 1;
int rows = h / numprocs;
subscn = new RGBApixmap(rows,w);
raytrace(rows, subscn);
MPI_Barrier(MPI_COMM_WORLD); /* Synchronize all processes */
if (smult > 1) *subscn = scaleImage(subscn,smult);
MPI_Barrier(MPI_COMM_WORLD); /* Synchronize all processes */
int nElts = subscn->getWidth()*subscn->getHeight();
RGBA *subscnpix, *scnpix;
subscnpix = subscn->getPixs();
scnpix = (RGBA*)malloc(sizeof(RGBA)*((w/smult)*(h/smult)));
MPI_Datatype pixel;
MPI_Type_contiguous(4,MPI_UNSIGNED_CHAR,&pixel);
MPI_Type_commit(&pixel);
MPI_Gather(subscnpix,nElts,pixel,scnpix,nElts,pixel,MASTER,MPI_COMM_WORLD);
scn = new RGBApixmap(h/smult,w/smult,scnpix);
MPI_Type_free(&pixel);
MPI_Barrier(MPI_COMM_WORLD); /* Synchonize all processes */
if (pid == MASTER) {
initGlut(argc, argv);
glutMainLoop();
}
MPI_Finalize();
return 0;
}