Boost logo

Boost Users :

Subject: Re: [Boost-users] boost transfer pointers by serialize
From: Jack Bryan (dtustudy68_at_[hidden])
Date: 2010-08-29 17:19:44

In this way, in myClass, I replace " double* myDouble" with " serializable_double myDouble". Can the " myDouble " be accessed as the original " double* " ?
I need to assign some values to myDouble at first and then use boost MPI to transfer it to another process.
For example,
if I use double*
double myVar =2.1 ;double* myDouble = &myVar ;
if I use serializable_double , I need to do it in this way :
double myVar = 2.1 ;serializable_double myDouble = &myVar ;
If I am wrong, please correct me.
The following is the data structure that I want to transfer from one process to another process : -------------------------------------------------------------------------------
typedef struct { int rank; double constr_violation; double *xreal; int **gene; double *xbin; double *obj; double *constr; double crowd_dist; }individual;
typedef struct { individual *ind;}population;-----------------------------------------------------------------------------------
I need to trasfer population from process 1 to process 2 such that the data members in population->ind can be operated in process 2.
Then, the process 2 returns the population->ind with new results to process 1.
Becasue the population and individual data structure are also used by other programs in the same project, I do not want to change double8 to serializable_double inside them.
May I use assignment to do it ?
for example,
    int rank; double constr_violation; serializable_double xreal; serializable_int *gene; serializable_double xbin; serializable_double obj; serializable_double constr; double crowd_dist;} myObject;
myObject.xreal = (population->ind)->xreal;
Any help is appreciated.
Aug. 29 2010
To: boost-users_at_[hidden]
From: ramey_at_[hidden]
Date: Sun, 29 Aug 2010 10:27:57 -0800
Subject: Re: [Boost-users] boost transfer pointers by serialize

Jack Bryan wrote:
> Thanks
> Is the m_sd a
pointer that points to a double variable ?

> How to refer to the values pointed by m_sd
the serializable_double can be handled exactly like a
(note: this is the way it is for integer types. As I write
I'm not sure it applies to floating point types but I
think it does.
think of strong typedef as the same as a typedef except
it actually creates a new identifiable type.
> For example, I transfer myClass from process 1 to process 2 :

> In process 1, I declear
> {
> serializable_double m_sd;
serializable_int m_sint;
> template<class
> void serialize(Archive &ar, const unsigned int
> ar & m_sd & m_sint;;
> }
> }

so far so good.

> In process 1 , I use
world.isend(destRank, downStreamTaskTag, myObject);
> In
process 2, I use
> world.recv(sourceRank,
downStreamTaskTag, myObjectRecv);
> How to refer to the
values pointed by m_sd in myClass ?
just like you would doubles.

> May I use it in this way ?

> *(myObjectRecv.m_sd) ;
you could.

> If myObjectRecv.m_sd is an address of a primitive
> the address should be in process 1's memory space.

> How does the process 2 can modify the value of the
> pointed by a pointer with address in process 1's memory space
no it will be in the address space of the process that
the de-serialization.

> I can
use the similar way to do it for pointer's pointer ?
> such as double**
unfortunately, pointers to pointers are not currently
There is a track item on this. This is an oversight
in the implementation
which is non-trivial to fix.

> Any help is appreciated ?

it is?
Robert Ramey

Boost-users mailing list

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at