_blsr_u64的标题与Sun在Solaris 11上提供了GCC? [英] Header for _blsr_u64 with Sun supplied GCC on Solaris 11?

查看:202
本文介绍了_blsr_u64的标题与Sun在Solaris 11上提供了GCC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一些在多个平台上运行的代码。该代码使用 BMI / BMI2 内在函数,如Core i7 5th gen。由Sun在Solaris 11.3上提供的GCC正在定义 __ BMI __ __ BMI2 __ ,但它在定位BMI / BMI2内部函数时遇到了问题:

  $ cat test.cxx 
#include< x86intrin.h>
int main(int argc,char * argv [])
{
unsigned long long t = argc;
#if defined(__ BMI__)||定义(__ BMI2__)
t = _blsr_u64(t);
#endif
return int(t);

$ b $ / bin / g ++ -march = native test.cxx -o test.exe
test.cxx:在函数中int main(int,char **) ':
test.cxx:6:18:错误:'_blsr_u64'未在此范围内声明
t = _blsr_u64(t);
^

包括 immintrin.h 没有区别。



其中头文件当在Solaris 11.3上使用GCC时,我们是否包含 _blsr_u64




<

  $ / bin / g ++ -march = native -dM -E  - < / dev / null |排序| \ 
/ 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位amd64应用程序
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
版权所有(C)2013 Free Software Foundat ion,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 


We've got some code that runs on multiple platforms. The code uses BMI/BMI2 intrinsics when available, like a Core i7 5th gen. GCC supplied by Sun on Solaris 11.3 is defining __BMI__ and __BMI2__, but its having trouble locating BMI/BMI2 intrinsics:

$ 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);
                  ^

Including immintrin.h does not make a difference.

Which header do we include for _blsr_u64 when using GCC on Solaris 11.3?


Here are the relevant defines from 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

And CPU features:

$ 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 

And GCC version:

$ /bin/g++ --version
g++ (GCC) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.

解决方案

Which header do we include for _blsr_u64 when using GCC on Solaris 11.3?

It looks like #include <x86intrin.h> is correct.

The problem was the compiler invocation required both -march=native -m64 even though 64-bit is native for the machine and the kernel is 64-bit:

$ /bin/g++ -march=native -m64 test.cxx -o test.exe

这篇关于_blsr_u64的标题与Sun在Solaris 11上提供了GCC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