Skip to content

Commit

Permalink
Build with AVX2 support
Browse files Browse the repository at this point in the history
automerged PR by conda-forge/automerge-action
  • Loading branch information
github-actions[bot] authored Feb 19, 2021
2 parents c56a351 + 7cbbe44 commit df8cd2e
Show file tree
Hide file tree
Showing 30 changed files with 1,052 additions and 216 deletions.
14 changes: 1 addition & 13 deletions .azure-pipelines/azure-pipelines-win.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 0 additions & 33 deletions .ci_support/win_64_cuda_compiler_version10.2.yaml

This file was deleted.

33 changes: 0 additions & 33 deletions .ci_support/win_64_cuda_compiler_version11.0.yaml

This file was deleted.

33 changes: 0 additions & 33 deletions .ci_support/win_64_cuda_compiler_version11.1.yaml

This file was deleted.

33 changes: 0 additions & 33 deletions .ci_support/win_64_cuda_compiler_version11.2.yaml

This file was deleted.

4 changes: 1 addition & 3 deletions .ci_support/win_64_cuda_compiler_versionNone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ channel_sources:
- conda-forge,defaults
channel_targets:
- conda-forge main
cuda_compiler:
- nvcc
cuda_compiler_version:
- None
cxx_compiler:
- vs2017
- vs2019
libblas:
- 3.8 *netlib
liblapack:
Expand Down
28 changes: 0 additions & 28 deletions README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions conda-forge.yml
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
azure:
settings_win:
pool:
vmImage: windows-2019
conda_forge_output_validation: true
6 changes: 6 additions & 0 deletions recipe/build-lib-avx2.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@echo on

:: same build script, only difference through CF_FAISS_BUILD
copy "%RECIPE_DIR%\build-lib.bat" .
set CF_FAISS_BUILD=avx2
call build-lib.bat
4 changes: 4 additions & 0 deletions recipe/build-lib-avx2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# same build script, only difference through CF_FAISS_BUILD
cp ${RECIPE_DIR}/build-lib.sh .
export CF_FAISS_BUILD="avx2"
bash build-lib.sh
6 changes: 6 additions & 0 deletions recipe/build-lib-generic.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@echo on

:: same build script, only difference through CF_FAISS_BUILD
copy "%RECIPE_DIR%\build-lib.bat" .
set CF_FAISS_BUILD=generic
call build-lib.bat
4 changes: 4 additions & 0 deletions recipe/build-lib-generic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# same build script, only difference through CF_FAISS_BUILD
cp ${RECIPE_DIR}/build-lib.sh .
export CF_FAISS_BUILD="generic"
bash build-lib.sh
15 changes: 11 additions & 4 deletions recipe/build-lib.bat
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,14 @@ if "%cuda_compiler_version%"=="None" (
echo Set up extra cmake-args: CUDA_CONFIG_ARGS=!CUDA_CONFIG_ARGS!
)

:: Build faiss.dll
cmake -B _build ^
:: workaround for https://github.com/conda-forge/vc-feedstock/issues/21
set "CMAKE_GENERATOR=Visual Studio 16 2019"

:: Build faiss.dll depending on $CF_FAISS_BUILD (either "generic" or "avx2")
cmake -B _build_%CF_FAISS_BUILD% ^
-DBUILD_SHARED_LIBS=ON ^
-DBUILD_TESTING=OFF ^
-DFAISS_OPT_LEVEL=%CF_FAISS_BUILD% ^
-DFAISS_ENABLE_PYTHON=OFF ^
-DFAISS_ENABLE_GPU=!FAISS_ENABLE_GPU! ^
-DCMAKE_BUILD_TYPE=Release ^
Expand All @@ -60,8 +64,11 @@ cmake -B _build ^
.
if %ERRORLEVEL% neq 0 exit 1

cmake --build _build --config Release -j %CPU_COUNT%
cmake --build _build_%CF_FAISS_BUILD% --config Release -j %CPU_COUNT%
if %ERRORLEVEL% neq 0 exit 1

cmake --install _build --config Release --prefix %PREFIX%
cmake --install _build_%CF_FAISS_BUILD% --config Release --prefix %PREFIX%
if %ERRORLEVEL% neq 0 exit 1
:: will be reused in build-pkg.bat
cmake --install _build_%CF_FAISS_BUILD% --config Release --prefix _libfaiss_%CF_FAISS_BUILD%_stage
if %ERRORLEVEL% neq 0 exit 1
20 changes: 15 additions & 5 deletions recipe/build-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,18 @@ else
FAISS_ENABLE_GPU="OFF"
fi

# Build vanilla version (no avx)
cmake -B _build_generic \
if [[ $target_platform == osx-* ]] && [[ $CF_FAISS_BUILD == avx2 ]]; then
# OSX CI has no AVX2 support
BUILD_TESTING="OFF"
else
BUILD_TESTING="ON"
fi

# Build version depending on $CF_FAISS_BUILD (either "generic" or "avx2")
cmake -B _build_${CF_FAISS_BUILD} \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_TESTING=ON \
-DBUILD_TESTING=${BUILD_TESTING} \
-DFAISS_OPT_LEVEL=${CF_FAISS_BUILD} \
-DFAISS_ENABLE_PYTHON=OFF \
-DFAISS_ENABLE_GPU=${FAISS_ENABLE_GPU} \
-DCMAKE_BUILD_TYPE=Release \
Expand All @@ -70,5 +78,7 @@ cmake -B _build_generic \
--verbose \
.

