<div dir="auto"><div>Just to remove one variable: what happens if you run the same executable multiple times, rather than rebuilding it each time?<br><div class="gmail_extra"><br><div class="gmail_quote">On Jan 15, 2017 6:34 PM, "Juan Luis Martty" <<a href="mailto:jmartty@hotmail.com">jmartty@hotmail.com</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">
<div id="m_1719488459420597808divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif" dir="ltr">
<p><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">Hello everyone,</span><br>
</p>
<div style="color:rgb(0,0,0)">
<div>
<div id="m_1719488459420597808divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif">
<div><br>
</div>
<div>I'm having a consistency issue with the following piece of code:</div>
<div><br>
</div>
<div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">heavyAm = 500</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">lightAm = 1000</span></div>
<div><br>
</div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">heavyCalc :: Int -> Int</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">heavyCalc s = sum [1..1000000*s]</span></div>
<div><br>
</div>
</div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">parallel = (heavyCalc lightAm, heavyCalc heavyAm) `using` (parTuple2 rseq rseq)</span><br>
</div>
<div><br>
</div>
<div>For some reason, during runtime the RTS sometimes parallelizes the evaluation and sometimes it doesn't. I'm running with all the RTS/compile time options correctly afaik. Here is the output from a couple of runs of the program:</div>
<div><br>
</div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">jmartty@walrus:~/hs/parallel$ stack build && time stack exec par-exe</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">Warning: File listed in par.cabal file does not exist: README.md</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">(500000000500000000,<wbr>125000000250000000)</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">Computation time: 1.557007s</span></div>
<div><br>
</div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">real 0m1.732s</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">user 0m2.528s</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">sys 0m0.464s</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">jmartty@walrus:~/hs/parallel$ stack build && time stack exec par-exe</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">Warning: File listed in par.cabal file does not exist: README.md</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">(500000000500000000,<wbr>125000000250000000)</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">Computation time: 1.544837s</span></div>
<div><br>
</div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">real 0m1.720s</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">user 0m2.544s</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">sys 0m0.712s</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">jmartty@walrus:~/hs/parallel$ stack build && time stack exec par-exe</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">Warning: File listed in par.cabal file does not exist: README.md</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">(500000000500000000,<wbr>125000000250000000)</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">Computation time: 2.316537s</span></div>
<div><br>
</div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">real 0m2.484s</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">user 0m2.592s</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">sys 0m0.680s</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">jmartty@walrus:~/hs/parallel$ stack build && time stack exec par-exe</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">Warning: File listed in par.cabal file does not exist: README.md</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">(500000000500000000,<wbr>125000000250000000)</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">Computation time: 2.318514s</span></div>
<div><br>
</div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">real 0m2.489s</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">user 0m2.612s</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">sys 0m0.688s</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">jmartty@walrus:~/hs/parallel$ stack build && time stack exec par-exe</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">Warning: File listed in par.cabal file does not exist: README.md</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">(500000000500000000,<wbr>125000000250000000)</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">Computation time: 1.544975s</span></div>
<div><br>
</div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">real 0m1.718s</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">user 0m2.512s</span></div>
<div><span style="font-family:"Courier New",monospace;font-size:10pt">sys 0m0.456s<br>
<br>
</span>As you can see, sometimes wall time roughly equals userspace time, sometimes it doesn't (meaning it parallelized at least some amount). I'm running on a dual core machine under Ubuntu using stack with lts-7.14 (GHC 8.0.1) and parallel-3.2.1.0.<br>
<span style="font-family:"Courier New",monospace"><br>
<span style="font-family:Calibri,Arial,Helvetica,sans-serif,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size:16px">Regards,<br>
Juan</span><br>
</span></div>
<p></p>
</div>
</div>
</div>
</div>
</div>
<br>______________________________<wbr>_________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/haskell-<wbr>cafe</a><br>
Only members subscribed via the mailman list are allowed to post.<br></blockquote></div><br></div></div></div>