<?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>geek thoughts</title>
	<atom:link href="http://www.mlesniak.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mlesniak.com</link>
	<description></description>
	<lastBuildDate>Tue, 02 Mar 2010 15:45:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Ubuntu 64 Bit and GHCs Garbage Collector</title>
		<link>http://www.mlesniak.com/2010/03/02/ubuntu-64-bit-and-ghcs-garbage-collector/</link>
		<comments>http://www.mlesniak.com/2010/03/02/ubuntu-64-bit-and-ghcs-garbage-collector/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 07:38:19 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[ghc]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[solutions]]></category>

		<guid isPermaLink="false">http://www.mlesniak.com/?p=646</guid>
		<description><![CDATA[Hi,
Update: I tested a kernel 2.6.31-12 (from kernel.org) and had the same (if not even worse) behaviour as with 2.6.31-19. So, I apologize. It has nothing to do with Ubuntu per se, but probably with the linux-kernel; that makes me wonder if I haven&#8217;t done something faulty: that behaviour should have attracted the attention of [...]]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p><em><strong>Update</strong>: I tested a kernel 2.6.31-12 (from kernel.org) and had the same (if not even worse) behaviour as with 2.6.31-19. So, I apologize. It has nothing to do with Ubuntu per se, but probably with the linux-kernel; that makes me wonder if I haven&#8217;t done something faulty: that behaviour should have attracted the attention of some other Haskell developers in the meantime, but I couldn&#8217;t find any information on it. So, take in mind that the following could be incorrect&#8230;</em></p>
<p>finding this strange behaviour had cost me a lot of hours (see also my <a href="http://www.haskell.org/pipermail/haskell-cafe/2010-March/073938.html">post</a> on the haskell-cafe mailing list), because honestly, who do you blame if your parallel programm behaves strangely:</p>
<ol>
<li>yourself</li>
<li>the compiler</li>
<li>the special patches of your OS vendor to your linux kernel</li>
</ol>
<p>Since the probabilities of an error in 2. are quite low (at lot of people use GHC and its parallelization techniques) and &#8212; at least I thought that &#8212; those in 3. are low, too (some of those people from 1. should be using my OS with GHC for parallel development), I chose 1. Hence, I spent a lot of time trying to find synchronisation and performance problems in my code, which in fact, weren&#8217;t there!</p>
<p>The current setup of a standard Ubuntu 9.10 (64 bit) is a vanilla kernel (2.6.31-19-generic) , used with GHC 6.12.1. Look at this small and seemingly innocent program</p>
<pre lang="haskell'">-- File Pi.hs
-- you need the numbers package from hackage.
module Main where
import Data.Number.CReal
import System.Environment
import GHC.Conc

main = do
    digits &lt;- (read . head) `fmap` getArgs :: IO Int
    showCReal (fromEnum digits) pi `pseq` return ()
</pre>
<p>that you can compile with</p>
<pre>ghc -- make -O2 -threaded Pi.hs -o pi
</pre>
<p>Benchmarking with</p>
<pre>for i in `seq 1 5`;do time pi 5000 +RTS -N1;done
for i in `seq 1 5`;do time pi 5000 +RTS -N2;done</pre>
<p>I received the following exemplary runtimes for the vanilla ubuntu kernel.</p>
<p><br class="spacer_" /></p>
<p><a href="http://www.mlesniak.com/wp-content/uploads/2010/03/bad.png"><img class="aligncenter size-full wp-image-648" title="bad" src="http://www.mlesniak.com/wp-content/uploads/2010/03/bad.png" alt="" width="354" height="310" /></a></p>
<p>And this is the threadscope profile of a particular bad run:</p>
<p><img class="aligncenter size-full wp-image-650" title="thread" src="http://www.mlesniak.com/wp-content/uploads/2010/03/thread.png" alt="" width="583" height="247" /><br />
 As you can see, nearly all time is spend in the Garbage Collector, doing&#8230;things, GCs do&#8230;</p>
<p>I then compiled my own kernel2.633 from kernel.org and received these results:</p>
<p><a href="http://www.mlesniak.com/wp-content/uploads/2010/03/good.png"><img class="aligncenter size-full wp-image-649" title="good" src="http://www.mlesniak.com/wp-content/uploads/2010/03/good.png" alt="" width="354" height="310" /></a></p>
<p><strong>Conclusion:</strong> At least for me and my parallel programs (and even some innocent toy programs like Pi.hs) does the standard Ubuntu 64bit kernel harm parallel performance (especially that of the GC) a lot.</p>
<p>I find this highly surprising:</p>
<ul>
<li>Ubuntu is a widely used distribution</li>
<li> 64 bit versions are also becoming quite common</li>
<li>in my perception Haskell developers use parallelism a lot</li>
</ul>
<p><strong>Question. </strong>Either the intersection of these properties is quite small or my measurements have some serious flaw. I&#8217;d be glad if someone could disprove my results (and give me the opportunity to learn a bit) or support my measurements.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mlesniak.com/2010/03/02/ubuntu-64-bit-and-ghcs-garbage-collector/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Visualizing rising iteration depth in a voltage diffusion model</title>
		<link>http://www.mlesniak.com/2010/01/08/visualizing-rising-iteration-depth-in-a-voltage-diffusion-model/</link>
		<comments>http://www.mlesniak.com/2010/01/08/visualizing-rising-iteration-depth-in-a-voltage-diffusion-model/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 14:38:03 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[haskell]]></category>
		<category><![CDATA[pastha]]></category>

		<guid isPermaLink="false">http://www.mlesniak.com/?p=640</guid>
		<description><![CDATA[Using my PASTHA library (more follows soon) to parallelize stencil calculations I wrote a few wrapper scripts for gnuplot and gifsicle to visualize the voltage diffusion for a metal plane for rising iteration depths:
]]></description>
			<content:encoded><![CDATA[<p>Using my PASTHA library (more follows soon) to parallelize stencil calculations I wrote a few wrapper scripts for gnuplot and gifsicle to visualize the voltage diffusion for a metal plane for rising iteration depths:<a href="http://www.mlesniak.com/wp-content/uploads/2010/01/anim.gif"><img class="aligncenter size-full wp-image-643" title="anim" src="http://www.mlesniak.com/wp-content/uploads/2010/01/anim.gif" alt="" width="400" height="300" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mlesniak.com/2010/01/08/visualizing-rising-iteration-depth-in-a-voltage-diffusion-model/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Idea for capabilities</title>
		<link>http://www.mlesniak.com/2010/01/03/idea-for-capabilities/</link>
		<comments>http://www.mlesniak.com/2010/01/03/idea-for-capabilities/#comments</comments>
		<pubDate>Sun, 03 Jan 2010 17:50:16 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[capabilities]]></category>
		<category><![CDATA[ghc]]></category>

		<guid isPermaLink="false">http://www.mlesniak.com/?p=636</guid>
		<description><![CDATA[After looking at the source code in Capabilities.c I think a rudimentary implementation to add dynamic capabilities can work like this:

Wait, until it is safe to change the capabilities structure.
Allocate memory for number_of_capabilities + 1
Copy old capabilities structure to new allocated one
Relink to new memory location

To be honest, I don&#8217;t think it&#8217;s so easy; but [...]]]></description>
			<content:encoded><![CDATA[<p>After looking at the source code in Capabilities.c I think a rudimentary implementation to add dynamic capabilities can work like this:</p>
<ol>
<li>Wait, until it is safe to change the capabilities structure.</li>
<li>Allocate memory for number_of_capabilities + 1</li>
<li>Copy old capabilities structure to new allocated one</li>
<li>Relink to new memory location</li>
</ol>
<p>To be honest, I don&#8217;t think it&#8217;s so easy; but at least this is a starting point I can use. Currently, I have to things to think about and which have to be solved before I can hack around in the code:</p>
<ol>
<li>How can I call C code in the RTS from Haskell?</li>
<li>When is it safe to modify the capabilities structure?</li>
</ol>
<p>Happy for any suggestions,<br />
 Michael</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mlesniak.com/2010/01/03/idea-for-capabilities/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GHC&#8217;s 6.12 new dynamic linking and file sizes</title>
		<link>http://www.mlesniak.com/2009/12/14/ghcs-6-12-new-dynamic-linking-and-file-sizes/</link>
		<comments>http://www.mlesniak.com/2009/12/14/ghcs-6-12-new-dynamic-linking-and-file-sizes/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 18:58:11 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[miscellaneous]]></category>

		<guid isPermaLink="false">http://www.mlesniak.com/?p=633</guid>
		<description><![CDATA[GHC 6.12 finally supports dynamic linking, leading too much smaller binaries: For the standard HelloWorld example

module Main where
&#160;
main = putStrLn &#34;Hello World&#34;

the binaries went from 427.000 bytes (stripped) to 10.736 bytes! That&#8217;s great  
]]></description>
			<content:encoded><![CDATA[<p><a href="http://haskell.org/ghc/download_ghc_6_12_1.html">GHC 6.12</a> finally supports dynamic linking, leading too much smaller binaries: For the standard HelloWorld example</p>

<div class="wp_codebox"><table><tr id="p6332"><td class="code" id="p633code2"><pre class="haskell" style="font-family:monospace;"><span style="color: #06c; font-weight: bold;">module</span> Main <span style="color: #06c; font-weight: bold;">where</span>
&nbsp;
main <span style="color: #339933; font-weight: bold;">=</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:putStrLn"><span style="font-weight: bold;">putStrLn</span></a> <span style="background-color: #3cb371;">&quot;Hello World&quot;</span></pre></td></tr></table></div>

<p>the binaries went from 427.000 bytes (stripped) to 10.736 bytes! That&#8217;s great <img src='http://www.mlesniak.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.mlesniak.com/2009/12/14/ghcs-6-12-new-dynamic-linking-and-file-sizes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Where am I?</title>
		<link>http://www.mlesniak.com/2009/12/12/where-am-i/</link>
		<comments>http://www.mlesniak.com/2009/12/12/where-am-i/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 13:19:14 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[capabilities]]></category>
		<category><![CDATA[ghc]]></category>

		<guid isPermaLink="false">http://www.mlesniak.com/?p=618</guid>
		<description><![CDATA[And what am I doing here? I currently read (more or less randomized) remarks about GHC&#8217;s source code; the codebase is quite huge (and probably the biggest code base that I&#8217;ve ever worked with):
Extension  Lines
.lhs       300482
.hs        473479
.c     [...]]]></description>
			<content:encoded><![CDATA[<p>And what am I doing here? I currently read (more or less randomized) remarks about GHC&#8217;s source code; the codebase is quite huge (and probably the biggest code base that I&#8217;ve ever worked with):</p>
<pre style="padding-left: 30px;" lang="c">Extension  Lines
.lhs       300482
.hs        473479
.c         184039
.h         448394

combined  1406394

Found using wc -l `find . -name \*.`
</pre>
<p>Thankfully I only need a tiny fraction of it to add the dynamic-capabilities-feature: according to the <a href="http://hackage.haskell.org/trac/ghc/wiki/Commentary/Rts">commentary</a> on the runtime system it consist of only about 50000 lines, and again, I probably need to modify / extend just a fraction of it. The code of the runtime system has an <a href="http://hackage.haskell.org/trac/ghc/wiki/Commentary/SourceTree/Rts">extra page</a> on the wiki; it describes</p>
<ul>
<li>the purpose of the single files. Unfortunately these are currently only one liners and links to the particular files. Maybe I will add a much more extensive description for the Capabilities-files.</li>
<li>the<a href="http://hackage.haskell.org/trac/ghc/wiki/Commentary/Rts/Conventions"> coding conventions</a> for this subsystem. They are quite extensive but (in my humble opinion) very good and describe not only syntactical conventions but also some general remarks, debugging and robustness tricks. </li>
</ul>
<p>For seeing how the capabilites are initialized I think that the file RtsFlag.c is helpful:</p>
<ul>
<li>RtsFlag.c defines parsing for -N&lt;&#8230;&gt;, hence I see where the capabilites are set and how they fit in the big puzzle of the RTS. </li>
<li>RtsFlag.c uses and sets RtsFlags.ParFlags.nNodes (line 958). The structure is included in includes/Rts.h which includes include/rts/Flags.h (line 189 defines the important parts). </li>
<li>RtsMessage.c would probably help me in the future for printing some debugging messages.</li>
</ul>
<p>I&#8217;m curious if I&#8217;m on the right track. By the way, take all the informations with a grain of salt, since I&#8217;m currently in the beginning of understanding the code of the runtime system.</p>
<p><strong>Minor update</strong>: After a look at the <a href="http://hackage.haskell.org/trac/ghc/wiki/Commentary/Rts">commentary</a> I&#8217;m pretty sure I need to understand much of the <a href="http://hackage.haskell.org/trac/ghc/wiki/Commentary/Rts/Scheduler">scheduling subsystem</a> to extend the capabilities-system. Thankfully the wiki seems to document it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mlesniak.com/2009/12/12/where-am-i/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Started hacking on GHC capabilities</title>
		<link>http://www.mlesniak.com/2009/12/11/started-hacking-on-ghc-capabilities/</link>
		<comments>http://www.mlesniak.com/2009/12/11/started-hacking-on-ghc-capabilities/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 19:57:40 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[capabilities]]></category>
		<category><![CDATA[haskell]]></category>

		<guid isPermaLink="false">http://www.mlesniak.com/?p=589</guid>
		<description><![CDATA[Today I&#8217;ve started the small personal hacking project of implementing dynamic capatiblities in GHC&#8217;s parallel runtime system; I&#8217;ll blog about my efforts, problems and solutions and would be grateful for any hints, comments or pointers for more documentation. I began by talking with Simon Marlow and discussing the idea. He said that it&#8217;s a least worthwhile [...]]]></description>
			<content:encoded><![CDATA[<p>Today I&#8217;ve started the small personal hacking project of implementing dynamic capatiblities in <a href="http://haskell.org/ghc/">GHC</a>&#8217;s parallel runtime system; I&#8217;ll blog about my efforts, problems and solutions and would be grateful for any hints, comments or pointers for more documentation. I began by talking with <a href="http://www.haskell.org/~simonmar/">Simon Marlow</a> and discussing the idea. He said that it&#8217;s a least worthwhile to try implementing it.</p>
<p>Currently I</p>
<ul>
<li>made an account (mlesniak) on the <a href="http://hackage.haskell.org/trac/ghc/">GHC&#8217;s developers wiki</a>.</li>
<li> opened a ticket (<a href="http://hackage.haskell.org/trac/ghc/ticket/3729">No. #3729</a>) as a task, describing my idea: <em>&#8220;Currently the number of capabilities can only be set at the start of a program using -N. At least for benchmarking and playing with semi-implicit code (any other real-world scenarious?) if would be nice to change the number of capabilities at runtime.&#8221; </em>
<p><em><span style="font-style: normal;"><strong>Current questions:</strong></span><br />
 </em></p>
<ul>
<li>There is no person assigned on this task, should I assign myself?</li>
<li>It&#8217;s the only project without a particular difficulty (Diffuclty: None); should I set one or is this set by one of the &#8220;important&#8221; maintainers?</li>
</ul>
</li>
<li>downloaded the source for GHC HEAD, according to <a href="http://hackage.haskell.org/trac/ghc/wiki/GettingStarted">Getting Started</a></li>
<li>was able to compile it on my 2.4 GHz Dualcore with 4 GB memory using the <a href="http://hackage.haskell.org/trac/ghc/wiki/Building">Building Guide</a>. It took about 40 minutes for a full compile (yikes!)</li>
<li>took a first look into ghc/rts/ <a href="http://www.mlesniak.com/wp-content/uploads/2009/12/Capability.c">Capability.c</a> and <a href="http://www.mlesniak.com/wp-content/uploads/2009/12/Capability.h">Capability.h</a>. This looks quite complicated and I probably have to understand a lot of the underlying system before I can even think about trying to modify this part of the RTS itself. Hopefully, the <a href="http://hackage.haskell.org/trac/ghc/wiki/Commentary">GHC Commentary</a> will help.</li>
</ul>
<p>Why do I do this? Firstly, I really like to solve problems and learn new things on the way. Secondly, I was always interested in the underlying parallel runtime system of GHC but without a concrete task motivating myself to understand this huge system was difficult. Thirdly, I hope that by learning part of the system I&#8217;m able to implement some of my (currently quite vague) ideas on dynamic adaptiblity of parallel runtime systems.</p>
<p>I will keep the interwebs updated, but do not expect too much soon, since I do this primary in my free time. Any hints, questions, remarks, (de-)motivating comments?</p>
<p><em> </em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mlesniak.com/2009/12/11/started-hacking-on-ghc-capabilities/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GHC 6.12 RC1 and Ubuntu 9.10 (Karmic Koala)</title>
		<link>http://www.mlesniak.com/2009/12/01/ghc-6-12-rc1-and-ubuntu-9-10-karmic-koala/</link>
		<comments>http://www.mlesniak.com/2009/12/01/ghc-6-12-rc1-and-ubuntu-9-10-karmic-koala/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 09:53:57 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[ghc]]></category>
		<category><![CDATA[haskell]]></category>

		<guid isPermaLink="false">http://www.mlesniak.com/?p=605</guid>
		<description><![CDATA[I&#8217;m excited about GHC 6.12 and hope it is released soon. Currently I have some problems with Ubuntu 9.10 and its Linux kernel 2.6.31-14. It seems that GHC 6.12 will solve (some) of my problems.
For the examplary unoptimized code

-- Compile with ghc-6.10.4 -O2 -threaded --make Example.hs -o example
module Main where
import GHC.Conc
import Control.Concurrent
import Control.Monad
import System.Environment
import Data.List
------------------------------------------------------------
main [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m excited about GHC 6.12 and hope it is released soon. Currently I have some <a href="http://www.mail-archive.com/haskell-cafe@haskell.org/msg67148.html">problems</a> with Ubuntu 9.10 and its Linux kernel 2.6.31-14. It seems that GHC 6.12 will solve (some) of my problems.</p>
<p>For the examplary unoptimized code</p>

<div class="wp_codebox"><table><tr id="p6054"><td class="code" id="p605code4"><pre class="haskell" style="font-family:monospace;"><span style="color: #5d478b; font-style: italic;">-- Compile with ghc-6.10.4 -O2 -threaded --make Example.hs -o example</span>
<span style="color: #06c; font-weight: bold;">module</span> Main <span style="color: #06c; font-weight: bold;">where</span>
<span style="color: #06c; font-weight: bold;">import</span> GHC<span style="color: #339933; font-weight: bold;">.</span>Conc
<span style="color: #06c; font-weight: bold;">import</span> Control<span style="color: #339933; font-weight: bold;">.</span>Concurrent
<span style="color: #06c; font-weight: bold;">import</span> Control<span style="color: #339933; font-weight: bold;">.</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Monad"><span style="color: #cccc00; font-weight: bold;">Monad</span></a>
<span style="color: #06c; font-weight: bold;">import</span> System<span style="color: #339933; font-weight: bold;">.</span>Environment
<span style="color: #06c; font-weight: bold;">import</span> Data<span style="color: #339933; font-weight: bold;">.</span>List
<span style="color: #5d478b; font-style: italic;">------------------------------------------------------------</span>
main <span style="color: #339933; font-weight: bold;">::</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:IO"><span style="color: #cccc00; font-weight: bold;">IO</span></a> <span style="color: green;">&#40;</span><span style="color: green;">&#41;</span>
main <span style="color: #339933; font-weight: bold;">=</span> <span style="color: #06c; font-weight: bold;">do</span>
    args <span style="color: #339933; font-weight: bold;">&lt;-</span> getArgs
    <span style="color: #06c; font-weight: bold;">let</span> threads <span style="color: #339933; font-weight: bold;">=</span> numCapabilities    <span style="color: #5d478b; font-style: italic;">-- threads determined by -N...</span>
        taskDur <span style="color: #339933; font-weight: bold;">=</span> <span style="color: red;">1000000</span>            <span style="color: #5d478b; font-style: italic;">-- big enough magic number</span>
        taskNum <span style="color: #339933; font-weight: bold;">=</span> <span style="color: green;">&#40;</span><a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:read"><span style="font-weight: bold;">read</span></a> <span style="color: #339933; font-weight: bold;">.</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:head"><span style="font-weight: bold;">head</span></a><span style="color: green;">&#41;</span> args <span style="color: #5d478b; font-style: italic;">-- Number of tasks is 1st parameter</span>
&nbsp;
    queue    <span style="color: #339933; font-weight: bold;">&lt;-</span> newChan
    finished <span style="color: #339933; font-weight: bold;">&lt;-</span> newChan
    writeList2Chan queue <span style="color: green;">&#40;</span>replicate taskNum taskDur<span style="color: green;">&#41;</span>
    replicateM<span style="color: #339933; font-weight: bold;">_</span> threads <span style="color: green;">&#40;</span>forkIO <span style="color: green;">&#40;</span>thread queue finished<span style="color: green;">&#41;</span><span style="color: green;">&#41;</span>
    replicateM<span style="color: #339933; font-weight: bold;">_</span> taskNum <span style="color: green;">&#40;</span>readChan finished<span style="color: green;">&#41;</span>
<span style="color: #5d478b; font-style: italic;">------------------------------------------------------------</span>
thread <span style="color: #339933; font-weight: bold;">::</span> Chan <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Int"><span style="color: #cccc00; font-weight: bold;">Int</span></a> <span style="color: #339933; font-weight: bold;">-</span>&amp;gt; Chan <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Int"><span style="color: #cccc00; font-weight: bold;">Int</span></a> <span style="color: #339933; font-weight: bold;">-</span>&amp;gt; <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:IO"><span style="color: #cccc00; font-weight: bold;">IO</span></a> <span style="color: green;">&#40;</span><span style="color: green;">&#41;</span>
thread queue finished <span style="color: #339933; font-weight: bold;">=</span>
    forever <span style="color: #339933; font-weight: bold;">$</span> <span style="color: #06c; font-weight: bold;">do</span>
        task <span style="color: #339933; font-weight: bold;">&lt;-</span> readChan queue
        workFor task
        writeChan finished <span style="color: red;">1</span>
  <span style="color: #06c; font-weight: bold;">where</span> workFor n <span style="color: #339933; font-weight: bold;">=</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:foldl"><span style="font-weight: bold;">foldl</span></a>' <span style="color: green;">&#40;</span>\a b <span style="color: #339933; font-weight: bold;">-&gt;</span> a <span style="color: #339933; font-weight: bold;">+</span> <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:sqrt"><span style="font-weight: bold;">sqrt</span></a> <span style="color: green;">&#40;</span><span style="color: red;">2</span><span style="color: #339933; font-weight: bold;">^</span>b<span style="color: green;">&#41;</span><span style="color: green;">&#41;</span> <span style="color: red;">1</span> <span style="color: green;">&#91;</span><span style="color: red;">1</span><span style="color: #339933; font-weight: bold;">..</span>n<span style="color: green;">&#93;</span> `pseq`
           <a href="http://haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#v:return"><span style="font-weight: bold;">return</span></a> <span style="color: green;">&#40;</span><span style="color: green;">&#41;</span></pre></td></tr></table></div>

<p>we get the following runtimes on my Dualcore Notebook:</p>
<pre>$ time e-6.12 +RTS -N1 -RTS 16

real	0m43.994s
user	0m43.630s
sys	0m0.040s
$ time e-6.12 +RTS -N2 -RTS 16

real	0m25.987s
user	0m48.790s
sys	0m0.230s
$ time e-6.10 +RTS -N1 -RTS 16

real	0m45.883s
user	0m44.500s
sys	0m0.400s
$ time e-6.10 +RTS -N2 -RTS 16

real	0m38.930s
user	0m46.040s
sys	0m0.490s
</pre>
<p>As you can see, e-6.12 (the version compiled with ghc-6.12-20091010) delivers a good speedup whereas ghc-6.10 does not use my two cores very much. This makes testing, benchmarking and developing my parallel Haskell code currently quite difficult.</p>
<p><br class="spacer_" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mlesniak.com/2009/12/01/ghc-6-12-rc1-and-ubuntu-9-10-karmic-koala/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Relaunch</title>
		<link>http://www.mlesniak.com/2009/11/30/relaunch/</link>
		<comments>http://www.mlesniak.com/2009/11/30/relaunch/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 11:35:06 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[miscellaneous]]></category>

		<guid isPermaLink="false">http://www.mlesniak.com/?p=609</guid>
		<description><![CDATA[Hello,  I&#8217;m relaunching mlesniak.com. Most of the old content (a raytracer and a tetris game in Java, biolib-Stuff) is gone at the moment but will probably be re-added over time. If you want details to a blog entry that you&#8217;ve found via Google&#8217;s cache just write me a mail.
]]></description>
			<content:encoded><![CDATA[<p>Hello,  I&#8217;m relaunching mlesniak.com. Most of the old content (a raytracer and a tetris game in Java, biolib-Stuff) is gone at the moment but will probably be re-added over time. If you want details to a blog entry that you&#8217;ve found via Google&#8217;s cache just write me a <a href="mailto:michael.lesniak@gmail.com">mail</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mlesniak.com/2009/11/30/relaunch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
