Re: [OMPI users] Passing data structure

2008-04-12 Thread Jeff Squyres
Since you are using C++, you might also want to investigate the Boost C 
++ MPI bindings.


http://www.boost.org/doc/libs/1_35_0/doc/html/mpi.html



On Apr 11, 2008, at 12:33 PM, Alessandro Palandri wrote:

Hello,

I am a new user of MPI and I would like to have your opinion on the  
following issue.

With 1 processor I keep the data in

std::vector > X

Then I call a function that takes various arguments, among which  
X[ i ] and X[ j ], i.e. two sub-vectors of X.


With MPI I would have the same function execute on different  
processors for different values of i and j in X[ i ] and X[ j ].


From my understanding since std::vector is not an MPI type it cannot  
be passed neither as a message nor an element of an MPI structure. I  
thought of using


double X[200][4000]

which MPI would pass but I don't see how to isolate a single row,  
i.e. X[99] would not make sense in this context.


Any suggestion for an efficient and possibly simple solution?

Thank you for your help,

Alessandro

___
users mailing list
us...@open-mpi.org
http://www.open-mpi.org/mailman/listinfo.cgi/users



--
Jeff Squyres
Cisco Systems



Re: [OMPI users] Fwd: Problem with sending vectors

2008-04-12 Thread Andreas Schäfer
On 20:39 Fri 11 Apr , Jeff Squyres wrote:
> Also, it's been a long time since I've done anything serious in C++,  
> but are you guaranteed that &foo[x] for a vector<> will yield  
> contiguous memory?

Good question. I was used to believe so, but I just had a look at the
standard and couldn't find any guarantee on that subject... However,
if your implementation doesn't work that way, you're pretty much
screwed, as the vector's interface makes it hard to detect
non-contiguous blocks.

> You might be better off using the Boost C++ MPI bindings; they provide  
> all kinds of nifty things for classes, etc.

True, but sometimes this convenience comes at a cost:

"When communicating data types over MPI that are not fundamental to
MPI (such as strings, lists, and user-defined data types), Boost.MPI
must first serialize these data types into a buffer and then
communicate them; the receiver then copies the results into a buffer
before deserializing into an object on the other end. For some data
types, this overhead can be eliminated by using
is_mpi_datatype. However, variable-length data types such as strings
and lists cannot be MPI data types." [1]

AFAIK, boost::mpi will thus buffer all vectors to be sent. This might
not be as efficient as just feeding it a raw pointer and the number of
elements.

Cheers!
-Andreas

[1] 
http://www.boost.org/doc/libs/1_35_0/doc/html/mpi/tutorial.html#mpi.point_to_point


-- 

Andreas Schäfer
Cluster and Metacomputing Working Group
Friedrich-Schiller-Universität Jena, Germany
PGP/GPG key via keyserver
I'm a bright... http://www.the-brights.net


(\___/)
(+'.'+)
(")_(")
This is Bunny. Copy and paste Bunny into your 
signature to help him gain world domination!


pgpqrUTSVfv7G.pgp
Description: PGP signature