<div dir="ltr">Here's a parallel version:<div><br></div><div><a href="https://github.com/jjallaire/RcppParallel/blob/master/inst/examples/parallel-distance-matrix.cpp">https://github.com/jjallaire/RcppParallel/blob/master/inst/examples/parallel-distance-matrix.cpp</a><br>
</div><div><br></div><div>To make the code reasonable I introduced a new RMatrix<T> class in RcppParallel that makes offsetting into rows and columns safe and straightforward. This class has no connection on the R or Rcpp APIs so is guaranteed to be thread-safe.</div>
<div><br></div><div>On a 4 core machine (8 with hyperthreading) I'm observing a 10x speedup. The parallel related speedup is 4x. There is an additional 2.5x speedup which appears to be related to the lower level access to the Matrix memory done by RMatrix<T> (and perhaps some elimination of copying).</div>
<div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Jul 13, 2014 at 7:27 AM, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=""><br>
On 12 July 2014 at 12:37, JJ Allaire wrote:<br>
| If you could send the full source code to your example (including js_distance<br>
| and whatever R code you are using to test/exercise the functions) I'll see if I<br>
| can come up with the code you'd use to parallelize the outer loop. Depending on<br>
| how it turns out perhaps we can even convert this into another gallery article!<br>
<br>
</div>That's the spirit!  [ I had another quick look at the inner-product example<br>
which is short and nice, but there is just too little of a pickup there... ]<br>
<div class="HOEnZb"><div class="h5"><br>
Dirk<br>
<br>
--<br>
<a href="http://dirk.eddelbuettel.com" target="_blank">http://dirk.eddelbuettel.com</a> | @eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a><br>
</div></div></blockquote></div><br></div>