Wrap BMI2 instruction usage in support checks.
A previous version of this was submitted and rolled back due to breakage -- an attempt to accommodate Visual Studio resulted in compiler errors on GCC/Clang with -mavx2 but without -mbmi2. This version makes the BMI2 support check more strict, to avoid the errors. A previous CL introduced _bzhi_u32 (part of Intel's BMI2 instruction set, released in Haswell) gated by a check for the __BMI2__ preprocessor macro. This works for Clang and GCC, but does not work on Visual Studio, and may not work on other compilers. This CL plumbs the BMI2 support checks through the CMake configuration used by the open source build. It also replaces the <x86intrin.h> header, which does not exist on Visual Studio, with the more scoped headers <tmmintrin.h> (for SSSE3) and <immintrin.h> (for BMI2/AVX2). Asides from fixing the open source build, the more scoped headers make it slightly less likely that newer intrinsics will creep in without proper gating.
This commit is contained in:
15
.travis.yml
15
.travis.yml
@@ -13,8 +13,10 @@ os:
|
||||
- osx
|
||||
|
||||
env:
|
||||
- BUILD_TYPE=Debug
|
||||
- BUILD_TYPE=RelWithDebInfo
|
||||
- BUILD_TYPE=Debug CPU_LEVEL=AVX
|
||||
- BUILD_TYPE=Debug CPU_LEVEL=AVX2
|
||||
- BUILD_TYPE=RelWithDebInfo CPU_LEVEL=AVX
|
||||
- BUILD_TYPE=RelWithDebInfo CPU_LEVEL=AVX2
|
||||
|
||||
matrix:
|
||||
exclude:
|
||||
@@ -22,6 +24,12 @@ matrix:
|
||||
# https://github.com/travis-ci/travis-ci/issues/9640
|
||||
- compiler: gcc
|
||||
os: osx
|
||||
# Travis OSX servers seem to run on pre-Haswell CPUs. Attempting to use AVX2
|
||||
# results in crashes.
|
||||
- env: BUILD_TYPE=Debug CPU_LEVEL=AVX2
|
||||
os: osx
|
||||
- env: BUILD_TYPE=RelWithDebInfo CPU_LEVEL=AVX2
|
||||
os: osx
|
||||
|
||||
addons:
|
||||
apt:
|
||||
@@ -61,7 +69,8 @@ install:
|
||||
|
||||
before_script:
|
||||
- mkdir -p build && cd build
|
||||
- cmake .. -G Ninja -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DSNAPPY_REQUIRE_AVX=ON
|
||||
- cmake .. -G Ninja -DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
||||
-DSNAPPY_REQUIRE_${CPU_LEVEL}=ON
|
||||
- cmake --build .
|
||||
- cd ..
|
||||
|
||||
|
||||
Reference in New Issue
Block a user