cmake --build _build_generic -j $CPU_COUNT
cmake --install _build_generic --prefix $PREFIX
cmake --build _build_${CF_FAISS_BUILD} -j $CPU_COUNT
cmake --install _build_${CF_FAISS_BUILD} --prefix $PREFIX
# will be reused in build-pkg.sh
cmake --install _build_${CF_FAISS_BUILD} --prefix _libfaiss_${CF_FAISS_BUILD}_stage/
34 changes: 28 additions & 6 deletions recipe/build-pkg.bat
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,44 @@ if "%cuda_compiler_version%"=="None" (
set "CUDAToolkit_ROOT=%CUDA_PATH%"
)

:: Build vanilla version (no avx2).
:: Do not use the Python3_* variants for cmake
cmake -B _build_python ^
:: workaround for https://github.com/conda-forge/vc-feedstock/issues/21
set "CMAKE_GENERATOR=Visual Studio 16 2019"

:: Build vanilla version (no avx2), see build-lib.bat
cmake -B _build_python_generic ^
-Dfaiss_ROOT=_libfaiss_generic_stage ^
-DFAISS_ENABLE_GPU=!FAISS_ENABLE_GPU! ^
-DCMAKE_BUILD_TYPE=Release ^
-DPython_EXECUTABLE="%PYTHON%" ^
faiss/python
if %ERRORLEVEL% neq 0 exit 1

cmake --build _build_python --config Release -j %CPU_COUNT%
cmake --build _build_python_generic --config Release -j %CPU_COUNT%
if %ERRORLEVEL% neq 0 exit 1

:: Build version with avx2 support, see build-lib.bat
cmake -B _build_python_avx2 ^
-Dfaiss_ROOT=_libfaiss_avx2_stage ^
-DFAISS_ENABLE_GPU=OFF ^
-DCMAKE_BUILD_TYPE=Release ^
-DPython_EXECUTABLE="%PYTHON%" ^
faiss/python
if %ERRORLEVEL% neq 0 exit 1

cmake --build _build_python_avx2 --config Release -j %CPU_COUNT%
if %ERRORLEVEL% neq 0 exit 1

:: copy generated swig module with avx2-support to specifically named file, cf.
:: https://github.com/facebookresearch/faiss/blob/v1.7.0/faiss/python/setup.py#L25-L26
copy _build_python_avx2\swigfaiss.py _build_python_generic\swigfaiss_avx2.py
copy _build_python_avx2\Release\_swigfaiss.pyd _build_python_generic\Release\_swigfaiss_avx2.pyd
if %ERRORLEVEL% neq 0 exit 1

:: Build actual python module.
pushd _build_python
pushd _build_python_generic
%PYTHON% setup.py install --single-version-externally-managed --record=record.txt --prefix=%PREFIX%
if %ERRORLEVEL% neq 0 exit 1
popd
:: clean up cmake-cache between builds
rd /S /Q _build_python
rd /S /Q _build_python_generic
rd /S /Q _build_python_avx2
25 changes: 19 additions & 6 deletions recipe/build-pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,32 @@ else
fi

# Build vanilla version (no avx2), see build-lib.sh
# Do not use the Python3_* variants for cmake
cmake -B _build_python \
-Dfaiss_ROOT=${PREFIX}\
cmake -B _build_python_generic \
-Dfaiss_ROOT=_libfaiss_generic_stage/ \
-DFAISS_ENABLE_GPU=${FAISS_ENABLE_GPU} \
-DCMAKE_BUILD_TYPE=Release \
-DPython_EXECUTABLE="${PYTHON}" \
faiss/python
cmake --build _build_python_generic -j $CPU_COUNT

cmake --build _build_python -j $CPU_COUNT
# Build version with avx2 support, see build-lib.sh
cmake -B _build_python_avx2 \
-Dfaiss_ROOT=_libfaiss_avx2_stage/ \
-DFAISS_ENABLE_GPU=${FAISS_ENABLE_GPU} \
-DCMAKE_BUILD_TYPE=Release \
-DPython_EXECUTABLE="${PYTHON}" \
faiss/python
cmake --build _build_python_avx2 -j $CPU_COUNT

# copy generated swig module with avx2-support to specifically named file, cf.
# https://github.com/facebookresearch/faiss/blob/v1.7.0/faiss/python/setup.py#L25-L26
cp _build_python_avx2/swigfaiss.py _build_python_generic/swigfaiss_avx2.py
cp _build_python_avx2/_swigfaiss.so _build_python_generic/_swigfaiss_avx2.so

# Build actual python module.
pushd _build_python
pushd _build_python_generic
$PYTHON setup.py install --single-version-externally-managed --record=record.txt --prefix=$PREFIX
popd
# clean up cmake-cache between builds
rm -r _build_python
rm -r _build_python_generic
rm -r _build_python_avx2
5 changes: 5 additions & 0 deletions recipe/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
cxx_compiler_version: # [osx]
# need to downgrade on osx due to a bug that breaks the test suite
- 10 # [osx]

c_compiler: # [win]
- vs2019 # [win]
cxx_compiler: # [win]
- vs2019 # [win]
Loading

0 comments on commit df8cd2e

Please sign in to comment.