[Rcpp-devel] Optimising 2d convolution

Hadley Wickham hadley at rice.edu
Fri Jan 6 21:02:33 CET 2012


> What are you doing the timing on?  On a modest desktop (2.6 GHz Athlon
> X4) I get less than a second for this
...
>> k <- matrix(runif(20* 20), ncol = 20)
>> system.time(convolve_2d(x, k))
>   user  system elapsed
>  0.864   0.000   0.862

Ooops, I must have been using a old k - I now get

> system.time(convolve_2d(x, k))
   user  system elapsed
  2.265   0.006   2.298

I'm on a 2nd gen macbook air, so the processor isn't the fastest (2.13
GHz). Maybe my intuition is wrong but it seems like you should be able
to do it faster than that.

But let me think - I'm doing 1000 * 1000 * 20 * 20 = 4e08 multiplies +
adds in ~2s.  So that's 5e-9 s = 5 ns per operation.  Looking at it
that way it does seem pretty fast already.

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/


More information about the Rcpp-devel mailing list