MPI错误:无输出 [英] MPI Error: No output

查看:215
本文介绍了MPI错误:无输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的代码用于使用4个节点通过MPI进行通信.我可以使用"mpiicpc"在群集上成功编译它.

The code below is for using 4 nodes to communicate using MPI. I am able to compile it successfully on the cluster using "mpiicpc".

但是,输出屏幕仅向我发出警告,警告:无法读取mpd.hosts以获取仅在当前位置启动的主机列表"并挂起.

However, the output screen just gives me a warning, ‘Warning: Cant read mpd.hosts for list of hosts start only on current’ and hangs.

能否请您提出警告的含义,以及这是否是我的代码挂起的原因?

Could you please suggest what the warning means and also if it is the reason why my code hangs?

#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 ....
       ....
 }

推荐答案

当您要在多个节点上运行时,必须使用-machinefile开关告诉mpirun您想要哪些节点.该计算机文件只是节点列表,每行一个.如果要在一个节点上放置2个进程,请列出两次.

When you want to run on multiple nodes you have to tell mpirun which ones you want with the -machinefile switch. This machinefile is just a list of nodes, one per line. If you want to put 2 processes on one node, list it twice.

因此,如果您的计算机分别命名为node1node2,并且您想使用每个内核中的两个内核:

So if your machines are named node1 and node2 and you want to use two cores from each:

$ cat nodes
node1
node1
node2
node2
$ mpirun -machinefile nodes -np 4 ./a.out

如果使用的是批处理控制系统,例如PBS或TORQUE(使用qsub提交作业),则将为您创建此节点文件,并且其位置位于$PBS_NODEFILE环境变量中:

If you're using a batch control system like PBS or TORQUE (you use qsub to submit your job) then this node file is created for you and its location is in the $PBS_NODEFILE environment variable:

mpirun -machinefile $PBS_NODEFILE -np 4 ./a.out

这篇关于MPI错误:无输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