Използването на sourceCpp
изглежда не работи с паралел. Как мога да извикам Rcpp
функция на parallel
клъстер?
моят пример:
Файл test.cpp
:
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
NumericVector timesTwo(NumericVector x) {
return x * 2;
}
И файл R
:
library(parallel)
library(Rcpp)
sourceCpp("test.cpp")
timesTwo(1)
# [1] 2
cl <- makeCluster(2)
clusterEvalQ(cl, {
library(Rcpp)
sourceCpp("test.cpp")
timesTwo(1)
})
# Error in checkForRemoteErrors(lapply(cl, recvResult)) :
# 2 nodes produced errors; first error: Error 1 occurred building shared library.
stopCluster(cl)