在Solaris 11上使用Sun提供的GCC的_blsr_u64的标头
Header for _blsr_u64 with Sun supplied GCC on Solaris 11?
我们有一些在多个平台上运行的代码。该代码在可用时使用BMI/BMI2内部函数,如Core i7第5代。Sun在Solaris 11.3上提供的GCC定义了__BMI__
和__BMI2__
,但在查找BMI/BMI1内部函数时遇到问题:
$ cat test.cxx
#include <x86intrin.h>
int main(int argc, char* argv[])
{
unsigned long long t = argc;
#if defined(__BMI__) || defined(__BMI2__)
t = _blsr_u64(t);
#endif
return int(t);
}
$ /bin/g++ -march=native test.cxx -o test.exe
test.cxx: In function ‘int main(int, char**)’:
test.cxx:6:18: error: ‘_blsr_u64’ was not declared in this scope
t = _blsr_u64(t);
^
包括immintrin.h并没有什么区别。
在Solaris 11.3上使用GCC时,_blsr_u64
包含哪个标头?
以下是GCC的相关定义:
$ /bin/g++ -march=native -dM -E - < /dev/null | sort |
/usr/gnu/bin/egrep -i '(sse|aes|rdrnd|rdseed|avx|bmi)'
#define __AES__ 1
#define __AVX__ 1
#define __AVX2__ 1
#define __BMI__ 1
#define __BMI2__ 1
#define __core_avx2 1
#define __core_avx2__ 1
#define __RDRND__ 1
#define __RDSEED__ 1
#define __SSE__ 1
#define __SSE2__ 1
#define __SSE3__ 1
#define __SSE4_1__ 1
#define __SSE4_2__ 1
#define __SSSE3__ 1
#define __tune_core_avx2__ 1
以及CPU功能:
$ isainfo -v
64-bit amd64 applications
avx xsave pclmulqdq aes movbe sse4.2 sse4.1 ssse3 amd_lzcnt popcnt tscp
ahf cx16 sse3 sse2 sse fxsr mmx cmov amd_sysc cx8 tsc fpu prfchw adx
rdseed efs rtm hle bmi2 avx2 bmi1 f16c fma rdrand
GCC版本:
$ /bin/g++ --version
g++ (GCC) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
在Solaris 11.3上使用GCC时,我们为_blsr_u64包含哪个标头?
看起来#include <x86intrin.h>
是正确的。
问题是编译器调用需要-march=native -m64
,即使64位是机器的本机,内核是64位:
$ /bin/g++ -march=native -m64 test.cxx -o test.exe
相关文章:
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 奇怪的结构&GCC&clang(void*返回类型)
- GCC本机矩阵运算库
- PowerPC ppc64le上的Gcc Woverloaded虚拟错误
- gcc和c++17的过载解析失败
- 数据成员SFINAE的C++17测试:gcc vs clang
- GCC对可能有效的代码抛出init list生存期警告
- 如何解决gcc编译器优化导致的centos双编译器设置中的分段错误
- 使用 GCC 卸载的 OpenMP 卸载失败,并出现"Ptx assembly aborted due to errors"
- 为什么与常规GCC不同,即使有"学究性错误",MinGW-GCC也能容忍丢失的返回类型
- 使用gcc从静态链接的文件中查找可选符号
- 普通环路未使用gcc 4.8.5自动矢量化
- 有了gcc,是否可以链接库,但前提是它存在
- 在clang++预处理器中确定gcc工具链版本
- 为什么 gcc 编译这个而 msvc 没有
- 为什么lambda在clang上崩溃而不是在gcc上崩溃
- 我可以检测和更改 gcc/g++ 中结构的当前数据对齐设置吗?
- gcc和clang在表达式是否为常量求值的问题上存在分歧
- 如何使用Clang/GCC在Mac上为C/C++设置VSCode
- 一位朋友将模板函数缩写为clang和gcc