<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Update: A Smart Way to Send a std::vector with MPI - and why it Fails</title>
	<atom:link href="http://www.thinkingparallel.com/2007/02/08/a-smart-way-to-send-a-stdvector-with-mpi-and-why-it-fails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thinkingparallel.com/2007/02/08/a-smart-way-to-send-a-stdvector-with-mpi-and-why-it-fails/</link>
	<description>A Blog on Parallel Programming and Concurrency by Michael Suess</description>
	<pubDate>Mon, 12 May 2008 00:13:23 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
		<item>
		<title>By: Mahantesh</title>
		<link>http://www.thinkingparallel.com/2007/02/08/a-smart-way-to-send-a-stdvector-with-mpi-and-why-it-fails/#comment-51315</link>
		<dc:creator>Mahantesh</dc:creator>
		<pubDate>Wed, 12 Mar 2008 17:32:44 +0000</pubDate>
		<guid isPermaLink="false">http://www.thinkingparallel.com/2007/02/08/a-smart-way-to-send-a-stdvector-with-mpi-and-why-it-fails/#comment-51315</guid>
		<description>Thanks! this works for me. I usually do vec1.reserve(N) within try and catch and reserve its place. The next operation will be .resize(N), that way you can hope for O(N) ((will not have to move data around if N is large.</description>
		<content:encoded><![CDATA[<p>Thanks! this works for me. I usually do vec1.reserve(N) within try and catch and reserve its place. The next operation will be .resize(N), that way you can hope for O(N) ((will not have to move data around if N is large.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stuart Dootson</title>
		<link>http://www.thinkingparallel.com/2007/02/08/a-smart-way-to-send-a-stdvector-with-mpi-and-why-it-fails/#comment-2289</link>
		<dc:creator>Stuart Dootson</dc:creator>
		<pubDate>Thu, 15 Feb 2007 18:26:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.thinkingparallel.com/2007/02/08/a-smart-way-to-send-a-stdvector-with-mpi-and-why-it-fails/#comment-2289</guid>
		<description>Ummmm - I think your students code is reasonably OK. They access the vector contents using the interface only - operator[]. That returns a reference to the first element of the vector contents. Taking it's address gives a pointer to the first location of the contiguous storage you mentioned. Nowhere are you accessing the *internals* of the vector object. It's like this (view with a monospace font!):

+-------------------------+
&#124; vector object internals &#124;
+-------------------------+
   &#124;
   &#124;
   V
   +-----------------+
   &#124; vector contents &#124;
   +-----------------+
   ^
   &#124;
   = &#38;vec[0]

memcpy is fine with a vector (though not idiomatic C++/STL - I tend to use std::copy instead).

You might like to look at Boost.MPI (http://www.generic-programming.org/~dgregor/boost.mpi/doc/index.html) - a C++ interface to MPI that's built on top of standard C MPI implementations.</description>
		<content:encoded><![CDATA[<p>Ummmm - I think your students code is reasonably OK. They access the vector contents using the interface only - operator[]. That returns a reference to the first element of the vector contents. Taking it&#8217;s address gives a pointer to the first location of the contiguous storage you mentioned. Nowhere are you accessing the *internals* of the vector object. It&#8217;s like this (view with a monospace font!):</p>
<p>+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br />
| vector object internals |<br />
+&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-+<br />
   |<br />
   |<br />
   V<br />
   +&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br />
   | vector contents |<br />
   +&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br />
   ^<br />
   |<br />
   = &amp;vec[0]</p>
<p>memcpy is fine with a vector (though not idiomatic C++/STL - I tend to use std::copy instead).</p>
<p>You might like to look at Boost.MPI (http://www.generic-programming.org/~dgregor/boost.mpi/doc/index.html) - a C++ interface to MPI that&#8217;s built on top of standard C MPI implementations.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: teki</title>
		<link>http://www.thinkingparallel.com/2007/02/08/a-smart-way-to-send-a-stdvector-with-mpi-and-why-it-fails/#comment-1926</link>
		<dc:creator>teki</dc:creator>
		<pubDate>Thu, 08 Feb 2007 11:10:34 +0000</pubDate>
		<guid isPermaLink="false">http://www.thinkingparallel.com/2007/02/08/a-smart-way-to-send-a-stdvector-with-mpi-and-why-it-fails/#comment-1926</guid>
		<description>Do not use resize, use reserve, that's what you want.

The statement of the article is false.
Recommended readings:
http://www.gotw.ca/publications/mill10.htm

An I recommend to read a few book about STL.</description>
		<content:encoded><![CDATA[<p>Do not use resize, use reserve, that&#8217;s what you want.</p>
<p>The statement of the article is false.<br />
Recommended readings:<br />
<a href="http://www.gotw.ca/publications/mill10.htm" rel="nofollow">http://www.gotw.ca/publications/mill10.htm</a></p>
<p>An I recommend to read a few book about STL.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wreel</title>
		<link>http://www.thinkingparallel.com/2007/02/08/a-smart-way-to-send-a-stdvector-with-mpi-and-why-it-fails/#comment-1923</link>
		<dc:creator>wreel</dc:creator>
		<pubDate>Thu, 08 Feb 2007 11:05:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.thinkingparallel.com/2007/02/08/a-smart-way-to-send-a-stdvector-with-mpi-and-why-it-fails/#comment-1923</guid>
		<description>That's actually safe.  std::vector types are, by design, STL's interface into legacy C array API calls.  The students looked like they did the proper research and it falls inline with Scott Meyers item 16 in "Effective STL".  If Stepanov had his druthers, you would/should have been able to pass &lt;code&gt;vec.begin()&lt;/code&gt; to &lt;code&gt;Recv()&lt;/code&gt; but quirkiness in certain STL implementations caused for the explicit call for the address of a reference.</description>
		<content:encoded><![CDATA[<p>That's actually safe.  std::vector types are, by design, STL's interface into legacy C array API calls.  The students looked like they did the proper research and it falls inline with Scott Meyers item 16 in "Effective STL".  If Stepanov had his druthers, you would/should have been able to pass [
<div class="igBar"><span id="lcode-1"><a href="#" onclick="javascript:showPlainTxt('code-1'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-1">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#93;</span>dmVjLmJlZ2luKCk=<span style="color:#006600; font-weight:bold;">&#91;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>] to [
<div class="igBar"><span id="lcode-2"><a href="#" onclick="javascript:showPlainTxt('code-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-2">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#93;</span>UmVjdigp<span style="color:#006600; font-weight:bold;">&#91;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>] but quirkiness in certain STL implementations caused for the explicit call for the address of a reference.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefan Eilemann</title>
		<link>http://www.thinkingparallel.com/2007/02/08/a-smart-way-to-send-a-stdvector-with-mpi-and-why-it-fails/#comment-1922</link>
		<dc:creator>Stefan Eilemann</dc:creator>
		<pubDate>Thu, 08 Feb 2007 10:58:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.thinkingparallel.com/2007/02/08/a-smart-way-to-send-a-stdvector-with-mpi-and-why-it-fails/#comment-1922</guid>
		<description>vector.resize can also be terrible slow, since you are inserting n elements into the vector. I discovered that when storing image data in a vector, and sending it over the network as described above. I'm now back using C arrays.</description>
		<content:encoded><![CDATA[<p>vector.resize can also be terrible slow, since you are inserting n elements into the vector. I discovered that when storing image data in a vector, and sending it over the network as described above. I'm now back using C arrays.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: teki</title>
		<link>http://www.thinkingparallel.com/2007/02/08/a-smart-way-to-send-a-stdvector-with-mpi-and-why-it-fails/#comment-1920</link>
		<dc:creator>teki</dc:creator>
		<pubDate>Thu, 08 Feb 2007 10:56:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.thinkingparallel.com/2007/02/08/a-smart-way-to-send-a-stdvector-with-mpi-and-why-it-fails/#comment-1920</guid>
		<description>"Counting on object-internals like the fact that it probably has a big block of memory inside to store the actual data will not do, although it may work with your present implementation!"

If it's a standard compliant STL implementation, then it have to work.

Recommended reading: http://www.gotw.ca/publications/mill10.htm</description>
		<content:encoded><![CDATA[<p>"Counting on object-internals like the fact that it probably has a big block of memory inside to store the actual data will not do, although it may work with your present implementation!"</p>
<p>If it's a standard compliant STL implementation, then it have to work.</p>
<p>Recommended reading: <a href="http://www.gotw.ca/publications/mill10.htm" rel="nofollow">http://www.gotw.ca/publications/mill10.htm</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
