Sending a C++ object over MPI

  • Follow


Hi all,

I am new to MPI, so please forgive me if this question has an obvious 
answer. I have a large object in C++ that dynamically allocates memory for 
its internal data. I have a feeling that using MPI to pass this object would 
only pass the internal pointers to the data and not the data itself, making 
the object useless to other nodes.

Is there an easy way to 'copy' an object to another node, if an assignment 
operator is already available that performs the deep copy of data necessary?

Thanks for your help,
Arnab Chowdry 


0
Reply Arnab 1/25/2005 10:11:07 PM

Hi,

depending on your problem, you may have a look at Charm++ as another
solution for parallel programming with C++:

http://charm.cs.uiuc.edu/

Cheers - Reuti

In article <ct6g24$1asi$1@agate.berkeley.edu>, Arnab Chowdry
<spam@berkeley.edu> wrote:

> Hi all,
> 
> I am new to MPI, so please forgive me if this question has an obvious 
> answer. I have a large object in C++ that dynamically allocates memory for 
> its internal data. I have a feeling that using MPI to pass this object would 
> only pass the internal pointers to the data and not the data itself, making 
> the object useless to other nodes.
> 
> Is there an easy way to 'copy' an object to another node, if an assignment 
> operator is already available that performs the deep copy of data necessary?
> 
> Thanks for your help,
> Arnab Chowdry 
> 
>
0
Reply Reuti 1/25/2005 11:01:48 PM


Arnab Chowdry wrote:
> Hi all,
> 
> I am new to MPI, so please forgive me if this question has an obvious 
> answer. I have a large object in C++ that dynamically allocates memory for 
> its internal data. I have a feeling that using MPI to pass this object would 
> only pass the internal pointers to the data and not the data itself, making 
> the object useless to other nodes.
> 
> Is there an easy way to 'copy' an object to another node, if an assignment 
> operator is already available that performs the deep copy of data necessary?
> 
> Thanks for your help,
> Arnab Chowdry 

No, there's no easy way.

It's no different from moving a C structure via MPI which contains a pointer.
To do a deep copy of an object, you must define a type using
MPI_Type_create_struct which must be decomposed into only MPI data types (e.g.
MPI_CHAR).  Then you must expand any pointer-based member data into fixed-length
data before transport, and do the reverse after transport.

    Randy

-- 
Randy Crawford   http://www.ruf.rice.edu/~rand   rand AT rice DOT edu
0
Reply Randy 1/25/2005 11:51:57 PM

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Arnab Chowdry wrote:
| Hi all,
|
| I am new to MPI, so please forgive me if this question has an obvious
| answer. I have a large object in C++ that dynamically allocates memory
for
| its internal data. I have a feeling that using MPI to pass this object
would
| only pass the internal pointers to the data and not the data itself,
making
| the object useless to other nodes.
|
| Is there an easy way to 'copy' an object to another node, if an
assignment
| operator is already available that performs the deep copy of data
necessary?

There are several possible approaches, but all of them must result in
calling some kind of constructor on the receiving node side. Did you
consider solution with objects serialization? In the simplest case you
serialize your object to the plain MPI_CHAR table and send it making
unserialization after receive.

Best regards,

j.zola
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFB+rqTxWG8XCjlC/cRAks0AKCH1EmUxqju6SFbCAjAEtg7VlLMggCg3h7e
mk8WQXeDV2qaXODRGgQRuvA=
=pee4
-----END PGP SIGNATURE-----
0
Reply Jaroslaw 1/28/2005 10:20:03 PM

3 Replies
648 Views

(page loaded in 1.814 seconds)

Similiar Articles:













7/24/2012 7:47:58 PM


Reply: