<div dir="ltr">Hi again.<div><br></div><div>This is the system information:</div><div><div>- Ubuntu 12.04 32-bit</div><div>- Intel® Core™2 Duo CPU T5270 @ 1.40GHz × 2 </div><div>- 2.9 GiB RAM</div><div><br></div><div>GHC version:</div>

<div>- GHC 7.4.1</div><div><br></div><div>DPH libraries:</div><div><div>- dph-base-0.6.1.1</div><div>- (dph-lifted-base-0.6.1.1)</div><div>- (dph-lifted-vseg-0.6.1.2)</div><div>- (dph-prim-interface-0.6.1.1)</div><div>- (dph-prim-par-0.6.1.1)</div>

<div>- (dph-prim-seq-0.6.1.1)</div></div><div><br></div><div>Compilation flags:</div><div>I&#39;m using two combinations of flags, taken from different sources. In both cases results are identical:</div><div>- From <a href="https://github.com/ghc/packages-dph">https://github.com/ghc/packages-dph</a>: -rtsopts -threaded -fllvm -optlo-O3 -Odph -fcpr-off -fno-liberate-case -package dph-lifted-vseg</div>

<div>- From dph-examples: -rtsopts -threaded -fllvm -Odph -package dph-lifted-vseg -fcpr-off -fno-liberate-case -fsimpl-tick-factor=1000</div><div><br></div><div>Execution flags:</div><div>+RTS -N</div><div><br></div><div>

Tests:</div><div>Computing the product of two 400*400 matrices takes 6.037993 seconds. </div><div><div>Computing the product of two 600*600 matrices yields &quot;out of memory (requested 1728053248 bytes)&quot;. </div></div>

