[Rcpp-devel] Using Rcpp::Function in parallel with TBB mutex lock & a reference.

Kumar MS mskb01 at gmail.com
Fri Feb 7 20:01:51 CET 2025


Thank you Dirk. Your observation is correct. I am left with two questions.
As always, I appreciate your answers.

1. Except for this single step of calling an R function (model matrix-like
objects that are being created by an external library in R), all my other
computations are now implemented in C++ & thread friendly. Does this mean I
would have no other option but to go serial if I need to call R an
function? Do you have any alternative recommendations? I would really love
to take advantage of RcppParallel/TBB here, as I have heavily exploited
RcppParallel to parallelize everything else.
2. Your RInside calculations in the Boost thread example are
multi-threaded, with a locking interface to RInside instance too. I wonder
what makes that work well without R reporting issues, while the
TBB/rcppParallel implementation taking a similar approach has trouble.

Sincerely,
Kumar

On Fri, Feb 7, 2025 at 1:41 PM Dirk Eddelbuettel <edd at debian.org> wrote:

>
> Hi Kumar,
>
> From a quick look you borrow the 'Worker' object from RcppParallel. But
> where
> (as far as I recall) all posted examples of RcppParallel do _not_ put any R
> objects inside a Worker instance, you put some there. That violates the
> recommendation in Writing R Extensions. So I think the outcome you observe
> is
> as expected.
>
> Best, Dirk
>
> --
> 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/20250207/c324f142/attachment-0001.htm>


More information about the Rcpp-devel mailing list