<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Yet Another [À Compléter] &#187; C#</title>
	<atom:link href="http://blog.neteril.org/category/programming/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.neteril.org</link>
	<description>Random thoughts of Jérémie Laval</description>
	<lastBuildDate>Mon, 19 Jul 2010 17:12:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Tying Mono and OpenCL</title>
		<link>http://blog.neteril.org/2010/06/18/tying-mono-and-opencl/</link>
		<comments>http://blog.neteril.org/2010/06/18/tying-mono-and-opencl/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 17:09:01 +0000</pubDate>
		<dc:creator>Jérémie Laval</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.neteril.org/?p=939</guid>
		<description><![CDATA[<p align="center"><a href="http://www.flickr.com/photos/un_owen/166787202/"><img src="http://blog.neteril.org/wp-content/uploads/2010/06/tortoise_hare.jpg" alt="tortoise_hare" title="tortoise_hare" width="507" height="380" class="aligncenter size-full wp-image-953" /></a></p>
<p>One of the cool buzzword these days beside parallel computing is GPGPU as in General Purpose GPU.</p>
<p>The base idea of GPGPU is to allow a programmer to tape in the parallel processing capacities of a GPU to do something different than pixel crushing (even though it mostly boils down to that very application most of time). </p>
<p>GPGPU isn&#8217;t new and for a long time vendors have provided their own rather low-level toolkit to program arbitrarily a GPU. As often, someone stepped up one day and proposed a unified API on top of all the vendor specificities. In our case, that API is a standard defined by the <a href="http://www.khronos.org/">Khronos group</a> (think OpenGL) and is named <a href="http://www.khronos.org/opencl/">OpenCL</a>.</p>
<p>OpenCL defines both a high-level C API to manipulate GPU (plus other friends) and a C-like intermediate language that is compiled and ultimately run on the device. It&#8217;s actually the same model as shader programming.</p>
<p>In the pursuit of <a href="http://www.mono-project.com">Mono</a> world-domination and following the implementation of PLinq that strived to be an easy way for programmer to access the multicore architecture of our processors via Linq, I hereby introduce <em>GLinq</em> (unoriginal acronym for GPU Linq) which this time use your graphic card to execute Linq queries via OpenCL. </p>
<p>GLinq is still much in its infancy and currently only support the Linq&#8217;s Select operator but I hope to be able to implement several other operators (at least the classic Where-Aggregate combo). The end goal is also to provide a new set of operator to allow OpenGL code to access the results of the computation without doing a roundtrip between CPU and GPU.</p>
<p>As I said previously, GLinq has the same design goal as PLinq which was to provide a totally new execution model for programmer in the most transparent way possible and with little modification to existing code. In our case, this prerequisite is rather tricky since you are juggling between two totally different worlds.</p>
<p>GLinq tries to provide that seamless experience with two features. The first one is the use of expression trees and C# compiler lambda magic to automatically capture the sense of a C# expression and rewrite it to OpenCL intermediate language. The second one is an automatic mapping of C# types and methods (e.g. Math class functions) to corresponding OpenCL symbols without however sacrificing OpenCL specificities which are also exposed through a C# API (not complete). </p>
<p>Of course, the GLinq API is still a transcription of standard Linq so you use it in the same way via the GpuEnumerable class. At the moment, the only input support are Range and Repeat but that will easily be changed to support any kind of IEnumerable.</p>
<p>Below is an example of the kind of query you can already execute:</p>
<pre class="brush: csharp;">

var query = GpuEnumerable.Range (-20, 50)
			 .Select ((i) =&gt; i * -2 + 3)
			 .Select ((i) =&gt; Math.Abs (i))
			 .Select ((i) =&gt; ExtraMath.Ldexp ((float)i, 2f))
			 .Select ((i) =&gt; (int)i);

foreach (var i in query)
	Console.Write (&quot;{0}, &quot;, i.ToString ());
</pre>
<p>From what you can see, there are a lot of select operators here. It comes from the fact that the compiler is only able to convert a pure expression lambda to its corresponding expression tree. You can circumvent this limitation by building yourself the expression tree or by using any compiler/interpreter that outputs expression trees (e.g. IronPython, IronRuby, Bechamel).</p>
<p>On a final note, there is an acknowledged bug in at least NVidia implementation of OpenCL which makes Mono doesn&#8217;t play nice with it. This is due to the fact that (most) OpenCL implementations use LLVM for code generation/optimization which in turns mess with Mono internal working.</p>
<p>This problem is going to be fixed in the next NVidia driver iteration but as a work-around you can apply <a href="http://monobin.com/__md461851">this simple patch</a> to mono. I put <del datetime="2010-06-18T18:01:11+00:00">SIGWINCH</del>SIGXFSZ there because it looks cool and seems generally unused but any other should do the trick.</p>
<p>Code in its proof-of-concept form is living here: <a href="http://git.neteril.org/glinq/">http://git.neteril.org/glinq/</a></p>
]]></description>
			<content:encoded><![CDATA[<p align="center"><a href="http://www.flickr.com/photos/un_owen/166787202/"><img src="http://blog.neteril.org/wp-content/uploads/2010/06/tortoise_hare.jpg" alt="tortoise_hare" title="tortoise_hare" width="507" height="380" class="aligncenter size-full wp-image-953" /></a></p>
<p>One of the cool buzzword these days beside parallel computing is GPGPU as in General Purpose GPU.</p>
<p>The base idea of GPGPU is to allow a programmer to tape in the parallel processing capacities of a GPU to do something different than pixel crushing (even though it mostly boils down to that very application most of time). </p>
<p>GPGPU isn&#8217;t new and for a long time vendors have provided their own rather low-level toolkit to program arbitrarily a GPU. As often, someone stepped up one day and proposed a unified API on top of all the vendor specificities. In our case, that API is a standard defined by the <a href="http://www.khronos.org/">Khronos group</a> (think OpenGL) and is named <a href="http://www.khronos.org/opencl/">OpenCL</a>.</p>
<p>OpenCL defines both a high-level C API to manipulate GPU (plus other friends) and a C-like intermediate language that is compiled and ultimately run on the device. It&#8217;s actually the same model as shader programming.</p>
<p>In the pursuit of <a href="http://www.mono-project.com">Mono</a> world-domination and following the implementation of PLinq that strived to be an easy way for programmer to access the multicore architecture of our processors via Linq, I hereby introduce <em>GLinq</em> (unoriginal acronym for GPU Linq) which this time use your graphic card to execute Linq queries via OpenCL. </p>
<p>GLinq is still much in its infancy and currently only support the Linq&#8217;s Select operator but I hope to be able to implement several other operators (at least the classic Where-Aggregate combo). The end goal is also to provide a new set of operator to allow OpenGL code to access the results of the computation without doing a roundtrip between CPU and GPU.</p>
<p>As I said previously, GLinq has the same design goal as PLinq which was to provide a totally new execution model for programmer in the most transparent way possible and with little modification to existing code. In our case, this prerequisite is rather tricky since you are juggling between two totally different worlds.</p>
<p>GLinq tries to provide that seamless experience with two features. The first one is the use of expression trees and C# compiler lambda magic to automatically capture the sense of a C# expression and rewrite it to OpenCL intermediate language. The second one is an automatic mapping of C# types and methods (e.g. Math class functions) to corresponding OpenCL symbols without however sacrificing OpenCL specificities which are also exposed through a C# API (not complete). </p>
<p>Of course, the GLinq API is still a transcription of standard Linq so you use it in the same way via the GpuEnumerable class. At the moment, the only input support are Range and Repeat but that will easily be changed to support any kind of IEnumerable.</p>
<p>Below is an example of the kind of query you can already execute:</p>
<pre class="brush: csharp;">

var query = GpuEnumerable.Range (-20, 50)
			 .Select ((i) =&gt; i * -2 + 3)
			 .Select ((i) =&gt; Math.Abs (i))
			 .Select ((i) =&gt; ExtraMath.Ldexp ((float)i, 2f))
			 .Select ((i) =&gt; (int)i);

foreach (var i in query)
	Console.Write (&quot;{0}, &quot;, i.ToString ());
</pre>
<p>From what you can see, there are a lot of select operators here. It comes from the fact that the compiler is only able to convert a pure expression lambda to its corresponding expression tree. You can circumvent this limitation by building yourself the expression tree or by using any compiler/interpreter that outputs expression trees (e.g. IronPython, IronRuby, Bechamel).</p>
<p>On a final note, there is an acknowledged bug in at least NVidia implementation of OpenCL which makes Mono doesn&#8217;t play nice with it. This is due to the fact that (most) OpenCL implementations use LLVM for code generation/optimization which in turns mess with Mono internal working.</p>
<p>This problem is going to be fixed in the next NVidia driver iteration but as a work-around you can apply <a href="http://monobin.com/__md461851">this simple patch</a> to mono. I put <del datetime="2010-06-18T18:01:11+00:00">SIGWINCH</del>SIGXFSZ there because it looks cool and seems generally unused but any other should do the trick.</p>
<p>Code in its proof-of-concept form is living here: <a href="http://git.neteril.org/glinq/">http://git.neteril.org/glinq/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.neteril.org/2010/06/18/tying-mono-and-opencl/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Zencomic 0.3 &#8211; &#171;&#160;Holy Crêpe&#160;&#187;</title>
		<link>http://blog.neteril.org/2010/05/09/zencomic-0-3-holy-crepe/</link>
		<comments>http://blog.neteril.org/2010/05/09/zencomic-0-3-holy-crepe/#comments</comments>
		<pubDate>Sun, 09 May 2010 18:57:43 +0000</pubDate>
		<dc:creator>Jérémie Laval</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[zencomic]]></category>

		<guid isPermaLink="false">http://blog.neteril.org/?p=911</guid>
		<description><![CDATA[<p align="center"><a href="http://icanhascheezburger.com/2009/04/01/funny-pictures-holy-crepe/"><img src="http://blog.neteril.org/wp-content/uploads/2010/05/holy-crepe.jpg" alt="holy-crepe" title="holy-crepe" width="500" height="336" class="aligncenter size-full wp-image-912" /></a></p>
<p>I&#8217;m proud to announce the next release of <a href="http://neteril.org/projects/zencomic/">Zencomic</a>, the comic strip-driven productivity enhancer that periodically makes your day funnier by showing comic like Dilbert or XKCD in a bubble.</p>
<h3>New stuff</h3>
<p>This release packs a fair number of internal change, UI polishing and a good deal of new comic providers for your pleasure.</p>
<h4>Comic backends</h4>
<p>Among comic newcomers, you will find <a href="http://trollcats.com/">Trollcats</a> joining their lolz counterparts and the duo <a href="http://garfield.com/">Garfield</a> and <a href="http://garfieldminusgarfield.net/">Garfield Minus Garfield</a> (contributed by <a href="http://monotorrent.blogspot.com/">Alan Mc Govern</a>) for even more fluffy fun (or not).</p>
<p align="center"><img src="http://blog.neteril.org/wp-content/uploads/2010/05/zencomic_screen_garfield.png" alt="zencomic_screen_garfield" title="zencomic_screen_garfield" width="612" height="229" class="aligncenter size-full wp-image-923" /><br /><em>Welcome to the laziest cat on Earth</em></p>
<h4>Cosmetic changes</h4>
<p>In Window mode, the comic are now correctly resized to take reasonable space on your screen. A link to the original strip is also supplied at the bottom of the window.</p>
<p>The preferences panel has been overhauled to be less cluttered and provide direct management of comic addins in the UI. It&#8217;s also now hopefully completely WM proof when it comes to showing up focused.</p>
<p align="center"><img src="http://blog.neteril.org/wp-content/uploads/2010/05/2010-05-09-192712_355x375_scrot.png" alt="2010-05-09-192712_355x375_scrot" title="2010-05-09-192712_355x375_scrot" width="355" height="375" class="aligncenter size-full wp-image-920" /><br /><em>Loaded addins configuration</em></p>
<h4>Misc</h4>
<ul>
<li>Comic are shuffled randomly and served in a round-robin fashion to avoid duplicate fun</li>
<li>Zencomic haz a new icon</li>
<li>Repository has been autotool-ified so that you can directly and easily build from git master</li>
<li>Refactorised addin code</li>
</ul>
<p align="center"><img src="http://blog.neteril.org/wp-content/uploads/2010/05/zencomic_icon.png" alt="zencomic_icon" title="zencomic_icon" width="256" height="256" class="aligncenter size-full wp-image-925" /><br /><em>New icon with my poor artistic foo</em></p>
<h3>Download</h3>
<p>Tarball: <a href="http://neteril.org/projects/zencomic/zencomic-0.3.tar.gz">http://neteril.org/projects/zencomic/zencomic-0.3.tar.gz</a><br />
Git repository:  <a href="http://git.neteril.org/zencomic/">http://git.neteril.org/zencomic/</a</p>
<p>Cheers!</p>
]]></description>
			<content:encoded><![CDATA[<p align="center"><a href="http://icanhascheezburger.com/2009/04/01/funny-pictures-holy-crepe/"><img src="http://blog.neteril.org/wp-content/uploads/2010/05/holy-crepe.jpg" alt="holy-crepe" title="holy-crepe" width="500" height="336" class="aligncenter size-full wp-image-912" /></a></p>
<p>I&#8217;m proud to announce the next release of <a href="http://neteril.org/projects/zencomic/">Zencomic</a>, the comic strip-driven productivity enhancer that periodically makes your day funnier by showing comic like Dilbert or XKCD in a bubble.</p>
<h3>New stuff</h3>
<p>This release packs a fair number of internal change, UI polishing and a good deal of new comic providers for your pleasure.</p>
<h4>Comic backends</h4>
<p>Among comic newcomers, you will find <a href="http://trollcats.com/">Trollcats</a> joining their lolz counterparts and the duo <a href="http://garfield.com/">Garfield</a> and <a href="http://garfieldminusgarfield.net/">Garfield Minus Garfield</a> (contributed by <a href="http://monotorrent.blogspot.com/">Alan Mc Govern</a>) for even more fluffy fun (or not).</p>
<p align="center"><img src="http://blog.neteril.org/wp-content/uploads/2010/05/zencomic_screen_garfield.png" alt="zencomic_screen_garfield" title="zencomic_screen_garfield" width="612" height="229" class="aligncenter size-full wp-image-923" /><br /><em>Welcome to the laziest cat on Earth</em></p>
<h4>Cosmetic changes</h4>
<p>In Window mode, the comic are now correctly resized to take reasonable space on your screen. A link to the original strip is also supplied at the bottom of the window.</p>
<p>The preferences panel has been overhauled to be less cluttered and provide direct management of comic addins in the UI. It&#8217;s also now hopefully completely WM proof when it comes to showing up focused.</p>
<p align="center"><img src="http://blog.neteril.org/wp-content/uploads/2010/05/2010-05-09-192712_355x375_scrot.png" alt="2010-05-09-192712_355x375_scrot" title="2010-05-09-192712_355x375_scrot" width="355" height="375" class="aligncenter size-full wp-image-920" /><br /><em>Loaded addins configuration</em></p>
<h4>Misc</h4>
<ul>
<li>Comic are shuffled randomly and served in a round-robin fashion to avoid duplicate fun</li>
<li>Zencomic haz a new icon</li>
<li>Repository has been autotool-ified so that you can directly and easily build from git master</li>
<li>Refactorised addin code</li>
</ul>
<p align="center"><img src="http://blog.neteril.org/wp-content/uploads/2010/05/zencomic_icon.png" alt="zencomic_icon" title="zencomic_icon" width="256" height="256" class="aligncenter size-full wp-image-925" /><br /><em>New icon with my poor artistic foo</em></p>
<h3>Download</h3>
<p>Tarball: <a href="http://neteril.org/projects/zencomic/zencomic-0.3.tar.gz">http://neteril.org/projects/zencomic/zencomic-0.3.tar.gz</a><br />
Git repository:  <a href="http://git.neteril.org/zencomic/">http://git.neteril.org/zencomic/</a</p>
<p>Cheers!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.neteril.org/2010/05/09/zencomic-0-3-holy-crepe/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PLinq is in</title>
		<link>http://blog.neteril.org/2010/04/17/plinq-is-in/</link>
		<comments>http://blog.neteril.org/2010/04/17/plinq-is-in/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 22:42:56 +0000</pubDate>
		<dc:creator>Jérémie Laval</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.neteril.org/?p=889</guid>
		<description><![CDATA[<p align="center"><div id="attachment_890" class="wp-caption aligncenter" style="width: 517px"><a href="http://www.flickr.com/photos/ecstaticist/3055718118/"><img src="http://blog.neteril.org/wp-content/uploads/2010/04/header_plinq.jpg" alt="The Delta by ecstaticist under CC by-nc-sa" title="The Delta by ecstaticist under CC by-nc-sa" width="507" height="306" class="size-full wp-image-890" /></a><p class="wp-caption-text">It's all about splitting work</p></div></p>
<p>At long last, <a href="http://msdn.microsoft.com/en-us/library/dd460688(VS.100).aspx">PLinq</a> has finally <a href="http://twitter.com/migueldeicaza/status/12241543855">found its way into Mono trunk</a> as what can be considered a preview release. The code has seen a major rewrite compared to the initial implementation done during earlier Google Summer of Code which lacked flexibility and correctness.</p>
<p>Public API is complete except some operator still not implemented. In addition and as implied by the preview title, the current code hasn&#8217;t been tested against all possible flavor of query so it might or might not work for you (i.e. deadlock). If that&#8217;s the case, don&#8217;t hesitate to fill a bug report with a query reproducing the problem. The more query I have, the more robust we can shape future release.</p>
<p>By the way, these <a href="http://blog.neteril.org/2009/08/16/how-to-get-the-max-out-of-your-plinq-query/">PLinq performance tips</a> still hold true.</p>
]]></description>
			<content:encoded><![CDATA[<p align="center"><div id="attachment_890" class="wp-caption aligncenter" style="width: 517px"><a href="http://www.flickr.com/photos/ecstaticist/3055718118/"><img src="http://blog.neteril.org/wp-content/uploads/2010/04/header_plinq.jpg" alt="The Delta by ecstaticist under CC by-nc-sa" title="The Delta by ecstaticist under CC by-nc-sa" width="507" height="306" class="size-full wp-image-890" /></a><p class="wp-caption-text">It's all about splitting work</p></div></p>
<p>At long last, <a href="http://msdn.microsoft.com/en-us/library/dd460688(VS.100).aspx">PLinq</a> has finally <a href="http://twitter.com/migueldeicaza/status/12241543855">found its way into Mono trunk</a> as what can be considered a preview release. The code has seen a major rewrite compared to the initial implementation done during earlier Google Summer of Code which lacked flexibility and correctness.</p>
<p>Public API is complete except some operator still not implemented. In addition and as implied by the preview title, the current code hasn&#8217;t been tested against all possible flavor of query so it might or might not work for you (i.e. deadlock). If that&#8217;s the case, don&#8217;t hesitate to fill a bug report with a query reproducing the problem. The more query I have, the more robust we can shape future release.</p>
<p>By the way, these <a href="http://blog.neteril.org/2009/08/16/how-to-get-the-max-out-of-your-plinq-query/">PLinq performance tips</a> still hold true.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.neteril.org/2010/04/17/plinq-is-in/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Wicd support patch for Banshee</title>
		<link>http://blog.neteril.org/2009/10/06/wicd-support-patch-for-banshee/</link>
		<comments>http://blog.neteril.org/2009/10/06/wicd-support-patch-for-banshee/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 21:25:38 +0000</pubDate>
		<dc:creator>Jérémie Laval</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.neteril.org/?p=700</guid>
		<description><![CDATA[<p>Shameless plug to tell I&#8217;m alive <img src='http://blog.neteril.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  .</p>
<p>If you are using <a href="http://wicd.sourceforge.net/">Wicd</a> and usually stare at Banshee trying to download cover art or post to last.fm while you are disconnected, <a href="http://neteril.org/mono/wicd-support.patch">the following patch</a> add just the support to fix this.</p>
<p>Here is the associated <a href="https://bugzilla.gnome.org/show_bug.cgi?id=596918">bug report</a> to get the patch integrated.</p>
<p>In other news, school restarted with its bunch of new responsibilities, limiting significantly free hacking time.</p>
]]></description>
			<content:encoded><![CDATA[<p>Shameless plug to tell I&#8217;m alive <img src='http://blog.neteril.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  .</p>
<p>If you are using <a href="http://wicd.sourceforge.net/">Wicd</a> and usually stare at Banshee trying to download cover art or post to last.fm while you are disconnected, <a href="http://neteril.org/mono/wicd-support.patch">the following patch</a> add just the support to fix this.</p>
<p>Here is the associated <a href="https://bugzilla.gnome.org/show_bug.cgi?id=596918">bug report</a> to get the patch integrated.</p>
<p>In other news, school restarted with its bunch of new responsibilities, limiting significantly free hacking time.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.neteril.org/2009/10/06/wicd-support-patch-for-banshee/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get the max out of your PLinq query</title>
		<link>http://blog.neteril.org/2009/08/16/how-to-get-the-max-out-of-your-plinq-query/</link>
		<comments>http://blog.neteril.org/2009/08/16/how-to-get-the-max-out-of-your-plinq-query/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 17:34:15 +0000</pubDate>
		<dc:creator>Jérémie Laval</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Google Summer of Code 2009]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://blog.neteril.org/?p=685</guid>
		<description><![CDATA[<p>Here are some tips you should follow if you want to get the maximum performance out of a Linq query parallelized with PLinq (at least with upcoming Mono version) :</p>
<ul>
<li>
<p>Use an indexed data structure as your source like an array, a list or anything which implements the generic IList&lt;T&gt; interface.</p>
<p>You can also use <a href="http://msdn.microsoft.com/en-us/library/dd268181%28VS.100%29.aspx">ParallelEnumerable.Repeat</a> and <a href="http://msdn.microsoft.com/en-us/library/system.linq.parallelenumerable.range%28VS.100%29.aspx">ParallelEnumerable.Range</a> as input. Notice the &#8216;Parallel&#8217; word in front as it&#8217;s not the same as Enumerable.(Range|Repeat)</p>
</li>
<li>
<p>Never use an ordering operator like OrderBy and never assume that the query should be ordered.</p>
<p>The overloads of some operator that provide an index integer are also to avoid.</p>
</li>
<li>
<p>As a general rule, try to stick to the general scheme of <a href="http://msdn.microsoft.com/en-us/library/dd383966%28VS.100%29.aspx">Select</a>-<a href="http://msdn.microsoft.com/en-us/library/dd384150%28VS.100%29.aspx">Where</a>-<a href="http://msdn.microsoft.com/en-us/library/dd383667%28VS.100%29.aspx">Aggregate</a> with any number of Select and Where (like the famous <a href="http://en.wikipedia.org/wiki/MapReduce">MapReduce</a>).</p>
<p>The syntactic sugar operators based on Aggregate like Min, Max, Average, etc&#8230; can also be used.</p>
</li>
<li>
<p>If you can manage it in your code, use the <a href="http://msdn.microsoft.com/en-us/library/dd383744%28VS.100%29.aspx">ForAll</a> method with an action delegate instead of iterating over the query with <code>foreach</code></p>
</li>
<li>
<p>Of course, forbid any synchronization (locks, semaphore, &#8230;) inside the operator selectors/predicates. The purest your lambdas are, the better.</p>
</li>
<li>
<p>The functions used with operators should be predictive and stable i.e. not depend on something uncertain time-wise like a network call and should yield approximately the same execution time with each input.</p>
<p>Sure, this is not always possible but if it is, it does prevent the engine from having to repeatedly balance the query execution itself.</p>
</li>
</ul>
<p>The <a href="http://msdn.microsoft.com/en-us/library/dd460688%28VS.100%29.aspx">PLinq MSDN page</a> contains some additional tricks and explanations if you are interested.</p>
]]></description>
			<content:encoded><![CDATA[<p>Here are some tips you should follow if you want to get the maximum performance out of a Linq query parallelized with PLinq (at least with upcoming Mono version) :</p>
<ul>
<li>
<p>Use an indexed data structure as your source like an array, a list or anything which implements the generic IList&lt;T&gt; interface.</p>
<p>You can also use <a href="http://msdn.microsoft.com/en-us/library/dd268181%28VS.100%29.aspx">ParallelEnumerable.Repeat</a> and <a href="http://msdn.microsoft.com/en-us/library/system.linq.parallelenumerable.range%28VS.100%29.aspx">ParallelEnumerable.Range</a> as input. Notice the &#8216;Parallel&#8217; word in front as it&#8217;s not the same as Enumerable.(Range|Repeat)</p>
</li>
<li>
<p>Never use an ordering operator like OrderBy and never assume that the query should be ordered.</p>
<p>The overloads of some operator that provide an index integer are also to avoid.</p>
</li>
<li>
<p>As a general rule, try to stick to the general scheme of <a href="http://msdn.microsoft.com/en-us/library/dd383966%28VS.100%29.aspx">Select</a>-<a href="http://msdn.microsoft.com/en-us/library/dd384150%28VS.100%29.aspx">Where</a>-<a href="http://msdn.microsoft.com/en-us/library/dd383667%28VS.100%29.aspx">Aggregate</a> with any number of Select and Where (like the famous <a href="http://en.wikipedia.org/wiki/MapReduce">MapReduce</a>).</p>
<p>The syntactic sugar operators based on Aggregate like Min, Max, Average, etc&#8230; can also be used.</p>
</li>
<li>
<p>If you can manage it in your code, use the <a href="http://msdn.microsoft.com/en-us/library/dd383744%28VS.100%29.aspx">ForAll</a> method with an action delegate instead of iterating over the query with <code>foreach</code></p>
</li>
<li>
<p>Of course, forbid any synchronization (locks, semaphore, &#8230;) inside the operator selectors/predicates. The purest your lambdas are, the better.</p>
</li>
<li>
<p>The functions used with operators should be predictive and stable i.e. not depend on something uncertain time-wise like a network call and should yield approximately the same execution time with each input.</p>
<p>Sure, this is not always possible but if it is, it does prevent the engine from having to repeatedly balance the query execution itself.</p>
</li>
</ul>
<p>The <a href="http://msdn.microsoft.com/en-us/library/dd460688%28VS.100%29.aspx">PLinq MSDN page</a> contains some additional tricks and explanations if you are interested.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.neteril.org/2009/08/16/how-to-get-the-max-out-of-your-plinq-query/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Follow-up on OpenVG support for Moonligh</title>
		<link>http://blog.neteril.org/2009/07/27/follow-up-on-openvg-support-for-moonlight/</link>
		<comments>http://blog.neteril.org/2009/07/27/follow-up-on-openvg-support-for-moonlight/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 18:12:52 +0000</pubDate>
		<dc:creator>Jérémie Laval</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://garuma.wordpress.com/?p=666</guid>
		<description><![CDATA[<p>Interested by the stuff I <a href="http://garuma.wordpress.com/2009/07/16/joining-the-moonlight-fun/">demonstrated</a> some weeks ago ?</p>
<p>Check out the following <a href="http://lists.ximian.com/pipermail/moonlight-list/2009-July/000561.html">message</a> on Moonlight mailing-list for instructions on how to get the same thing.</p>
<p>Just to make you salivate :</p>
<p align="center"><span class="youtube">
<object width="425" height="355">
<param name="movie" value="http://www.youtube.com/v/Ekfb6jCyDmM&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0?rel=1" />
<param name="allowFullScreen" value="true" />
<embed wmode="transparent" src="http://www.youtube.com/v/Ekfb6jCyDmM&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0?rel=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="355"></embed>
<param name="wmode" value="transparent" />
</object>
</span><p><a href="http://www.youtube.com/watch?v=Ekfb6jCyDmM">www.youtube.com/watch?v=Ekfb6jCyDmM</a></p><br />
<br /><em>BubbleMark running at ~50 fps without too much visual glitches</em><br />
(direct link : <a href="http://www.youtube.com/watch?v=Ekfb6jCyDmM">http://www.youtube.com/watch?v=Ekfb6jCyDmM</a>)</p>
]]></description>
			<content:encoded><![CDATA[<p>Interested by the stuff I <a href="http://garuma.wordpress.com/2009/07/16/joining-the-moonlight-fun/">demonstrated</a> some weeks ago ?</p>
<p>Check out the following <a href="http://lists.ximian.com/pipermail/moonlight-list/2009-July/000561.html">message</a> on Moonlight mailing-list for instructions on how to get the same thing.</p>
<p>Just to make you salivate :</p>
<p align="center"><span class="youtube">
<object width="425" height="355">
<param name="movie" value="http://www.youtube.com/v/Ekfb6jCyDmM&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0?rel=1" />
<param name="allowFullScreen" value="true" />
<embed wmode="transparent" src="http://www.youtube.com/v/Ekfb6jCyDmM&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0?rel=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="355"></embed>
<param name="wmode" value="transparent" />
</object>
</span><p><a href="http://www.youtube.com/watch?v=Ekfb6jCyDmM">www.youtube.com/watch?v=Ekfb6jCyDmM</a></p><br />
<br /><em>BubbleMark running at ~50 fps without too much visual glitches</em><br />
(direct link : <a href="http://www.youtube.com/watch?v=Ekfb6jCyDmM">http://www.youtube.com/watch?v=Ekfb6jCyDmM</a>)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.neteril.org/2009/07/27/follow-up-on-openvg-support-for-moonlight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Joining the Moonlight fun</title>
		<link>http://blog.neteril.org/2009/07/16/joining-the-moonlight-fun/</link>
		<comments>http://blog.neteril.org/2009/07/16/joining-the-moonlight-fun/#comments</comments>
		<pubDate>Thu, 16 Jul 2009 15:07:17 +0000</pubDate>
		<dc:creator>Jérémie Laval</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://garuma.wordpress.com/?p=660</guid>
		<description><![CDATA[<p>Watching my teammate hacking on moonlight was sure to detain on me someday. So when <a href="http://monotorrent.blogspot.com/">Alan</a> talked about making <a href="http://mono-project.com/Moonlight">Moonlight</a> run on top of <a href="http://en.wikipedia.org/wiki/OpenVG">OpenVG</a> I got pretty hooked.</p>
<p>Two hacking days later, I actually got something to &laquo;&nbsp;work&nbsp;&raquo;. At the moment it&#8217;s quite rough, hacky and it probably kills kitteh too (be careful, it makes shana angry, you wouldn&#8217;t like that).</p>
<p>Basically, what I did is to plug the OpenVG layer inside Moonlight custom version of cairo (using <a href="http://lists.cairographics.org/archives/cairo/2008-January/012833.html">that code</a> as a base) and then tweaked Moonlight to use the new surface (together with some changes in how drawing and caching is done internally).</p>
<p>Following is a screencast of the thing running <a href="http://bubblemark.com/silverlight2.html">Bubble Mark</a> :</p>
<p align="center"><span class="youtube">
<object width="425" height="355">
<param name="movie" value="http://www.youtube.com/v/dywInr08ySg&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0?rel=1" />
<param name="allowFullScreen" value="true" />
<embed wmode="transparent" src="http://www.youtube.com/v/dywInr08ySg&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0?rel=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="355"></embed>
<param name="wmode" value="transparent" />
</object>
</span><p><a href="http://www.youtube.com/watch?v=dywInr08ySg">www.youtube.com/watch?v=dywInr08ySg</a></p><br />
<br />
(Direct link : <a href="http://www.youtube.com/watch?v=dywInr08ySg">http://www.youtube.com/watch?v=dywInr08ySg</a>)</p>
<p>As you can see there are a lot of drawing issues remaining but the basic stuff is here. The code is not terribly faster (+10 fps or so) but that may come either from a bug in my graphic card driver (it already does the bizarre thing of slowing down after some time) or an other part of Moonlight.</p>
<p>It will definitely be better when OpenVG becomes more widespread, has more optimized implementations and can actually run on its own rather than on top of OpenGL (I&#8217;m eager to try that on top of Gallium3D when it will be ready).</p>
<p>As for inclusion in the mainline tree, I don&#8217;t know. I mostly did the thing for fun as a proof-of-concept and it&#8217;s certainly far too crappy to ever get integrated as is, but maybe someone will step up and do it correctly later <img src='http://blog.neteril.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  .</p>
]]></description>
			<content:encoded><![CDATA[<p>Watching my teammate hacking on moonlight was sure to detain on me someday. So when <a href="http://monotorrent.blogspot.com/">Alan</a> talked about making <a href="http://mono-project.com/Moonlight">Moonlight</a> run on top of <a href="http://en.wikipedia.org/wiki/OpenVG">OpenVG</a> I got pretty hooked.</p>
<p>Two hacking days later, I actually got something to &laquo;&nbsp;work&nbsp;&raquo;. At the moment it&#8217;s quite rough, hacky and it probably kills kitteh too (be careful, it makes shana angry, you wouldn&#8217;t like that).</p>
<p>Basically, what I did is to plug the OpenVG layer inside Moonlight custom version of cairo (using <a href="http://lists.cairographics.org/archives/cairo/2008-January/012833.html">that code</a> as a base) and then tweaked Moonlight to use the new surface (together with some changes in how drawing and caching is done internally).</p>
<p>Following is a screencast of the thing running <a href="http://bubblemark.com/silverlight2.html">Bubble Mark</a> :</p>
<p align="center"><span class="youtube">
<object width="425" height="355">
<param name="movie" value="http://www.youtube.com/v/dywInr08ySg&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0?rel=1" />
<param name="allowFullScreen" value="true" />
<embed wmode="transparent" src="http://www.youtube.com/v/dywInr08ySg&amp;color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0?rel=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="355"></embed>
<param name="wmode" value="transparent" />
</object>
</span><p><a href="http://www.youtube.com/watch?v=dywInr08ySg">www.youtube.com/watch?v=dywInr08ySg</a></p><br />
<br />
(Direct link : <a href="http://www.youtube.com/watch?v=dywInr08ySg">http://www.youtube.com/watch?v=dywInr08ySg</a>)</p>
<p>As you can see there are a lot of drawing issues remaining but the basic stuff is here. The code is not terribly faster (+10 fps or so) but that may come either from a bug in my graphic card driver (it already does the bizarre thing of slowing down after some time) or an other part of Moonlight.</p>
<p>It will definitely be better when OpenVG becomes more widespread, has more optimized implementations and can actually run on its own rather than on top of OpenGL (I&#8217;m eager to try that on top of Gallium3D when it will be ready).</p>
<p>As for inclusion in the mainline tree, I don&#8217;t know. I mostly did the thing for fun as a proof-of-concept and it&#8217;s certainly far too crappy to ever get integrated as is, but maybe someone will step up and do it correctly later <img src='http://blog.neteril.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  .</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.neteril.org/2009/07/16/joining-the-moonlight-fun/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Zencomic 0.2.1 : OH HAI!</title>
		<link>http://blog.neteril.org/2009/07/10/zencomic-0-2-1-oh-hai/</link>
		<comments>http://blog.neteril.org/2009/07/10/zencomic-0-2-1-oh-hai/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 15:22:36 +0000</pubDate>
		<dc:creator>Jérémie Laval</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[comic]]></category>
		<category><![CDATA[webcomic]]></category>
		<category><![CDATA[zencomic]]></category>

		<guid isPermaLink="false">http://garuma.wordpress.com/?p=640</guid>
		<description><![CDATA[<p>After fighting a bit with Gtk# widget styling and MonoDevelop tarball deployment, here is a new Zencomic.</p>
<h2>Summary</h2>
<p>Zencomic is the comic strip-driven productivity enhancer that periodically makes your day funnier by showing comic like Dilbert or XKCD in a bubble.</p>
<h2>What&#8217;s new aka The Cool Stuff &#8482;</h2>
<h3>New, window-based, popup</h3>
<p>Tired of having some comic showing far too small ? This is for you !</p>
<p>Now, if you go to the preference dialog, you will be able to switch to a window-based popup which shows your comics in all their greatness at the expense of taking more window space and making your boss, who was incidentally passing by, angry at you (in that case, a quick click on the popup will close it).</p>
<p><a href="http://garuma.files.wordpress.com/2009/07/new-window-popup.png"><img src="http://garuma.files.wordpress.com/2009/07/new-window-popup.png?w=256" alt="new-window-popup" title="new-window-popup" width="256" height="300" class="aligncenter size-medium wp-image-642" /></a></p>
<h3>Can I haz lolcats ?</h3>
<p>Lolcat greatness is here with the addition of a new addin :</p>
<p><a href="http://garuma.files.wordpress.com/2009/07/zencomic-lolcat.png"><img src="http://garuma.files.wordpress.com/2009/07/zencomic-lolcat.png?w=300" alt="zencomic-lolcat" title="zencomic-lolcat" width="300" height="238" class="aligncenter size-medium wp-image-641" /></a></p>
<h3>The remaining</h3>
<ul>
<li>For the Gnome Do junkie, Zencomic now correctly comes with a .desktop file so that you can launch it from there</li>
<li>Made the preference dialog show in a little saner way i.e. by coming up directly at the front (which apparently wasn&#8217;t the case with some WM).</li>
<li>The traditional round of bugfixes (should you still spot one don&#8217;t hesitate to manifest in the comments)</li>
</ul>
<h2>Downloadz</h2>
<p>Tarball : <a href="http://netherilshade.free.fr/mono/zencomic-0.2.1.tar.gz">http://netherilshade.free.fr/mono/zencomic-0.2.1.tar.gz</a></p>
<p>If by any chance you feel this is an application that should come in your distribution, don&#8217;t hesitate to contribute some packages <img src='http://blog.neteril.org/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  .</p>
]]></description>
			<content:encoded><![CDATA[<p>After fighting a bit with Gtk# widget styling and MonoDevelop tarball deployment, here is a new Zencomic.</p>
<h2>Summary</h2>
<p>Zencomic is the comic strip-driven productivity enhancer that periodically makes your day funnier by showing comic like Dilbert or XKCD in a bubble.</p>
<h2>What&#8217;s new aka The Cool Stuff &#8482;</h2>
<h3>New, window-based, popup</h3>
<p>Tired of having some comic showing far too small ? This is for you !</p>
<p>Now, if you go to the preference dialog, you will be able to switch to a window-based popup which shows your comics in all their greatness at the expense of taking more window space and making your boss, who was incidentally passing by, angry at you (in that case, a quick click on the popup will close it).</p>
<p><a href="http://garuma.files.wordpress.com/2009/07/new-window-popup.png"><img src="http://garuma.files.wordpress.com/2009/07/new-window-popup.png?w=256" alt="new-window-popup" title="new-window-popup" width="256" height="300" class="aligncenter size-medium wp-image-642" /></a></p>
<h3>Can I haz lolcats ?</h3>
<p>Lolcat greatness is here with the addition of a new addin :</p>
<p><a href="http://garuma.files.wordpress.com/2009/07/zencomic-lolcat.png"><img src="http://garuma.files.wordpress.com/2009/07/zencomic-lolcat.png?w=300" alt="zencomic-lolcat" title="zencomic-lolcat" width="300" height="238" class="aligncenter size-medium wp-image-641" /></a></p>
<h3>The remaining</h3>
<ul>
<li>For the Gnome Do junkie, Zencomic now correctly comes with a .desktop file so that you can launch it from there</li>
<li>Made the preference dialog show in a little saner way i.e. by coming up directly at the front (which apparently wasn&#8217;t the case with some WM).</li>
<li>The traditional round of bugfixes (should you still spot one don&#8217;t hesitate to manifest in the comments)</li>
</ul>
<h2>Downloadz</h2>
<p>Tarball : <a href="http://netherilshade.free.fr/mono/zencomic-0.2.1.tar.gz">http://netherilshade.free.fr/mono/zencomic-0.2.1.tar.gz</a></p>
<p>If by any chance you feel this is an application that should come in your distribution, don&#8217;t hesitate to contribute some packages <img src='http://blog.neteril.org/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  .</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.neteril.org/2009/07/10/zencomic-0-2-1-oh-hai/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>GSoC: the now and the next</title>
		<link>http://blog.neteril.org/2009/07/03/gsoc-the-now-and-the-next/</link>
		<comments>http://blog.neteril.org/2009/07/03/gsoc-the-now-and-the-next/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 21:52:21 +0000</pubDate>
		<dc:creator>Jérémie Laval</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Google Summer of Code 2009]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://garuma.wordpress.com/?p=619</guid>
		<description><![CDATA[<p><a href="http://garuma.wordpress.com/2009/04/21/yet-another-round-of-summer-love/">As you may recall</a>, I have the great pleasure to participate again in Google Summer of Code this year with Mono.</p>
<p>Since we are nearing midterm evaluation, I thought about doing a kind of status report like last year. Unfortunately, I haven&#8217;t been as active as I wanted to this time (exams were more time consuming this semester). However there is still some cool stuff that have already landed and which are described next.</p>
<h2>What has been done since last year</h2>
<h3>Actors and Software-transactional-memory goodness</h3>
<p>I took some time to implement rudimentary version of those two parallel programming paradigms earlier this year.</p>
<p>See this <a href="http://garuma.wordpress.com/2009/03/02/exploring-other-concurrency-models/">post</a> which describes in more details the ideas behind them and some examples.</p>
<h3>New more efficient scheduler&#8217;s deque</h3>
<p>The scheduler&#8217;s deque that was used before was quite complex due to the fact that the inherent storage mechanism was based on a doubly linked-list which is rather hard to get right when you add parallel and concurrency constraints (see <a href="http://en.wikipedia.org/wiki/ABA_problem">ABA problem</a> for instance).</p>
<p>The algorithm I was using was mostly designed with C++ in mind where you can mess up with pointers pretty easily and make freely use of CAS on pointers as integers. Since I wanted to avoid any kind of unsafe or native code in the library, I tried to port that algorithm down to C#.</p>
<p>After some mail exchange with a fellow person (hey Susan o/) who was using Mono&#8217;s ParallelFx on a big box in a laboratory, we started to see some concurrency problems with my code. Turns out that the ABA prevention code wasn&#8217;t really working with my C# rewrite. Therefore I decided to hunt for another, more C#-friendly, type of scheduler&#8217;s deque.</p>
<p>Actually, I did find it and it&#8217;s the one used now under the CyclicDeque name. It&#8217;s particularly swift because it only do integer manipulations that are particularly fast with the C# Interlocked methods and doesn&#8217;t suffer of the ABA problem because, using the vast range of values available with 64 bits integers, it&#8217;s based on a forward-only algorithm.</p>
<p>With the tests I was able to do, this new deque works more reliably and faster than the precedent. It&#8217;s currently enabled by default but I need to do some 32 bits checks to see if it behaves as expected on those plateforms.</p>
<h3>New types</h3>
<p>Following the new type introduced as part of my first SoC and the two parallel paradigms I described above, I have done some other parallel and concurrent code to be used both internally and publicly.</p>
<p>One of those is a new collection, ConcurrentSkipList that provides a thread-safe implementation of a skip-list (a nice tree-ish list container). This skip-list implementation is also used for the ConcurrentDictionary type.</p>
<p>The other is a stripped down CountdownEvent called Snzi (Scalable non-zero indicator) that basically do the same thing except that instead of keeping a count record, Snzi just tells in a binary fashion if there is or not a count remaining. That weaker semantic opens the door for more scalable and efficient optimizations.</p>
<h3>Optimizing, fixing and hardening</h3>
<p>The final task that occupied me during the inter-soc period was mostly tuning and bug-fixing the existing parts with a focus on Task reliability and PLinq performance and correctness.</p>
<h2>What have I begin to do for this SoC</h2>
<p>Currently I&#8217;m hard working on the .NET 4 port of Mono&#8217;s ParallelFx as it comes with a whole lot of new stuff and API changes.</p>
<p>The ParallelFx team over at Microsot has been publishing posts these last months about the new things coming down the pipe (check out their <a href="http://blogs.msdn.com/pfxteam/">blog</a> if you still haven&#8217;t do so).</p>
<p>At the moment, the System.Threading.Tasks namespace port is fairly complete and Tasks/Future unit tests are all back to green.</p>
<p>I&#8217;m now working a bit on the Collections namespace, adapting some of my code to the new API (notably ConcurrentDictionary) and seeing how to implement the new Partitioner pattern.</p>
<h2>What to expect next</h2>
<p><img src="http://garuma.files.wordpress.com/2009/07/mono-ireland2.png" alt="mono-ireland" title="mono-ireland" width="411" height="159" class="aligncenter size-full wp-image-626" /></p>
<p>First of all, the following weeks are going to be quite more productive as, with big thanks to <a href="http://monotorrent.blogspot.com/">Alan</a> and <a href="http://tirania.org/blog/">Miguel</a>, I&#8217;m going to spend a month in Dublin hacking in the Novell offices. Looking forward to this.</p>
<p>As for the next, the plan is to continue porting the existing code to .NET 4, first with the Parallel loops class (with probably some further optimizations on data source partitioning) and then PLinq.</p>
<p>In addition, since Mono recently enabled the .NET 4 profile in SVN, some of the ParallelFx code will also soon transition from the google code repository to official Mono&#8217;s trunk for early mass consumption.</p>
<p>Finally, last but not least, I&#8217;m going to devote the rest of the summer to testing ParallelFx more extensively with, both, improving the existing test suite with harder parallel stress-testing and the development of a <a href="http://research.microsoft.com/en-us/projects/chess/">Chess</a>-like parallel correctness checker.</p>
<p>See you at the end of the SoC for another full report <img src='http://blog.neteril.org/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  .</p>
]]></description>
			<content:encoded><![CDATA[<p><a href="http://garuma.wordpress.com/2009/04/21/yet-another-round-of-summer-love/">As you may recall</a>, I have the great pleasure to participate again in Google Summer of Code this year with Mono.</p>
<p>Since we are nearing midterm evaluation, I thought about doing a kind of status report like last year. Unfortunately, I haven&#8217;t been as active as I wanted to this time (exams were more time consuming this semester). However there is still some cool stuff that have already landed and which are described next.</p>
<h2>What has been done since last year</h2>
<h3>Actors and Software-transactional-memory goodness</h3>
<p>I took some time to implement rudimentary version of those two parallel programming paradigms earlier this year.</p>
<p>See this <a href="http://garuma.wordpress.com/2009/03/02/exploring-other-concurrency-models/">post</a> which describes in more details the ideas behind them and some examples.</p>
<h3>New more efficient scheduler&#8217;s deque</h3>
<p>The scheduler&#8217;s deque that was used before was quite complex due to the fact that the inherent storage mechanism was based on a doubly linked-list which is rather hard to get right when you add parallel and concurrency constraints (see <a href="http://en.wikipedia.org/wiki/ABA_problem">ABA problem</a> for instance).</p>
<p>The algorithm I was using was mostly designed with C++ in mind where you can mess up with pointers pretty easily and make freely use of CAS on pointers as integers. Since I wanted to avoid any kind of unsafe or native code in the library, I tried to port that algorithm down to C#.</p>
<p>After some mail exchange with a fellow person (hey Susan o/) who was using Mono&#8217;s ParallelFx on a big box in a laboratory, we started to see some concurrency problems with my code. Turns out that the ABA prevention code wasn&#8217;t really working with my C# rewrite. Therefore I decided to hunt for another, more C#-friendly, type of scheduler&#8217;s deque.</p>
<p>Actually, I did find it and it&#8217;s the one used now under the CyclicDeque name. It&#8217;s particularly swift because it only do integer manipulations that are particularly fast with the C# Interlocked methods and doesn&#8217;t suffer of the ABA problem because, using the vast range of values available with 64 bits integers, it&#8217;s based on a forward-only algorithm.</p>
<p>With the tests I was able to do, this new deque works more reliably and faster than the precedent. It&#8217;s currently enabled by default but I need to do some 32 bits checks to see if it behaves as expected on those plateforms.</p>
<h3>New types</h3>
<p>Following the new type introduced as part of my first SoC and the two parallel paradigms I described above, I have done some other parallel and concurrent code to be used both internally and publicly.</p>
<p>One of those is a new collection, ConcurrentSkipList that provides a thread-safe implementation of a skip-list (a nice tree-ish list container). This skip-list implementation is also used for the ConcurrentDictionary type.</p>
<p>The other is a stripped down CountdownEvent called Snzi (Scalable non-zero indicator) that basically do the same thing except that instead of keeping a count record, Snzi just tells in a binary fashion if there is or not a count remaining. That weaker semantic opens the door for more scalable and efficient optimizations.</p>
<h3>Optimizing, fixing and hardening</h3>
<p>The final task that occupied me during the inter-soc period was mostly tuning and bug-fixing the existing parts with a focus on Task reliability and PLinq performance and correctness.</p>
<h2>What have I begin to do for this SoC</h2>
<p>Currently I&#8217;m hard working on the .NET 4 port of Mono&#8217;s ParallelFx as it comes with a whole lot of new stuff and API changes.</p>
<p>The ParallelFx team over at Microsot has been publishing posts these last months about the new things coming down the pipe (check out their <a href="http://blogs.msdn.com/pfxteam/">blog</a> if you still haven&#8217;t do so).</p>
<p>At the moment, the System.Threading.Tasks namespace port is fairly complete and Tasks/Future unit tests are all back to green.</p>
<p>I&#8217;m now working a bit on the Collections namespace, adapting some of my code to the new API (notably ConcurrentDictionary) and seeing how to implement the new Partitioner pattern.</p>
<h2>What to expect next</h2>
<p><img src="http://garuma.files.wordpress.com/2009/07/mono-ireland2.png" alt="mono-ireland" title="mono-ireland" width="411" height="159" class="aligncenter size-full wp-image-626" /></p>
<p>First of all, the following weeks are going to be quite more productive as, with big thanks to <a href="http://monotorrent.blogspot.com/">Alan</a> and <a href="http://tirania.org/blog/">Miguel</a>, I&#8217;m going to spend a month in Dublin hacking in the Novell offices. Looking forward to this.</p>
<p>As for the next, the plan is to continue porting the existing code to .NET 4, first with the Parallel loops class (with probably some further optimizations on data source partitioning) and then PLinq.</p>
<p>In addition, since Mono recently enabled the .NET 4 profile in SVN, some of the ParallelFx code will also soon transition from the google code repository to official Mono&#8217;s trunk for early mass consumption.</p>
<p>Finally, last but not least, I&#8217;m going to devote the rest of the summer to testing ParallelFx more extensively with, both, improving the existing test suite with harder parallel stress-testing and the development of a <a href="http://research.microsoft.com/en-us/projects/chess/">Chess</a>-like parallel correctness checker.</p>
<p>See you at the end of the SoC for another full report <img src='http://blog.neteril.org/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  .</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.neteril.org/2009/07/03/gsoc-the-now-and-the-next/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MD quick feature : switch support in Autotools deployment project</title>
		<link>http://blog.neteril.org/2009/06/24/md-quick-feature-switch-support-in-autotools-deployment-project/</link>
		<comments>http://blog.neteril.org/2009/06/24/md-quick-feature-switch-support-in-autotools-deployment-project/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 16:23:31 +0000</pubDate>
		<dc:creator>Jérémie Laval</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[English]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Monodevelop]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://garuma.wordpress.com/?p=608</guid>
		<description><![CDATA[<p>Just to let you know that MonoDevelop&#8217;s Autotools deployment projects now allow you to add specific switch for the configure script.</p>
<p>Let&#8217;s say for instance that you want to enable at compile time a specific feature in your project. Now what you can do is add a switch to your deployment project which will be turned in something like <code>--enable-super-feature</code> on configure side (i.e. you will be able to run configure like <code>./configure --enable-super-feature</code>).</p>
<p>This will actually define (as in #define) a symbol that you can use with #if &#8230; #endif constructs in your code to activate your specific feature.</p>
<p>Since we are at it, here is a little screenie :</p>
<p><a href="http://garuma.files.wordpress.com/2009/06/md-switch-defines.png"><img src="http://garuma.files.wordpress.com/2009/06/md-switch-defines.png?w=300" alt="md-switch-defines" title="md-switch-defines" width="300" height="156" class="aligncenter size-medium wp-image-609" /></a></p>
<p>I will add support asap for simple makefile projects. The UI is also probably a bit rough, if there are any usability expert out of there I will gladly accept any sensible criticism <img src='http://blog.neteril.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  .</p>
]]></description>
			<content:encoded><![CDATA[<p>Just to let you know that MonoDevelop&#8217;s Autotools deployment projects now allow you to add specific switch for the configure script.</p>
<p>Let&#8217;s say for instance that you want to enable at compile time a specific feature in your project. Now what you can do is add a switch to your deployment project which will be turned in something like <code>--enable-super-feature</code> on configure side (i.e. you will be able to run configure like <code>./configure --enable-super-feature</code>).</p>
<p>This will actually define (as in #define) a symbol that you can use with #if &#8230; #endif constructs in your code to activate your specific feature.</p>
<p>Since we are at it, here is a little screenie :</p>
<p><a href="http://garuma.files.wordpress.com/2009/06/md-switch-defines.png"><img src="http://garuma.files.wordpress.com/2009/06/md-switch-defines.png?w=300" alt="md-switch-defines" title="md-switch-defines" width="300" height="156" class="aligncenter size-medium wp-image-609" /></a></p>
<p>I will add support asap for simple makefile projects. The UI is also probably a bit rough, if there are any usability expert out of there I will gladly accept any sensible criticism <img src='http://blog.neteril.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  .</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.neteril.org/2009/06/24/md-quick-feature-switch-support-in-autotools-deployment-project/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
