-1
當我試圖運行一個MPI程序但失敗。它說:這些退出代碼對於MPI程序意味着什麼?
job aborted:
[ranks] message
[0] process exited without calling finalize
[1-3] terminated
錯誤分析說退出碼是0xc0000005
。
然後我google了一下,有人說用MPI_Init_thread
代替,但它給了我255
退出代碼。
我該如何解決?等級0過程有什麼問題?
下面是一個使用MPI發送和接收數據的代碼片段:
// MPI things
MPI_Comm_rank(MPI_COMM_WORLD, &taskid);
// master
if (taskid == 0)
{
//printf("taskid: %d", taskid);
average = Nchunk/Nworkers;
extra = Nchunk % Nworkers;
mtype = FROM_MASTER;
offset = 0;
// store volume[Itemp[n]]
for (int i = 0; i < Nchunk; i++)
{
volumeTemp[i] = volume[Itemp[i]];
}
// send to slave
for (int dest = 1; dest <= Nworkers; dest++)
{
Nelements = (dest <= extra) ? average + 1 : average;
MPI_Send(&Nelements, 1, MPI_INT, dest, mtype, MPI_COMM_WORLD);
MPI_Send(&offset, 1, MPI_INT, dest, mtype, MPI_COMM_WORLD);
MPI_Send(&Itemp[offset], Nelements, MPI_INT, dest, mtype, MPI_COMM_WORLD);
MPI_Send(&SMtemp[offset], Nelements, MPI_FLOAT, dest, mtype, MPI_COMM_WORLD);
MPI_Send(&volumeTemp[offset], Nelements, MPI_FLOAT, dest, mtype, MPI_COMM_WORLD);
offset = offset + Nelements;
}
// receive result from slave
mtype = FROM_WORKERS;
for (int source = 1; source <= Nworkers; source++)
{
//MPI_Recv(&average, 1, MPI_INT, source, mtype, MPI_COMM_WORLD, &status);
//MPI_Recv(&offset, 1, MPI_INT, source, mtype, MPI_COMM_WORLD, &status);
MPI_Recv(&sinogram[ns], 1, MPI_FLOAT, source, mtype, MPI_COMM_WORLD, &status);
}
}
//printf("taskid: %d", taskid);
// slave
if (taskid > 0)
{
//printf("taskid: %d", taskid);
mtype = FROM_MASTER;
MPI_Recv(&Nelements, 1, MPI_INT, MASTER, mtype, MPI_COMM_WORLD, &status);
MPI_Recv(&offset, 1, MPI_INT, MASTER, mtype, MPI_COMM_WORLD, &status);
MPI_Recv(&Itemp[offset], Nelements, MPI_INT, MASTER, mtype, MPI_COMM_WORLD, &status);
MPI_Recv(&SMtemp[offset], Nelements, MPI_INT, MASTER, mtype, MPI_COMM_WORLD, &status);
MPI_Recv(&volumeTemp, Nelements, MPI_FLOAT, MASTER, mtype, MPI_COMM_WORLD, &status);
for (int i = 0; i < average; i++)
{
if (fabs(volumeTemp[i]) > 1.0e-14)
sinogram[ns] = sinogram[ns] + volumeTemp[i] * SMtemp[i];
}
//send to master
mtype = FROM_WORKERS;
MPI_Send(&sinogram[ns], 1, MPI_FLOAT, MASTER, mtype, MPI_COMM_WORLD, &status);
}
顯示代碼,它可以是任何東西。試着找出進程退出代碼的哪個位置。 –
它應該是一個MCVE ... – Jeff
對不起,這是我第一次發佈我的問題。我附上了一段代碼片段以使其更好 – Heran