<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Patterns for Parallel Programming with the .NET Framework</title><link>http://blogs.msdn.com/b/pfxteam/archive/2009/11/09/9919848.aspx</link><description>I've recently written a detailed paper, "Patterns for Parallel Programming: Understanding and Applying Parallel Patterns with the .NET Framework 4", on implementing a variety of common parallel patterns with the .NET Framework 4. The paper is now live</description><dc:language>en-US</dc:language><generator>Telligent Evolution Platform Developer Build (Build: 5.6.50428.7875)</generator><item><title>re: Patterns for Parallel Programming with the .NET Framework</title><link>http://blogs.msdn.com/b/pfxteam/archive/2009/11/09/9919848.aspx#10111254</link><pubDate>Mon, 03 Jan 2011 21:45:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10111254</guid><dc:creator>Stephen Toub - MSFT</dc:creator><description>&lt;p&gt;AB, for my paper, there&amp;#39;s no separate download with the code. &amp;nbsp;If you&amp;#39;re interested in the recent book from the patterns &amp;amp; practices team on parallel patterns (&lt;a rel="nofollow" target="_new" href="http://msdn.microsoft.com/en-us/library/ff963553.aspx"&gt;msdn.microsoft.com/.../ff963553.aspx&lt;/a&gt;), you can find the code for that at &lt;a rel="nofollow" target="_new" href="http://parallelpatterns.codeplex.com"&gt;parallelpatterns.codeplex.com&lt;/a&gt;.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10111254" width="1" height="1"&gt;</description></item><item><title>re: Patterns for Parallel Programming with the .NET Framework</title><link>http://blogs.msdn.com/b/pfxteam/archive/2009/11/09/9919848.aspx#10107499</link><pubDate>Tue, 21 Dec 2010 04:50:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:10107499</guid><dc:creator>AB</dc:creator><description>&lt;p&gt;Excellenet patterns, From where I can download the complete samples from this book? For me the section CONTINUATION CHAINING is bit unclear, and bit confused about Task Walk&amp;lt;T&amp;gt;..&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10107499" width="1" height="1"&gt;</description></item><item><title>re: Patterns for Parallel Programming with the .NET Framework</title><link>http://blogs.msdn.com/b/pfxteam/archive/2009/11/09/9919848.aspx#9927535</link><pubDate>Mon, 23 Nov 2009 21:00:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9927535</guid><dc:creator>Stephen Toub - MSFT</dc:creator><description>&lt;p&gt;Thanks, Richard! &amp;nbsp;Nice catch. &amp;nbsp;Copy and paste error... I'll fix it when I repost the paper.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9927535" width="1" height="1"&gt;</description></item><item><title>re: Patterns for Parallel Programming with the .NET Framework</title><link>http://blogs.msdn.com/b/pfxteam/archive/2009/11/09/9919848.aspx#9927532</link><pubDate>Mon, 23 Nov 2009 20:58:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9927532</guid><dc:creator>Richard</dc:creator><description>&lt;p&gt;OK, I've found the problem:&lt;/p&gt;
&lt;p&gt;double partial = sum + 4.0 / (1.0 + x * x);&lt;/p&gt;
&lt;p&gt;sum += partial;&lt;/p&gt;
&lt;p&gt;You're adding sum twice. It should be:&lt;/p&gt;
&lt;p&gt;double partial = 4.0 / (1.0 + x * x);&lt;/p&gt;
&lt;p&gt;sum += partial;&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9927532" width="1" height="1"&gt;</description></item><item><title>re: Patterns for Parallel Programming with the .NET Framework</title><link>http://blogs.msdn.com/b/pfxteam/archive/2009/11/09/9919848.aspx#9927525</link><pubDate>Mon, 23 Nov 2009 20:50:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9927525</guid><dc:creator>Richard</dc:creator><description>&lt;p&gt;Great paper.&lt;/p&gt;
&lt;p&gt;Are you sure about the SerialPi algorithm on page 67? On my machine, with NUM_STEPS = 1000, the result is 4.28601621355331E+298; NUM_STEPS = 10000 gives Infinity.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9927525" width="1" height="1"&gt;</description></item><item><title>re: Patterns for Parallel Programming with the .NET Framework</title><link>http://blogs.msdn.com/b/pfxteam/archive/2009/11/09/9919848.aspx#9926483</link><pubDate>Fri, 20 Nov 2009 22:10:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9926483</guid><dc:creator>Matt</dc:creator><description>&lt;p&gt;Great paper. I'm really looking forward to the F# version! &lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9926483" width="1" height="1"&gt;</description></item><item><title>re: Patterns for Parallel Programming with the .NET Framework</title><link>http://blogs.msdn.com/b/pfxteam/archive/2009/11/09/9919848.aspx#9924155</link><pubDate>Wed, 18 Nov 2009 08:14:44 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9924155</guid><dc:creator>Stephen Toub - MSFT</dc:creator><description>&lt;p&gt;It's extremely unlikely that you'll end up with hundreds or thousands of threads, and even if you do, you likely have more fundamental issues to deal with than having to check one piece of state per thread. &amp;nbsp;Have you actually seen this approach to be problematic?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9924155" width="1" height="1"&gt;</description></item><item><title>re: Patterns for Parallel Programming with the .NET Framework</title><link>http://blogs.msdn.com/b/pfxteam/archive/2009/11/09/9919848.aspx#9923828</link><pubDate>Tue, 17 Nov 2009 20:32:49 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9923828</guid><dc:creator>Michael Cederberg DK</dc:creator><description>&lt;p&gt;But that still leaves me with potentially thousands of values to sample (in case different IOCP threads are posting threadlocal results).&lt;/p&gt;
&lt;p&gt;What I was hoping for was more like &amp;quot;CoreLocal&amp;lt;T&amp;gt;&amp;quot; ... that way I would only need to sample one value per core.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9923828" width="1" height="1"&gt;</description></item><item><title>re: Patterns for Parallel Programming with the .NET Framework</title><link>http://blogs.msdn.com/b/pfxteam/archive/2009/11/09/9919848.aspx#9923626</link><pubDate>Tue, 17 Nov 2009 15:41:37 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9923626</guid><dc:creator>Stephen Toub - MSFT</dc:creator><description>&lt;p&gt;Hi Michael-&lt;/p&gt;
&lt;p&gt;Glad you enjoyed the paper. &amp;nbsp;Consider checking out the ReductionVariable type in the Beta 2 samples at &lt;a rel="nofollow" target="_new" href="http://code.msdn.microsoft.com/ParExtSamples"&gt;http://code.msdn.microsoft.com/ParExtSamples&lt;/a&gt;. &amp;nbsp;It's a very thin wrapper on top of ThreadLocal&amp;lt;T&amp;gt; that maintains a list of all of the local values created. &amp;nbsp;Each of your threads can update the .Value property, which could contain the statistics for the local thread, and then your sampling routine would loop through the IEnumerable&amp;lt;T&amp;gt; .Values property.&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9923626" width="1" height="1"&gt;</description></item><item><title>re: Patterns for Parallel Programming with the .NET Framework</title><link>http://blogs.msdn.com/b/pfxteam/archive/2009/11/09/9919848.aspx#9923588</link><pubDate>Tue, 17 Nov 2009 14:49:09 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9923588</guid><dc:creator>Michael Cederberg DK</dc:creator><description>&lt;p&gt;Great paper, however here is a pattern that I did not find any guidance on: &lt;/p&gt;
&lt;p&gt;We have a highly parallel system with a few thousand very independent tasks executing concurrently (I hope soon to get a 64 core box to run it on). The system runs for days. From each of these tasks I would like to collect statistics: Number of items processed, Average processing time per item, etc. &amp;nbsp;At regular intervals I would like to sample these statistics.&lt;/p&gt;
&lt;p&gt;A naive implementation would protect the collected statistics with a lock, essentially serializing update of it. However such a pattern do not scale very well (and I would not like to introduce such locks in our otherwise almost lock free design).&lt;/p&gt;
&lt;p&gt;A nicer solution would keep an array of statistics data. Each update would only update one slot of statistics data thus removing the need for a lock. When sampling the data, we would loop through the array and aggregate statistics. The tricky thing is to find a good key for the array. ThreadId is not a good candidate as it can grow quite large (As I understand it, there are ~500 IO completion port threads allocated per core). A “core id” would be better, although there are some interesting synchronization issues there.&lt;/p&gt;
&lt;p&gt;I suspect the new ThreadLocal&amp;lt;T&amp;gt; class will not solve the problem either, as there will be one slot per thread (which is the essence of the ThreadLocal abstraction).&lt;/p&gt;
&lt;p&gt;What are your comments?&lt;/p&gt;
&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9923588" width="1" height="1"&gt;</description></item></channel></rss>