2
여러 플랫폼에서 실행되는 코드가 있습니다. 코어 i7 5 세대와 같이 사용 가능한 코드는 BMI/BMI2 내장 함수를 사용합니다. 솔라리스 11.3에 Sun에서 제공하는 GCC는 __BMI__
및 __BMI2__
를 정의하지만, BMI/BMI2의 내장 함수의 위치는 데 문제가 :Solaris에서 _blsr_u64 용 헤더가 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 대 -m64에 영향을주지 않습니다. 최적화 옵션으로 인해 32 비트 빌드가 손상 될 수 있다면 (예 : 32 비트였던 다른 오브젝트 파일과 연결되지 않는 64 비트 .o를 만들어서) 타겟 ISA 내에서 명령 세트 확장을 사용 가능하게 설정하면 '-mtune') –