Dillon,

The point of RMatrix and RVector in RcppParallel is to shield objects inside
the RcppParallel blocks using Intel TBB from any interaction with the outer R
process which may, or may not, run a gc() to rearrange its memory.

Where they work, you should not use Rcpp's own NumericMatrix and alike. As for

   Is there a way to write generic functions that will work in both cases?

Yes, with care. Standard C++ should work. You have to 'arrange' functionality
in such a way that you have "clean" internal functions (using STL objects
and/or RMatrix and RVector) plus a wrapper making them callable from R).

    Is it safe to create new objects on each thread

Yes, but they have to standard C++ objects. At the once, your sums or
reductions or ... have completed, converted to something you can return to R.

The golden rule simply is 'no R objects in the inner core'.

Hope this helps and was clear enough, I am still on my first coffee.

Dirk

-- 
https://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org
_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to