检测MPI第一个进程执行

时间:2016-05-16 12:48:42

标签: c++ mpi

使用c ++语言编写MPI库。 我只需要从用户那里读取参数一次 像这样的东西:

if (rank==0 )
       {
           printf ("enter a,b: %d\n");
           scanf("%d",&a);
             scanf("%d",&b);
        std::vector<int> ab;
            ab.resize(2);
            ab[0]=a;
            ab[1]=b;
            for (int i=1;i<numtasks;i++)
            MPI_Send(&ab.front(),2,MPI_INT,i,0,MPI_COMM_WORLD);
             MPI_Barrier(MPI_COMM_WORLD);
      }
       else if (rank!=0)
       {MPI_Status status1;
     MPI_Request request1;
    std::vector<int> ab;
    ab.resize(2);
    std::vector<int> temp=ab;
    MPI_Barrier(MPI_COMM_WORLD);
    while (temp==MinMax)*/
      MPI_Irecv(&ab.front(),2,MPI_INT,0,0,MPI_COMM_WORLD,&request1);
      a=ab[0];
     b=ab[1];}

我的意思是我想要一个proccess读取参数并将它们发送给所有其他人

或以任何方式定义共享参数并一次读取它们&gt;

0 个答案:

没有答案