<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<p><br>
</p>
<span style="font-size: 12pt;">The build isn't really doing anything after the first build cause it doesn't detect any changes. And stack exec is already passing the right RTS options</span>
<div><br>
<div style="color: rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> David Feuer <david.feuer@gmail.com><br>
<b>Sent:</b> Monday, January 16, 2017 9:02 PM<br>
<b>To:</b> Juan Luis Martty<br>
<b>Cc:</b> haskell-cafe@haskell.org<br>
<b>Subject:</b> Re: [Haskell-cafe] Control.Parallel seemingly randomly behaviour</font>
<div> </div>
</div>
<div>
<div dir="auto">Oh, and you should probably be passing your program an explicit +RTS option to tell it how many OS threads to use.</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Jan 16, 2017 7:01 PM, "David Feuer" <<a href="mailto:david.feuer@gmail.com">david.feuer@gmail.com</a>> wrote:<br type="attribution">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<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" target="_blank">jmartty@hotmail.com</a>> wrote:<br type="attribution">
<blockquote class="m_-4964879388951346861quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">
<div id="m_-4964879388951346861m_1719488459420597808divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Arial,Helvetica,sans-serif">
<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_-4964879388951346861m_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,1250000002<wbr>50000000)</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,1250000002<wbr>50000000)</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,1250000002<wbr>50000000)</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,1250000002<wbr>50000000)</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,1250000002<wbr>50000000)</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-bi<wbr>n/mailman/listinfo/haskell-caf<wbr>e</a><br>
Only members subscribed via the mailman list are allowed to post.<br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>