<div dir="ltr">Here it's recommended that you simply read the source code to figure out if memory allocations or stack checking are done: <a href="https://rcppcore.github.io/RcppParallel/#api_restrictions">https://rcppcore.github.io/RcppParallel/#api_restrictions</a></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Apr 15, 2018 at 11:56 PM, Murray Efford <span dir="ltr"><<a href="mailto:murray.efford@gmail.com" target="_blank">murray.efford@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Thanks. This is all happening inside a package for CRAN, so I would rather avoid more complexity and potential platform-dependence, but I also cannot afford for it to break unpredictably (or otherwise).<span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888">Murray<br></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 16, 2018 at 3:33 PM, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><br>
On 16 April 2018 at 13:41, Murray Efford wrote:<br>
| I read in the RcppParallel blurb "The code that you write within parallel<br>
| workers should not call the R or Rcpp API in any fashion", which is<br>
| admirably clear. However, it leaves me without threadsafe access to<br>
| distribution functions (dpois, dbinom etc.). In practice, so far, these R<br>
| API calls seem to work for me, but can they be trusted? Is there an<br>
| alternative?<br>
<br>
</span>That's a fair question. They may work, as they are also exposed / available<br>
via the standalone R math library (see Writing R Extensions).<br>
<br>
As such, they may not required memory allocations or other interactions with<br>
the R process and hence "not call R ... in any fashion" per the above. <br>
<br>
But we can't say for sure. If you want to be safe, maybe stick to <br>
equivalent functions from a non-R source: C++11, Boost, ...  <br>
<br>
Dirk<br>
<div class="m_4043386532855329696HOEnZb"><div class="m_4043386532855329696h5"><br>
| (It seems this question must have arisen before, but I haven't found an<br>
| answer)<br>
<br>
</div></div><span class="m_4043386532855329696HOEnZb"><font color="#888888">-- <br>
<a href="http://dirk.eddelbuettel.com" rel="noreferrer" target="_blank">http://dirk.eddelbuettel.com</a> | @eddelbuettel | <a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a><br>
</font></span></blockquote></div><br></div>
</div></div><br>______________________________<wbr>_________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-<wbr>project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" rel="noreferrer" target="_blank">https://lists.r-forge.r-<wbr>project.org/cgi-bin/mailman/<wbr>listinfo/rcpp-devel</a><br></blockquote></div><br></div>