[Rcpp-devel] Distribution functions threadsafe in RcppParallel?

JJ Allaire jj.allaire at gmail.com
Mon Apr 16 13:04:53 CEST 2018


Here it's recommended that you simply read the source code to figure out if
memory allocations or stack checking are done:
https://rcppcore.github.io/RcppParallel/#api_restrictions

On Sun, Apr 15, 2018 at 11:56 PM, Murray Efford <murray.efford at gmail.com>
wrote:

> 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).
> Murray
>
> On Mon, Apr 16, 2018 at 3:33 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
>
>>
>> On 16 April 2018 at 13:41, Murray Efford wrote:
>> | I read in the RcppParallel blurb "The code that you write within
>> parallel
>> | workers should not call the R or Rcpp API in any fashion", which is
>> | admirably clear. However, it leaves me without threadsafe access to
>> | distribution functions (dpois, dbinom etc.). In practice, so far, these
>> R
>> | API calls seem to work for me, but can they be trusted? Is there an
>> | alternative?
>>
>> That's a fair question. They may work, as they are also exposed /
>> available
>> via the standalone R math library (see Writing R Extensions).
>>
>> As such, they may not required memory allocations or other interactions
>> with
>> the R process and hence "not call R ... in any fashion" per the above.
>>
>> But we can't say for sure. If you want to be safe, maybe stick to
>> equivalent functions from a non-R source: C++11, Boost, ...
>>
>> Dirk
>>
>> | (It seems this question must have arisen before, but I haven't found an
>> | answer)
>>
>> --
>> http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
>>
>
>
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20180416/8e11ce7d/attachment.html>


More information about the Rcpp-devel mailing list