2
複数のプラットフォームで動作するコードがあります。このコードでは、core i7 5th genのように、使用可能な場合に組み込み関数BMI/BMI2が使用されています。 Solarisの11.3に日によって提供されるGCCは__BMI__
と__BMI2__
を定義しているが、BMI/BMI2組み込み関数を見つけるその苦労:_blsr_u64のヘッダーは、SunがSolaris 11でGCCを提供していますか?
$ 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.
*カーネルは64ビットです。* [Solarisのネイティブモードは32ビットです](https://docs.oracle.com/cd/E60778_01/html/E60745/bjapr.html#OSSCGgif)。 –
'-march = native'は、-m32と-m64の間には影響しません。これは、最適化オプションが32ビットビルドを壊す可能性がある場合(例えば、32ビットの他のオブジェクトファイルとリンクしない64ビットの.oを作成するなど)、ターゲットISA内で命令セット拡張を有効にします'-mtune') –