Boost logo

Boost Users :

Subject: Re: [Boost-users] boost.MPI dynamic data structure error
From: Matthias Troyer (troyer_at_[hidden])
Date: 2010-10-19 20:12:33


On 19 Oct 2010, at 13:39, Jack Bryan wrote:

> Hi ,
>
> I need to design a data structure to transfer data between nodes by boost.MPI.
>
> Some elements of the the structure has dynamic size.
>
> For example,
>
> typedef struct{
>
> double data1;
> vector<double> dataVec;
>
> } myDataType;
>
> The size of the dataVec depends on some intermidiate computing results.
>
> If I only declear it as the above myDataType, I think, only a pointer is transfered.
>
> When the data receiver try to access the elements of vector<double> dataVec, it got
> segmentation fault error.
>
> But, I also need to use the myDataType to declear other data structures.
>
> such as vector<myDataType> newDataVec;

Hi Jack,

All you need to do is to define a serialize() function for your data structure, so that it can be serialized by Boost.Serialization. Then you can transfer the datastructure with Boost.MPI

Matthias



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net