C++ boost mpi是否需要等待多个宽频播放?c++;

C++ boost mpi是否需要等待多个宽频播放?c++;,c++,boost,mpi,C++,Boost,Mpi,在我的主功能中,我广播多个对象: bool kill_all_slave=false; broadcast(mpi_world,kill_all_slave,0); broadcast(mpi_world,periodicity_vector,0); broadcast(mpi_world,J,0); broadcast(mpi_world,x_range,0); broadcast(mpi_world,y_range,0); b

在我的主功能中,我广播多个对象:

    bool kill_all_slave=false;
    broadcast(mpi_world,kill_all_slave,0);

    broadcast(mpi_world,periodicity_vector,0);

    broadcast(mpi_world,J,0);

    broadcast(mpi_world,x_range,0);

    broadcast(mpi_world,y_range,0);

    broadcast(mpi_world,z_range,0);

    broadcast(mpi_world,component,0);

    broadcast(mpi_world,min_bound,0);
在我的从属功能中,我接收它们:

    while (kill_all_slave==false) {


        vector<tuple<int,int,int,int,int,int> > periodicity_vector;

        std::cout << "[SLAVE: " << mpi_world.rank()<< "] I am waiting to receive periodicity vector"<<endl;

        broadcast(mpi_world,periodicity_vector,0);

        std::cout << "[SLAVE: " << mpi_world.rank()<< "] I am waiting to J "<<endl;


        broadcast(mpi_world,J,0);

        int x_range,y_range,z_range;
        double min_bound;
        map<int,int> component;

        cout<<"\n hello I am slave: "<<mpi_world.rank()<<" received 3rd set of the global parameters"<<endl;

        broadcast(mpi_world,x_range,0);
        broadcast(mpi_world,y_range,0);

        cout<<"\n hello I am slave: "<<mpi_world.rank()<<" received 4th set of the global parameters"<<endl;
        broadcast(mpi_world,z_range,0);
        broadcast(mpi_world,component,0);
        cout<<"\n hello I am slave: "<<mpi_world.rank()<<" received 5th set of the global parameters"<<endl;


        broadcast(mpi_world,min_bound,0);

        cout<<"\n hello I am slave: "<<mpi_world.rank()<<" received 6th set of the global parameters"<<endl;

        bool stop = false;
        string status="initial";
        mpi_world.send(0, 0, status);
//        
        cout<<"\n hello I am slave: "<<mpi_world.rank()<<" I am going to send to root status"<<endl;


        mpi_world.recv(0, 0, stop);

        cout<<"\n hello I am slave: "<<mpi_world.rank()<<" I am going to receive stop signal from root"<<endl;


        while(!stop) {

            map< tuple<int,int,int,int,int,int>, map<set<tuple<int,int,int,int,int> >, double> > clustertype_periodic;

            // Wait for new job

            unsigned int job_id = 0;

            cout<<"\n hello I am slave: "<<mpi_world.rank()<<" I am going to receive stop job id from root"<<endl;

            mpi_world.recv(0, 0, job_id);

            cout<<"\n hello I am slave: "<<mpi_world.rank()<<" I am going to receive stop min bound from root"<<endl;


            mpi_world.recv(0, 1, min_bound);


            std::cout << "[SLAVE: " << mpi_world.rank()

            << "] Received job " << job_id << " from MASTER.\n"<<endl;

            // Perform "job"

            map<tuple<int,int,int,int>,int>  spin_tmp;
            double energy_tmp=0;

            tuple<int,int,int,int,int,int>  periodicity_now;
            {
                int i=job_id;
                periodicity_now=periodicity_vector[i];
                int a0=periodicity_now.get<0>();
                int a1=periodicity_now.get<1>();
                int a2=periodicity_now.get<2>();
                int a3=periodicity_now.get<3>();
                int a4=periodicity_now.get<4>();
                int a5=periodicity_now.get<5>();

                {
                    if (pseudo_mode) {



                        periodic(a0, a1, a2, a3, a4, a5,
                                 J, x_range, y_range, z_range, component,
                                 spin_tmp,
                                 energy_tmp,
                                 clustertype_periodic, min_bound, id,
                                 true, false, false,
                                 obscenely_verbose,global_parameters);

                        //                    {
                        //                        spin_periodic[make_tuple(a0,a1,a2,a3,a4,a5)]=spin_tmp;
                        //                        energy_periodic[make_tuple(a0,a1,a2,a3,a4,a5)]=energy_tmp;
                        //                    }
                    }
                    else if (basic_exact_mode){




                        periodic(a0, a1, a2, a3, a4, a5,
                                 J, x_range, y_range, z_range, component,
                                 spin_tmp,
                                 energy_tmp,
                                 clustertype_periodic, min_bound, id,
                                 false, true, false,
                                 obscenely_verbose,global_parameters);

                        //                    {
                        //                        spin_periodic[make_tuple(a0,a1,a2,a3,a4,a5)]=spin_tmp;
                        //                        energy_periodic[make_tuple(a0,a1,a2,a3,a4,a5)]=energy_tmp;
                        //                    }


                    }

                }
            }



            // Notify master that the job is done

            std::cout << "[SLAVE: " << mpi_world.rank()

            << "] Done with job " << job_id << ". Notifying MASTER.\n"<<endl;

            status="finish";

            mpi_world.send(0, 0,status);
//            std::cout << "[SLAVE: " << mpi_world.rank()<< "] I have sent status back to master"<<endl;

            //note here, I deliberated exclude cluster_type_periodic which may be the culprit of a lot of bad computing performance for realistic system

            //send periodicity, spin_tmp and energy_tmp

            //        and remember to send more detail;


            mpi_world.send(0, 1,spin_tmp);
            std::cout << "[SLAVE: " << mpi_world.rank()<< "] I have sent spin_tmp back to master"<<endl;
            mpi_world.send(0, 2,energy_tmp);
            std::cout << "[SLAVE: " << mpi_world.rank()<< "] I have sent energy_tmp back to master"<<endl;
            mpi_world.send(0, 3,periodicity_now);
            std::cout << "[SLAVE: " << mpi_world.rank()<< "] I have sent periodicity_now back to master"<<endl;


            // Check if a new job is coming

            mpi_world.recv(0, 0, stop);
            std::cout << "[SLAVE: " << mpi_world.rank()<< "] I have receive stop from master"<<endl;


        }


        std::cout << "[SLAVE: " << mpi_world.rank()<< "] I am waiting for signal whether kill_all_slave"<<endl;


        broadcast(mpi_world,kill_all_slave,0);

        std::cout << "[SLAVE: " << mpi_world.rank()<< "] I receive kill_all_slave signal as "<<kill_all_slave<<endl;


    }

