<div dir="ltr"><div class="gmail_extra">On 4 March 2013 14:50, J <span dir="ltr"><<a href="mailto:private@private-dont-email-dont-spam.com" target="_blank">private@private-dont-email-dont-spam.com</a>></span> wrote:<br>
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5">On Monday, 4 March 2013 at 04:22:01 UTC, bearophile wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
So this should be better:<br>
<br>
<a href="http://codepad.org/B5b4uyBM" target="_blank">http://codepad.org/B5b4uyBM</a><br>
<br>
Bye,<br>
bearophile<br>
</blockquote>
<br></div></div>
@bearophile: Thank you!  Unfortunately the <a href="http://codepad.org/B5b4uyBM" target="_blank">http://codepad.org/B5b4uyBM</a> code runs a bit *slower* than the original D code. Yikes!<br>
<br>
$  gdmd -O -inline -release -noboundscheck -m64 bear.d -ofdbear<br>
$ time ./dbear<br>
-1015380632 859379360 -367726792 -1548829944<br>
<br>
real    2m36.971s<br>
user    2m36.910s<br>
sys 0m0.030s<br>
$ time ./dbear<br>
-1015380632 859379360 -367726792 -1548829944<br>
<br>
real    2m34.425s<br>
user    2m34.370s<br>
sys 0m0.020s<br>
<br>
<br>
@John Colvin: here is the disassembly of mmult() in both languages. Unfortunately I'm not literate in x86_64 assembly.  Perhaps the problem is obvious to you?  All I can really tell is that the g++ version is shorter.<br>

<br>
The memory allocation, when timed separately (comment out mmult), is less than 60 msec for either version, so I don't think its a memory issue, although it could be caching issue since the matrix layouts are different.<br>
</blockquote><div><br></div>Using dynamic arrays of dynamic arrays that way is pretty poor form regardless of the language.<div><br><div>You should really use single dimensional array:</div><div>  int matrix[SIZE*SIZE];</div>
<div>And index via: </div><div>  matrix[y*SIZE+x]</div><div><br></div><div>(You can pretty this up in various ways, if this is too unsightly)</div></div><div><br></div></div></div><div class="gmail_extra"><br></div><div class="gmail_extra">
On 4 March 2013 14:02, John Colvin <span dir="ltr"><<a href="mailto:john.loughran.colvin@gmail.com" target="_blank">john.loughran.colvin@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5"><span style="color:rgb(34,34,34)">    int[][] m = new int[][](rows, cols);</span></div>
</div></blockquote><div><br></div><div>Does D support proper square array's this way? Or does it just automate allocation of the inner arrays?</div><div>Does it allocate all the associated memory in one block?</div></div>
</div></div></div>