[Rcpp-devel] usage question (avoiding data copies)

Dirk Eddelbuettel edd at debian.org
Sat Mar 2 16:19:50 CET 2013


On 2 March 2013 at 09:58, Greg Minshall wrote:
| hi, all.  i've had great success speeding up my computations using
| Rcpp/C++.  (thanks to the list for the help getting up and running.)
| 
| but...
| 
| now, when i scale up (from a 554x415 matrix to a 2592x1936 matrix), my
| run time slows down, and experimenting, it seems it's the cost of
| copying my dataset between R and C++ that is taking the time.  (i drive
| the process from R, and have 4 passes that are processed in C++.)
| 
| i could leave all the data in C++-land, but for investigating the data,
| etc., i would really like to be able to access it from the R side.
| 
| any suggestions on how to proceed?  i'm currently shipping a list of S4
| objects and a numeric matrix across the interface.  would converting
| both to be reference classes allow me to avoid the copies, but still
| access both from the R side?  (if i have to pay a performance penalty
| for access, i'd rather pay it from the R side, as long as it isn't too
| onerous.)

You get a very firm "maybe" from me and the recommendation to carefully
profile your code.  Everything else is just waffling.

You can be explicit about not copying with the XPtr class using R's external
pointers. 

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com  


More information about the Rcpp-devel mailing list