<div><br></div><div>DPH code:</div><div>-------------------------------------------------------------------------------------</div><div><div>{-# NOINLINE matMult_wrapper #-}</div><div>matMult_wrapper :: Matrix_wrapper -&gt; Matrix_wrapper -&gt; Matrix_wrapper</div>

<div>matMult_wrapper mA mB = toPArrayP (mapP toPArrayP (matMult (fromNestedPArrayP mA) (fromNestedPArrayP mB)))</div><div><br></div><div>matMult :: Matrix -&gt; Matrix -&gt; Matrix</div><div>matMult mA mB = mapP (\row -&gt; mapP (\col -&gt; dotp row col) mB) mA</div>

<div>-- I removed the call to transposeP, so It&#39;s no longer an actual matrix product</div><div><br></div><div>dotp :: MVector -&gt; MVector -&gt; MMultType</div><div>dotp row col = D.sumP (zipWithP (D.*) row col)</div>

</div><div>-------------------------------------------------------------------------------------</div><div>I&#39;m attaching the files with the full example code</div><div>If there is any other information needed, please let me know</div>

<div><br></div><div>Any help is very appreciated</div><br><div class="gmail_quote">On Tue, Jul 10, 2012 at 9:51 AM, Mauro Blanco <span dir="ltr">&lt;<a href="mailto:blancomau@gmail.com" target="_blank">blancomau@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks for both answers<div><br></div><div>I have used repa with the newer interface for the same example, but I wanted to have another example using DPH. I know repa is more suited for regular representations, but I wanted to express the same program in DPH where I don´t have to worry of nested parallel computation. </div>


<div><br></div><div>The transposeP  did not seem to be the problem as only executing transposeP on &quot;big&quot; matrices generated no memory issues. But, something like this (on square matrices) still have  memory problems:</div>


<div><div class="im"><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">matMult :: Matrix -&gt; Matrix -&gt; Matrix</div></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">


matMult mA mB = mapP (\row -&gt; mapP (\col -&gt; dotp row col) <b>mB</b>) mA</div><div class="im"><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif"><br></div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">


dotp :: MVector -&gt; MVector -&gt; MMultType</div><div style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">dotp row col = D.sumP (zipWithP (D.*) row col)</div></div></div><div>
<br></div><div>Later today (or tomorrow) I will post exact OS, GHC and libraries version as the command line options and execution information on the simplified example.</div><div><br></div><div>Thanks again<div><div class="h5">

<br><br><div class="gmail_quote">
On Tue, Jul 10, 2012 at 8:43 AM, Manuel M T Chakravarty <span dir="ltr">&lt;<a href="mailto:chak@cse.unsw.edu.au" target="_blank">chak@cse.unsw.edu.au</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div style="word-wrap:break-word"><div>Firstly, especially when you are talking about performance, please provided detailed information on (a) the versions of the compiler and libraries that you used and (b) of the command line options that you used for compilation.</div>


<div><br></div><div>Secondly, your function &#39;transposeP&#39; doesn&#39;t make for a good nested data-parallel program. I haven&#39;t looked at the generated code, but I wouldn&#39;t be surprised if it doesn&#39;t optimise very well.</div>


<div><br></div><div>The core benefit of nested data parallelism is that the sub-arrays in a nested array of arrays can be of varying size leading to irregular parallelism. However, that flexibility comes at a price, namely that it is a fairly inefficient representation for *rectangular arrays*, such as regular two-dimensional matrices (as in your example). It shouldn&#39;t be quite as inefficient as what you report, but it will never be competitive with a dedicated regular representation.</div>


<div><br></div><div>Hence, for code, such as yours, we recommend to use our Repa library: <a href="http://hackage.haskell.org/package/repa" target="_blank">http://hackage.haskell.org/package/repa</a></div><div><br></div>

<div>
It generates very fast code for regular array problems, see also <a href="http://www.cse.unsw.edu.au/~chak/papers/LCKP12.html" target="_blank">http://www.cse.unsw.edu.au/~chak/papers/LCKP12.html</a></div><div><br></div><div>


Manuel</div><div><br></div><br><div><div>mblanco &lt;<a href="mailto:blancomau@gmail.com" target="_blank">blancomau@gmail.com</a>&gt;:</div><blockquote type="cite"><div><div><div style="font-family:arial,sans-serif">
Hi, I&#39;m trying to implement a matrix product example using DPH. This is the code:</div><div style="font-family:arial,sans-serif"><div>------------------------------<u></u>------------------------------<u></u>------------------------------<u></u>-------------------------<br>


</div><div><div>type MMultType = Double</div><div>type Matrix = [:[:MMultType:]:]</div><div>type MVector = [:MMultType:]</div><div>type Matrix_wrapper = PArray (PArray MMultType)</div></div><div><br></div><div><div>{-# NOINLINE matMult_wrapper #-}</div>


<div>matMult_wrapper :: Matrix_wrapper -&gt; Matrix_wrapper -&gt; Matrix_wrapper</div><div>matMult_wrapper mA mB = toPArrayP (mapP toPArrayP (matMult (fromNestedPArrayP mA) (fromNestedPArrayP mB)))</div><div><br></div><div>


matMult :: Matrix -&gt; Matrix -&gt; Matrix</div><div>matMult mA mB = mapP (\row -&gt; mapP (\col -&gt; dotp row col) (transposeP mB)) mA</div><div><br></div><div>dotp :: MVector -&gt; MVector -&gt; MMultType</div><div>dotp row col = D.sumP (zipWithP (D.*) row col)</div>


<div><br></div><div>transposeP :: Matrix -&gt; Matrix</div><div>transposeP m = </div><div>    let</div><div>        h = lengthP m</div><div>        w = lengthP (m !: 0)</div><div>        rh = I.enumFromToP 0 (h I.- 1)</div>


<div>        rw = I.enumFromToP 0 (w I.- 1)</div><div>    in</div><div>        if h I.== 0 then [: :]</div><div>        else mapP (\y -&gt; mapP (\x -&gt; m !: x !: y) rh) rw</div></div><div>------------------------------<u></u>------------------------------<u></u>------------------------------<u></u>-------------------------</div>


</div><div style="font-family:arial,sans-serif"><br></div><div style="font-family:arial,sans-serif">My problem is at execution time, on matrices of size 300*300 the program does finish (although it is very slow), but on 700*700 it consumes GBs of RAM until the process is aborted.</div>


<div style="font-family:arial,sans-serif"><br></div><div style="font-family:arial,sans-serif">In the paper &quot;Work Efficient Higher-Order Vectorisation&quot; it is explained that a work complexity problem (wich involved unnecesary array replication) was recently treated. So at first I thought the code implementation related to the paper had not been uploaded to hackage. But as I understand it must have been, as that seems to be the motive of the &quot;dph-lifted-vseg&quot; package.</div>


<div style="font-family:arial,sans-serif"><br></div><div style="font-family:arial,sans-serif">Does anybody notice the problem with the example or if the problem is related to the subject treated in the paper?</div><div style="font-family:arial,sans-serif">


<br></div><div style="font-family:arial,sans-serif">Thanks in advance!</div></div></div>_______________________________________________<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>


<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br></blockquote></div><br></div></blockquote></div><br><br clear="all"><div><br></div>

</div></div><span class="HOEnZb"><font color="#888888">
-- <br><div dir="ltr">Mauro Blanco<br></div><br>
</font></span></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Mauro Blanco<br></div><br>
</div></div>