但是它没有接收下一轮广播,而其他从进程确实接收。

也许我遗漏了什么,但是如果从进程在while循环中“接收”广播,那么主进程也必须在相同(或类似)while循环中广播数据。现在,很明显,您在某些方面存在不匹配的集体操作,这是我看到的第一个潜在问题。您似乎正在调用
广播(mpi\u world,kill\u all\u slave,0)辅助函数中的最后一个,主函数中的第一个。除非在
while
循环之前的workers中有另一个广播,否则这将无法按预期工作。所有级别的集体呼叫顺序必须相同。实际上,顺序是相同的。。。。因为如果我生产400个从机,399可以完美工作,有时只有一个从机不能以1%的概率捕捉广播。。。。这是一个完全神秘的灾难……也许我遗漏了什么,但是如果您的从属进程在while循环中“接收”广播,那么主进程也必须在相同(或类似)while循环中广播数据。现在,很明显,您在某些方面存在不匹配的集体操作,这是我看到的第一个潜在问题。您似乎正在调用
广播(mpi\u world,kill\u all\u slave,0)辅助函数中的最后一个,主函数中的第一个。除非在
while
循环之前的workers中有另一个广播,否则这将无法按预期工作。所有级别的集体呼叫顺序必须相同。实际上,顺序是相同的。。。。因为如果我生产400个从机,399可以完美工作,有时只有一个从机不能以1%的概率捕捉广播。。。。这是一场完全神秘的灾难。。。。
[SLAVE: 56] I receive kill_all_slave signal as 0