Skip to content

Commit

Permalink
Configure CMake with parallel builds
Browse files Browse the repository at this point in the history
  • Loading branch information
jakirkham committed Jan 5, 2023
1 parent 6dc52a9 commit 6e1e350
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion recipe/build-lib.bat
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ cmake %CMAKE_ARGS% ^
-DFAISS_ENABLE_PYTHON=OFF ^
-DFAISS_ENABLE_GPU=!FAISS_ENABLE_GPU! ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_BUILD_PARALLEL_LEVEL="%CPU_COUNT%" ^
-DCMAKE_INSTALL_BINDIR="%LIBRARY_BIN%" ^
-DCMAKE_INSTALL_LIBDIR="%LIBRARY_LIB%" ^
-DCMAKE_INSTALL_INCLUDEDIR="%LIBRARY_INC%" ^
Expand All @@ -58,7 +59,7 @@ if "%CF_FAISS_BUILD%"=="avx2" (
set "TARGET=faiss"
)

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

cmake --install _build_%CF_FAISS_BUILD% --config Release --prefix %PREFIX%
Expand Down
3 changes: 2 additions & 1 deletion recipe/build-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ cmake ${CMAKE_ARGS} \
-DFAISS_ENABLE_PYTHON=OFF \
-DFAISS_ENABLE_GPU=${FAISS_ENABLE_GPU} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_BUILD_PARALLEL_LEVEL="${CPU_COUNT}" \
-DCMAKE_INSTALL_LIBDIR=lib \
${CUDA_CONFIG_ARGS+"${CUDA_CONFIG_ARGS[@]}"} \
-B _build_${CF_FAISS_BUILD} \
Expand All @@ -67,6 +68,6 @@ else
TARGET="faiss"
fi

cmake --build _build_${CF_FAISS_BUILD} --target ${TARGET} -j $CPU_COUNT
cmake --build _build_${CF_FAISS_BUILD} --target ${TARGET}
cmake --install _build_${CF_FAISS_BUILD} --prefix $PREFIX
cmake --install _build_${CF_FAISS_BUILD} --prefix _libfaiss_${CF_FAISS_BUILD}_stage/
6 changes: 4 additions & 2 deletions recipe/build-pkg.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ cmake -B _build_python_generic ^
-Dfaiss_ROOT=_libfaiss_generic_stage ^
-DFAISS_ENABLE_GPU=!FAISS_ENABLE_GPU! ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_BUILD_PARALLEL_LEVEL="%CPU_COUNT%" ^
-DPython_EXECUTABLE="%PYTHON%" ^
faiss/python
if %ERRORLEVEL% neq 0 exit 1

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

:: Build version with avx2 support, see build-lib.bat
Expand All @@ -26,11 +27,12 @@ cmake -B _build_python_avx2 ^
-DFAISS_OPT_LEVEL=avx2 ^
-DFAISS_ENABLE_GPU=!FAISS_ENABLE_GPU! ^
-DCMAKE_BUILD_TYPE=Release ^
-DCMAKE_BUILD_PARALLEL_LEVEL="%CPU_COUNT%" ^
-DPython_EXECUTABLE="%PYTHON%" ^
faiss/python
if %ERRORLEVEL% neq 0 exit 1

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

:: copy generated swig module with avx2-support to specifically named file, cf.
Expand Down
6 changes: 4 additions & 2 deletions recipe/build-pkg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@ cmake ${CMAKE_ARGS} \
-Dfaiss_ROOT=_libfaiss_generic_stage/ \
-DFAISS_ENABLE_GPU=${FAISS_ENABLE_GPU} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_BUILD_PARALLEL_LEVEL="${CPU_COUNT}" \
-DPython_EXECUTABLE="${PYTHON}" \
-B _build_python_generic \
faiss/python
cmake --build _build_python_generic --target swigfaiss -j $CPU_COUNT
cmake --build _build_python_generic --target swigfaiss

# Build version with avx2 support, see build-lib.sh
if [[ "${target_platform}" == *-64 ]]; then
Expand All @@ -25,10 +26,11 @@ if [[ "${target_platform}" == *-64 ]]; then
-DFAISS_OPT_LEVEL=avx2 \
-DFAISS_ENABLE_GPU=${FAISS_ENABLE_GPU} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_BUILD_PARALLEL_LEVEL="${CPU_COUNT}" \
-DPython_EXECUTABLE="${PYTHON}" \
-B _build_python_avx2 \
faiss/python
cmake --build _build_python_avx2 --target swigfaiss_avx2 -j $CPU_COUNT
cmake --build _build_python_avx2 --target swigfaiss_avx2

# copy generated swig module with avx2-support to specifically named file, cf.
# https://github.com/facebookresearch/faiss/blob/v1.7.1/faiss/python/setup.py#L37-L40
Expand Down

0 comments on commit 6e1e350

Please sign in to comment.