'Rcpp and parallel

I have an Rcpp routine that is given an R function and then does various computations. When run as such it works just fine. Now I want to run it in parallel, and then I get the error

Error in checkForRemoteErrors(lapply(cl, recvResult)): 4 nodes produced errors; first error: NULL value passed as symbol address

A toy example is here. The routine is supposed to generate 10 observations from a normal distribution with the mean passed as an argument:

The Rcpp code:

#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
NumericVector tst(Function f, double m) {
   NumericVector out=f(m);
   return out;
}

and running

f=function(m) {rnorm(10, m)}
tst(f, 5)

works fine. But trying

cl <- makeCluster(4)
z=clusterCall(cl, tst, f, 5)

results in the error.

In the real routine f could be any routine that generates data, even something not part of base R.

Wolfgang



Solution 1:[1]

I had read many of the discussions on the subject before, and even created a package, but kept getting error messages. I have it running now, even though I am not sure what the problem was before.

Anyway, thanks for the replies!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Wolfgang Rolke