LAM/MPI logo

LAM/MPI General User's Mailing List Archives

  |   Home   |   Download   |   Documentation   |   FAQ   |   all just in this list

From: André Kempe (andre_at_[hidden])
Date: 2003-04-23 02:05:08


Hi,

I would be very causious with that assumption. I had a short glimpse at
the C++ standard (ISO 14482), and it says nothing about the requirered
memory-managment of the vector.

If it would do so, you could ask
a. what the allocator-template-argument is good for, and
b. why is there no function const T* data() similar to const char *
c_str() of std::string for dircect-memory-access

This would leave only three possibilities to get the stl::vector work
with MPI. Either create a temporary copy, or have a real close look at
your stl-implemetation, or write your own container that meets your
requirements.

Good Luck

André

Virgilio, Vincent wrote:

>I am under the impression that one of the (perhaps implicit) requirements of
>the C++ STL is that std::vectors are stored in contiguous memory. So the
>below code should work with all conformant C++ compilers.
>
>Vince Virgilio
>
>
>
>>-----Original Message-----
>>From: Vishal Sahay [mailto:vsahay_at_[hidden]]
>>Sent: Tuesday, April 22, 2003 9:17 PM
>>To: sbcair; General LAM/MPI mailing list
>>Subject: Re: LAM: MPI datatypes
>>
>>
>>It is possible to send STL vector<double> in the manner shown
>>in the second code.
>>
>>The traditional C way of doing it would be:
>>
>> void
>> foo(int array_len)
>> {
>> double *a;
>> a = malloc(sizeof(double) * array_len);
>>
>> /* do some work on a */
>>
>> MPI_Send(a, array_len, MPI_DOUBLE, dest, tag, comm);
>> }
>>
>>Using STL vectors, the code would be:
>>
>> void
>> foo(int array_len)
>> {
>> vector<double> a;
>>
>> /* do some work on a */
>>
>> MPI_Send(&a[0], array_len, MPI_DOUBLE, dest, tag, comm);
>> }
>>
>>This may not necessarily work with all compilers, but so far
>>has worked for most of them. Note that this seems to work
>>only for STL vectors and not STL lists or other STL stuffs.
>>
>>Infact it would work for vector<T> where T is just any common
>>datatypes or a simple struct.
>>
>>Hope this helps...
>>
>>-Vishal Sahay
>>===================================================================
>>(Graduate Student, CS Dept. Open Systems Lab
>>Indiana University, Bloomington) Make Today A LAM/MPI Day :)
>>http://cs.indiana.edu/~vsahay http://www.lam-mpi.org
>>===================================================================
>>
>>
>
>************************************
>If this email is not intended for you, or you are not responsible for the
>delivery of this message to the addressee, please note that this message may
>contain ITT Privileged/Proprietary Information. In such a case, you may not
>copy or deliver this message to anyone. You should destroy this message and
>kindly notify the sender by reply email. Information contained in this
>message that does not relate to the business of ITT is neither endorsed by
>nor attributable to ITT.
>************************************
>
>_______________________________________________
>This list is archived at http://www.lam-mpi.org/MailArchives/lam/
>
>
>