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