Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: Re: [OMPI users] Fwd: Problem with sending vectors
From: Andreas Schäfer (gentryx_at_[hidden])
Date: 2008-04-12 09:58:46


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!


  • application/pgp-signature attachment: stored