1
以下代碼用於使用4個節點使用MPI進行通信。我可以使用「mpiicpc」在集羣上成功編譯它。MPI錯誤:無輸出
但是,輸出屏幕只是給我一個警告,'警告:無法讀取mpd.hosts的主機列表只能啓動當前'並掛起。
請問您能提出警告的含義,如果這是我的代碼掛起的原因嗎?
#include <mpi.h>
#include <fstream>
using namespace std;
#define Cols 96
#define Rows 96
#define beats 1
ofstream fout("Vm0");
ofstream f1out("Vm1");
.....
.....
double V[Cols][Rows];
int r,i,y,ibeat;
int my_rank;
int p;
int source;
int dest;
int tag = 0;
//Allocating Memory
double *A = new double[Rows*sizeof(double)];
double *B = new double[Rows*sizeof(double)];
.....
......
void prttofile();
// MAIN FUNCTION
int main (int argc, char *argv[])
{
//MPI Commands
MPI_Status status;
MPI_Request send_request, recv_request;
MPI_Init (&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
MPI_Comm_size(MPI_COMM_WORLD, &p);
for (ibeat=0;ibeat<beats;ibeat++)
{
for (i=0; i<Cols/2; i++)
{
for (y=0; y<Rows/2; y++)
{
if (my_rank == 0)
if (i < 48)
if (y<48)
V[i][y] = 0;
....
.......
.....
}
}
//Load the Array with the edge values
for (r=0; r<Rows/2; y++)
{
if ((my_rank == 0) || (my_rank == 1))
{
A[r] = V[r][48];
BB[r] = V[r][48];
}
.....
.....
}
int test = 2;
if ((my_rank%test) == 0)
{
MPI_Isend(C, Rows, MPI_DOUBLE, my_rank+1, 0, MPI_COMM_WORLD, &send_request);
MPI_Irecv(CC, Rows, MPI_DOUBLE, my_rank+1, MPI_ANY_TAG, MPI_COMM_WORLD, &recv_request);
}
else if ((my_rank%test) == 1)
......
......
ibeat = ibeat+1;
prttofile();
} //close ibeat
MPI_Finalize();
} //close main
//Print to File Function to save output values
void prttofile()
{
for (i = 0; i<Cols/2; i++)
{
for (y = 0; y<Rows/2; y++)
{
if (my_rank == 0)
fout << V[i][y] << " " ;
....
.....
}
}
if (my_rank == 0)
fout << endl;
if ....
....
}
Adam。謝謝!我提交的運行命令是mpirun -np 4 <編譯文件>。儘管現在,模擬計算出的輸出正常,但仍顯示警告。我會嘗試你所建議的...... – Ashmohan 2011-05-18 15:55:02