<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><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="divtagdefaultwrapper" 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,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,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,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,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,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>
</body>
</html>