Linux中内联函数,Windows 7上的内联函数的doParallel问题(适用于Linux)

我在

Windows 7和

Linux(SUSE Server 11(x86_64))上都使用R 3.0.1.以下示例代码在Windows上产生错误,但在Linux上不产生错误.列出的所有工具箱在两台机器中都是最新的.

Windows错误是:

Error in { : task 1 failed - "NULL value passed as symbol address"

如果我将%dopar%更改为%do%,则Windows代码运行时不会出现任何错误.我最初的猜测是,这与Windows中的一些配置问题有关,我尝试重新安装Rcpp和R,但这没有帮助.该错误似乎与作用域有关 – 如果我在f1中定义并编译函数cFunc,那么%dopar%可以工作,但是,正如预期的那样,它非常慢,因为我们为每个任务调用一次编译器.

有没有人对错误发生的原因或如何解决它的建议有一些见解?

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

谢谢!

古斯塔沃

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值