[Rcpp-devel] parallel distance matrix calculation

JJ Allaire jj.allaire at gmail.com
Mon Jul 14 16:45:06 CEST 2014


Here's a parallel version:

https://github.com/jjallaire/RcppParallel/blob/master/inst/examples/parallel-distance-matrix.cpp

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.

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).




On Sun, Jul 13, 2014 at 7:27 AM, Dirk Eddelbuettel <edd at debian.org> wrote:

>
> On 12 July 2014 at 12:37, JJ Allaire wrote:
> | If you could send the full source code to your example (including
> js_distance
> | and whatever R code you are using to test/exercise the functions) I'll
> see if I
> | can come up with the code you'd use to parallelize the outer loop.
> Depending on
> | how it turns out perhaps we can even convert this into another gallery
> article!
>
> That's the spirit!  [ I had another quick look at the inner-product example
> which is short and nice, but there is just too little of a pickup there...
> ]
>
> Dirk
>
> --
> http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20140714/a4fcf62a/attachment.html>


More information about the Rcpp-devel mailing list