On 24 March 2016 at 01:02, Hoang Nguyen wrote: | Hi, | I am working with Rcpp and need to call function bessel_k from R::bessel_k in | parallel. I got usually crash in Rstudio, and still not find out which is the | mistake
You _cannot call back to R_ from parallel code. | Here is my code in R: | | Sys.setenv("PKG_CXXFLAGS"="-fopenmp") | Sys.setenv("PKG_LIBS"="-fopenmp") | library(Rcpp) | sourceCpp("Bessel.cpp") | xseq = rt(10000,df = 8) | param <- c(0.0000000, 2.8284271, -0.4954229, 8.0000000) | BasselCm <- BasselC(xseq,param) | | here is my code in Bessel.cpp: | if I set num threads(2) it was crash but run smooth if I set back to 1. Sorry but I fear you either -- must write a new C++ implementation of the Bessel_k, or -- if you want to use R's, you need to use process-parallelism (ie something like OpenMPI to separate R processes). Dirk | | Thank you so much for your consideration. | | Best regards. | | | | | > sessionInfo() | R version 3.2.4 Revised (2016-03-16 r70336) | Platform: x86_64-pc-linux-gnu (64-bit) | Running under: Ubuntu 14.04.4 LTS | | locale: | [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME= | es_ES.UTF-8 | [4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=es_ES.UTF-8 LC_MESSAGES= | en_US.UTF-8 | [7] LC_PAPER=es_ES.UTF-8 LC_NAME=C LC_ADDRESS= | C | [10] LC_TELEPHONE=C LC_MEASUREMENT=es_ES.UTF-8 LC_IDENTIFICATION= | C | | attached base packages: | [1] stats graphics grDevices utils datasets methods base | | other attached packages: | [1] Rcpp_0.12.3 | | loaded via a namespace (and not attached): | [1] tools_3.2.4 RcppArmadillo_0.6.600.4.0 | | | -- | | | [DELETED ATTACHMENT Bessel.cpp, text/x-c++src] | _______________________________________________ | Rcpp-devel mailing list | Rcpp-devel@lists.r-forge.r-project.org | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel -- http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel