Linux中内联函数,Windows 7上的内联函数的doParallel问题(适用于Linux)
我在
Windows 7和
Linux(SUSE Server 11(x86_64))上都使用R 3.0.1.以下示例代碼在Windows上產(chǎn)生錯誤,但在Linux上不產(chǎn)生錯誤.列出的所有工具箱在兩臺機(jī)器中都是最新的.
Windows錯誤是:
Error in { : task 1 failed - "NULL value passed as symbol address"
如果我將%dopar%更改為%do%,則Windows代碼運(yùn)行時不會出現(xiàn)任何錯誤.我最初的猜測是,這與Windows中的一些配置問題有關(guān),我嘗試重新安裝Rcpp和R,但這沒有幫助.該錯誤似乎與作用域有關(guān) – 如果我在f1中定義并編譯函數(shù)cFunc,那么%dopar%可以工作,但是,正如預(yù)期的那樣,它非常慢,因為我們?yōu)槊總€任務(wù)調(diào)用一次編譯器.
有沒有人對錯誤發(fā)生的原因或如何解決它的建議有一些見解?
library(inline)
sigFunc
code
for(int k = 0; k < INTEGER(size_x)[0]; k++){
tot += REAL(x)[k];
};
return ScalarReal(tot);
'
cFunc
f1
x
a
return(a)
}
library(foreach)
library(doParallel)
registerDoParallel()
# this produces an error in Windows but not in Linux
res
# this works for both Windows and Linux
res
# The following is not a practical solution, but I can compile cFunc inside f1 and then this works in Windows but it is very slow
f1
library(inline)
sigFunc
code
for(int k = 0; k < INTEGER(size_x)[0]; k++){
tot += REAL(x)[k];
};
return ScalarReal(tot);
'
cFunc
x
a
return(a)
}
# this now works in Windows but is very slow
res
謝謝!
古斯塔沃
總結(jié)
以上是生活随笔為你收集整理的Linux中内联函数,Windows 7上的内联函数的doParallel问题(适用于Linux)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Examining Open vSwit
- 下一篇: Linux环境变量PSI指什么,PSI