MPI Error: No output

为君一笑 提交于 2019-12-24 09:58:59

问题


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

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

回答1:


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.

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

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


来源:https://stackoverflow.com/questions/5982645/mpi-error-no-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!