<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><div style="font-family: arial; font-size: 10pt; ">Thank, Daniel</div><div style="font-family: arial; font-size: 10pt; "><br></div><div style="font-family: arial; font-size: 10pt; ">Multiple threads are in evidence in my system monitor, but I wonder why I'm getting two different answers, one twice the other. The first is the parallel solution and the second is the non.</div><div style="font-family: arial; font-size: 10pt; "><br></div><div style="font-family: arial; font-size: 10pt; ">Michael</div><div style="font-family: arial; font-size: 10pt; "><br></div><div style="font-family: arial; font-size: 10pt; ">===========</div><div style="font-family: arial; font-size: 10pt; "><br></div><div><div><font class="Apple-style-span" face="arial" size="2">{-</font></div><div><font class="Apple-style-span" size="2" face="courier, monaco, monospace, sans-serif">import
 Control.Parallel</font></div><div><font class="Apple-style-span" size="2" face="courier, monaco, monospace, sans-serif"><br></font></div><div><font class="Apple-style-span" size="2" face="courier, monaco, monospace, sans-serif">nfib :: Int -&gt; Int</font></div><div><font class="Apple-style-span" size="2" face="courier, monaco, monospace, sans-serif">nfib n | n &lt;= 1 = 1</font></div><div><font class="Apple-style-span" size="2" face="courier, monaco, monospace, sans-serif">&nbsp; &nbsp; &nbsp; &nbsp;| otherwise = par n1 (pseq n2 (n1 + n2 + 1))</font></div><div><font class="Apple-style-span" size="2" face="courier, monaco, monospace, sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;where n1 = nfib (n-1)</font></div><div><font class="Apple-style-span" size="2" face="courier, monaco, monospace, sans-serif">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;n2 = nfib
 (n-2)</font></div><div><font class="Apple-style-span" size="2" face="courier, monaco, monospace, sans-serif">-}</font></div><div><font class="Apple-style-span" size="2" face="courier, monaco, monospace, sans-serif"><br></font></div><div><font class="Apple-style-span" size="2" face="courier, monaco, monospace, sans-serif">nfib :: Int -&gt; Int</font></div><div><font class="Apple-style-span" size="2" face="courier, monaco, monospace, sans-serif">nfib n | n &lt;= 1 = 1</font></div><div><font class="Apple-style-span" size="2" face="courier, monaco, monospace, sans-serif">&nbsp; &nbsp; &nbsp; &nbsp;| otherwise = nfib (n-1) + nfib (n-2)</font></div><div><font class="Apple-style-span" size="2" face="courier, monaco, monospace, sans-serif"><br></font></div><div><font class="Apple-style-span" size="2" face="courier, monaco, monospace, sans-serif">main = do putStrLn $ show $ nfib 39</font></div></div><div><font class="Apple-style-span" face="arial"
 size="2"><br></font></div><div><font class="Apple-style-span" face="arial" size="2">=============</font></div><div style="font-family: arial; font-size: 10pt; "><br></div><div style="font-family: arial; font-size: 10pt; ">[michael@hostname ~]$ ghc --make -threaded nfib.hs</div><div style="font-family: arial; font-size: 10pt; ">[1 of 1] Compiling Main &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ( nfib.hs, nfib.o )</div><div style="font-family: arial; font-size: 10pt; ">Linking nfib ...</div><div style="font-family: arial; font-size: 10pt; ">[michael@hostname ~]$ ./nfib +RTS -N3</div><div style="font-family: arial; font-size: 10pt; ">204668309</div><div style="font-family: arial; font-size: 10pt; ">[michael@hostname ~]$ ghc --make nfib.hs</div><div style="font-family: arial; font-size: 10pt; ">[1 of 1] Compiling Main &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ( nfib.hs, nfib.o )</div><div style="font-family: arial; font-size: 10pt; ">Linking nfib
 ...</div><div style="font-family: arial; font-size: 10pt; ">[michael@hostname ~]$ ./nfib</div><div style="font-family: arial; font-size: 10pt; ">102334155</div><div style="font-family: arial; font-size: 10pt; ">[michael@hostname ~]$&nbsp;</div><div style="font-family: arial; font-size: 10pt; "><br></div><br><font class="Apple-style-span" face="arial" size="2">--- On </font><b style="font-family: arial; font-size: 10pt; ">Thu, 5/26/11, Daniel Fischer <i>&lt;daniel.is.fischer@googlemail.com&gt;</i></b><font class="Apple-style-span" face="arial" size="2"> wrote:</font><br><blockquote style="font-family: arial; font-size: 10pt; border-left-width: 2px; border-left-style: solid; border-left-color: rgb(16, 16, 255); margin-left: 5px; padding-left: 5px; "><br>From: Daniel Fischer &lt;daniel.is.fischer@googlemail.com&gt;<br>Subject: Re: [Haskell-cafe] Parallel compilation and execution?<br>To: haskell-cafe@haskell.org<br>Cc: "michael rice"
 &lt;nowgate@yahoo.com&gt;<br>Date: Thursday, May 26, 2011, 8:16 AM<br><br><div class="plainMail">On Thursday 26 May 2011 13:24:09, michael rice wrote:<br>&gt; How do I compile and run this parallel program?<br>&gt; Michael<br>&gt; ===========================<br>&gt; import Control.Parallel<br>&gt; nfib :: Int -&gt; Int<br>&gt; nfib n | n &lt;= 1 = 1&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; | otherwise = par n1 (seq n2 (n1 + n2 + 1))<br><br>The 'seq' here should be a 'pseq' to ensure that n2 is (started to be) <br>calculated before (n1 + n2 +1) is evaluated (iirc, currently, both work <br>with ghc, but it's not guaranteed for seq).<br> <br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; where <br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n1 = nfib (n-1)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n2 = nfib (n-2)<br>&gt;&nbsp; {-nfib :: Int -&gt; Intnfib n | n &lt;= 1 =
 1<br>&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;| otherwise = nfib (n-1) + nfib (n-2)-}<br>&gt; <br>&gt; main = do putStrLn $ show $ nfib 39<br>&gt; ===========================<br>&gt; [michael@hostname ~]$ ghc --make -threaded nfib.hs<br>&gt; [michael@hostname ~]$ ./nfib +RTS -N3<br><br>In principle, that is the correct way to compile and run it (note that with <br>ghc-7, you don't need the --make).<br><br>&gt; nfib: the flag -N3 requires the program to be built with<br>&gt; -threaded<br><br>Have you previously compiled the programme without -threaded?<br>Unless you snipped the compilation messages, their absence strongly <br>indicates so.<br><br>If that is the case, you fell victim to ghc's recompilation-avoidance which <br>doesn't keep track of the flags a programme/module was compiled with, so it <br>saw that nothing [as far as it knows] changed, hence didn't recompile.<br><br>Then removing .o and .hi or passing -fforce-recomp will make it
 recompile <br>and link with the threaded runtime.<br></div></blockquote></td></tr></table>