thanks,
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,
myClass
{
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.
thanks
Jack
Aug. 29 2010
To: boost-users@lists.boost.org
From: ramey@rrsd.com
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 ?
no
>
>
> How to refer to the values pointed by m_sd
?
if you use BOOST_SERIALIZE_STRONG_TYPEDEF
then
the serializable_double can be handled exactly like a
double.
(note: this is the way it is for integer types. As I write
this
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
that
it actually creates a new identifiable type.
> For example, I transfer myClass from process 1 to process 2 :
>
>
> In process 1, I declear
>
>
>
myClass
> {
> serializable_double m_sd;
>
>
>
serializable_int m_sint;
>
>
> template<class
Archive>
> void serialize(Archive &ar, const unsigned int
version){
> ar & m_sd & m_sint;;
> }
> }
myObject;
>
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
variable,
> the address should be in process 1's memory space.
>
>
> How does the process 2 can modify the value of the
variable
> pointed by a pointer with address in process 1's memory space
?
no it will be in the address space of the process that
does
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
serializable.
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@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users