0

尽管成功R-3.1.2使用英特尔编译器套件 ver.2015.0.077 进行了编译,包括MKL在我运行 Yosemite 的 2014 年末 MacBook Pro(此处概述)上,但我无法Rcpp通过R为 Mavericks预打包的二进制文件。现在,我想加快速度,特别是使用OpenMP似乎与默认不兼容的clang. 我知道该OpenMP/clang项目,但似乎在优胜美地上的安装仍然很狡猾。

除了Warning in strptimemake -j8. make install_ R_ 尽管如此,该Rcpp软件包还是失败了:

> install.packages("Rcpp")

Warning in strptime(xx, f <- "%Y-%m-%d %H:%M:%OS", tz = tz) :
  unknown timezone 'Asia/Kolkata'
Warning in strptime(xx, f <- "%Y-%m-%d %H:%M:%OS", tz = tz) :
  unknown timezone 'GMT'
Warning in strptime(xx, f <- "%Y-%m-%d %H:%M:%OS", tz = tz) :
  unknown timezone 'America/New_York'
* installing *source* package ‘Rcpp’ ...
** package ‘Rcpp’ successfully unpacked and MD5 sums checked
Warning in as.POSIXlt.POSIXct(x, tz) : unknown timezone 'GMT'
Warning in as.POSIXlt.POSIXct(x, tz) :
  unknown timezone 'America/New_York'
** libs
icpc -I/Users/username/R-3.1.2/include -DNDEBUG -I../inst/include/ -I/sw/include -I/usr/local/include    -fPIC  -g -O3   -c Date.cpp -o Date.o
In file included from ../inst/include/Rcpp/Vector.h(69),
                 from ../inst/include/Rcpp.h(38),
                 from Date.cpp(31):
../inst/include/Rcpp/vector/swap.h(35): error: "swap" is not a class or function template name in the current scope
  RCPP_GENERATE_SWAP(generic_proxy,VECSXP)
  ^

In file included from ../inst/include/Rcpp/Vector.h(69),
                 from ../inst/include/Rcpp.h(38),
                 from Date.cpp(31):
../inst/include/Rcpp/vector/swap.h(36): error: "swap" is not a class or function template name in the current scope
  RCPP_GENERATE_SWAP(generic_proxy,EXPRSXP)
  ^

In file included from ../inst/include/Rcpp/Vector.h(69),
                 from ../inst/include/Rcpp.h(38),
                 from Date.cpp(31):
../inst/include/Rcpp/vector/swap.h(37): error: "swap" is not a class or function template name in the current scope
  RCPP_GENERATE_SWAP(string_proxy,STRSXP)
  ^

Date.cpp(562): warning #437: reference to local variable of enclosing function is not allowed
              2 * sizeof *sp + 4 * TZ_MAX_TIMES];
                          ^

compilation aborted for Date.cpp (code 2)
make: *** [Date.o] Error 2
ERROR: compilation failed for package ‘Rcpp’

有没有办法来解决这个问题?或者,如何切换编译器以便能够Rcpp在我的 MacBook 上调用“OpenMP”?

4

1 回答 1

2

这是我对正在发生的事情的最佳猜测。在中,我们为这里Rcpp提供了专业化,为简洁起见复制了相关位:std::swap()

namespace std {

#undef RCPP_GENERATE_SWAP
#define RCPP_GENERATE_SWAP(TYPE,RTYPE)                          \
    template<> inline void swap< Rcpp::internal::TYPE<RTYPE> >( \
        Rcpp::internal::TYPE<RTYPE>& a ,                            \
        Rcpp::internal::TYPE<RTYPE>& b) {                           \
            a.swap(b) ;                                             \
        }

RCPP_GENERATE_SWAP(generic_proxy,VECSXP)
RCPP_GENERATE_SWAP(generic_proxy,EXPRSXP)
RCPP_GENERATE_SWAP(string_proxy,STRSXP)
#undef RCPP_GENERATE_SWAP

}

看起来您的编译器遇到此标头的那一刻,std::swap()尚未看到适当的模板定义,因此它会出错。这让我感到惊讶,因为我们确实明确提供了#include <algorithm>in RcppCommon.h,默认情况下包含它。或者,也许您的编译器使用的头文件std::swap()以这样一种方式定义,即这种形式的专业化不起作用——我不确定。

FWIW,cppreference提倡在定义类型的命名空间内提供这些专业化,而不是std,以允许 ADL。

您可以尝试在本地修改 Rcpp 源以查看是否可以提供另一种支持方式std::swap()(如 建议的那样cppreference),然后Rcpp如果一切看起来都很好,那么也建议对上游进行修改。

于 2015-02-22T13:14:20.127 回答