icc:包括 omp.h 需要 byteswap.h

icc: including omp.h requires byteswap.h

刚刚尝试使用 icc-11 编译我的代码(与 gcc 完美配合)。
如果我包含 omp.h 我会收到以下错误:

/usr/include/bits/byteswap.h(47): error: identifier "__builtin_bswap32" is undefined
    return __builtin_bswap32 (__bsx);
           ^

/usr/include/bits/byteswap.h(111): error: identifier "__builtin_bswap64" is undefined
    return __builtin_bswap64 (__bsx);

如果我包含 stdlib.h,也会发生同样的情况。

我真的很困惑,我什至不知道byteswap有什么用。我在编译前发布了 iccvars_intel64.sh 脚本。虽然没有多大帮助。

有什么想法吗?

P.S.: 如果想并行化一些循环,我什至需要包含 omp.h 吗?也许我可以简单地省略 #include <omp.h>.

很遗憾,ICC 11.0 不支持 __builtin_bswap32__builtin_bswap64。您可能会遇到这些错误,因为 byteswap.h 包含在 omp.hstdlib.h 内部。此 LLVM bug report.

中也报告了此问题

基本上,您的系统 headers "newer" 与 ICC 11.0 不兼容。

由于更新的 ICC 版本支持 bswap 内置函数(至少从 13.0 开始,根据 Compiler Explorer),一种选择是升级到更新的 ICC。

或者,您需要使用与 ICC 11.0 兼容的标准 headers,而不是您的系统标准,如英特尔开发人员专区 thread 中所述。一种方法是安装 "matches" ICC 11.0 的 GCC 版本,然后告诉 ICC 使用与该 GCC 捆绑在一起的 headers。根据 Wikipedia, ICC 11.0 was released on Nov. 2008, so the GCC 4.2 release series may be compatible (see here for other GCC releases).