[Rcpp-devel] Inline and Parallel computing

Marie Auger-Methe marie.augermethe at gmail.com
Thu Apr 19 17:11:27 CEST 2012


Hi list,

sorry for bombarding the list with questions.
I'm trying to use Rcpp via the inline package and to use parallel 
computing at the same time. But I get this error:

first error: NULL value passed as symbol address
I've read a few posts (not related to parallel computing) discussing this error but I couldn't link it back to my specific problem.

Here is an example:

library(inline)
library(parallel)

# A silly Rcpp function
sillyscr<- '
   int x = as<int>(i);
   double y = 5.6;
   NumericVector j(1);
   j[0] =  x + y;

   return j;
'
silly<- cxxfunction(signature(i = "int"), body = sillyscr, plugin = "Rcpp")
silly(1) # Works!

# Equivalent function in R to make sure the problem is not the parallel computing
silly_notcpp<- function(i){
   j<- i +5.6
   return(j)
}
silly_notcpp(1) # Works !


M<- detectCores()
cl<- makeCluster(M)
clusterExport(cl, varlist=list("silly","silly_notcpp"))
res1<- parSapply(cl, 1:10,silly_notcpp) # Works!
res1
res2<- parSapply(cl, 1:10,silly) # Does not work !
res2
stopCluster(cl)

Many thanks!

Marie

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20120419/4e07e85a/attachment.html>


More information about the Rcpp-devel mailing list