【问题标题】:MPI Error: No outputMPI 错误:无输出
【发布时间】:2011-05-18 16:12:00
【问题描述】:

下面的代码是使用 4 个节点使用 MPI 进行通信。我能够使用“mpiicpc”在集群上成功编译它。

但是,输出屏幕只是给我一个警告,“警告:无法读取 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 ....
       ....
 }

【问题讨论】:

    标签: mpi runtime-error


    【解决方案1】:

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

    因此,如果您的机器被命名为 node1 和 node2,并且您想使用每个机器的两个内核:

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

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

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

    【讨论】:

    • 亚当。谢谢!我提交的运行命令是 mpirun -np 4 。虽然现在,模拟确实可以很好地计算输出,但它仍然显示警告。我会试试你的建议...
    猜你喜欢
    • 2020-01-18
    • 2013-12-19
    • 2017-11-10
    • 2013-02-12
    • 2017-01-20
    • 2017-06-25
    • 2014-11-16
    • 2014-05-07
    • 2014-05-07
    相关资源
    最近更新 更多