<div dir="ltr">Thank you Dirk. Your observation is correct. I am left with two questions. As always, I appreciate your answers.<div><br></div><div>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. </div><div>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. </div><div><br></div><div>Sincerely,</div><div>Kumar</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Fri, Feb 7, 2025 at 1:41 PM Dirk Eddelbuettel <<a href="mailto:edd@debian.org">edd@debian.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Hi Kumar,<br>
<br>
>From a quick look you borrow the 'Worker' object from RcppParallel. But where<br>
(as far as I recall) all posted examples of RcppParallel do _not_ put any R<br>
objects inside a Worker instance, you put some there. That violates the<br>
recommendation in Writing R Extensions. So I think the outcome you observe is<br>
as expected. <br>
<br>
Best, Dirk<br>
<br>
-- <br>
<a href="http://dirk.eddelbuettel.com" rel="noreferrer" target="_blank">dirk.eddelbuettel.com</a> | @eddelbuettel | <a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a><br>
</blockquote></div>