Boost MPI:gather:free():指针无效

时间:2014-07-01 10:02:32

标签: c++ boost mpi

我写了简单的程序来说明MPI聚集。每个进程发送对象数组,根进程在向量中接收该对象。但是,我得到了错误:

*** glibc detected *** gather: free(): invalid pointer: 0xb7464464 ***
BackTrace
......
MemoryMap
......

这是我的代码:

#include <boost/mpi/environment.hpp>
#include <boost/mpi/communicator.hpp>
#include <boost/mpi.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/access.hpp>
#include <boost/serialization/string.hpp>
#include <iostream>
#include <vector>
#include <sstream>
#include <boost/array.hpp>
#include <boost/mpi/collectives.hpp>

using namespace std;
using namespace boost::mpi;

class A
{
private:
    string x,y;
public:
    void setX(string x)
    {
        this->x=x;
    }
    void setY(string y)
    {
        this->y=y;
    }
    string getX()
    {
        return this->x;
    }
    string getY()
    {
        return this->y;
    }
    A()
    {

    }
    A(string x,string y)
    {
        this->x=x;
        this->y=y;
    }
    friend class boost::serialization::access;
    template <class Archive>

    void serialize(Archive &ar,unsigned int version)
    {
        ar &x;
        ar &y;
    }


};



int main(int argc,char *argv[])
{
    environment env(argc,argv);
    communicator world;


    A p[2];

    p[0]=A("aa","aa");
    p[1]=A("bb","bb");

    vector<A> t;


    t.reserve(2*world.size());


    gather(world,p,2,t,0);

}

有谁知道什么是问题? 谢谢:)!

0 个答案:

没有答案