Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix osx openmp #2857

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions conda/faiss-gpu/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ source:

outputs:
- name: libfaiss
script: build-lib.sh
script: build-lib.sh # [x86_64 and not win]
script: build-lib-arm64.sh # [not x86_64]
script: build-lib.bat # [win]
build:
string: "h{{ PKG_HASH }}_{{ number }}_cuda{{ cudatoolkit }}{{ suffix }}"
run_exports:
Expand All @@ -36,28 +38,32 @@ outputs:
requirements:
build:
- {{ compiler('cxx') }}
- sysroot_linux-64 =2.17 # [linux64]
- sysroot_linux-64 =2.17 # [linux64]
- llvm-openmp # [osx]
- cmake =3.23.1
- make # [not win]
- mkl-devel =2023
- mkl-devel =2023 # [x86_64]
host:
- mkl =2023
- mkl =2023 # [x86_64]
- openblas # [not x86_64]
- cudatoolkit {{ cudatoolkit }}
run:
- mkl =2023
- mkl =2023 # [x86_64]
- openblas # [not x86_64]
- {{ pin_compatible('cudatoolkit', max_pin='x.x') }}
test:
requires:
- conda-build
commands:
- test -f $PREFIX/lib/libfaiss.so # [linux]
- test -f $PREFIX/lib/libfaiss.dylib # [osx]
- test -f $PREFIX/lib/libfaiss$SHLIB_EXT # [not win]
- test -f $PREFIX/lib/libfaiss_avx2$SHLIB_EXT # [x86_64 and not win]
- conda inspect linkages -p $PREFIX $PKG_NAME # [not win]
- conda inspect objects -p $PREFIX $PKG_NAME # [osx]

- name: faiss-gpu
script: build-pkg.sh
script: build-pkg.sh # [x86_64 and not win]
script: build-pkg-arm64.sh # [not x86_64]
script: build-pkg.bat # [win]
build:
string: "py{{ PY_VER }}_h{{ PKG_HASH }}_{{ number }}_cuda{{ cudatoolkit }}{{ suffix }}"
requirements:
Expand Down Expand Up @@ -86,9 +92,9 @@ outputs:
- cp tests/common_faiss_tests.py faiss/gpu/test
- python -X faulthandler -m unittest discover -v -s faiss/gpu/test/ -p "test_*"
- python -X faulthandler -m unittest discover -v -s faiss/gpu/test/ -p "torch_*"
- sh test_cpu_dispatch.sh # [linux]
- sh test_cpu_dispatch.sh # [linux64]
files:
- test_cpu_dispatch.sh # [linux]
- test_cpu_dispatch.sh # [linux64]
source_files:
- tests/
- faiss/gpu/test/
27 changes: 27 additions & 0 deletions conda/faiss/build-lib-osx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

set -e


# Build libfaiss.so/libfaiss_avx2.so.
cmake -B _build \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_TESTING=OFF \
-DFAISS_OPT_LEVEL=avx2 \
-DFAISS_ENABLE_GPU=OFF \
-DFAISS_ENABLE_PYTHON=OFF \
-DBLA_VENDOR=Intel10_64lp \
-DOpenMP_CXX_FLAGS=-fopenmp=libiomp5 \
-DOpenMP_CXX_LIB_NAMES=libiomp5 \
-DOpenMP_libiomp5_LIBRARY=$PREFIX/lib/libiomp5.dylib \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_BUILD_TYPE=Release .

make -C _build -j$(nproc) faiss faiss_avx2

cmake --install _build --prefix $PREFIX
cmake --install _build --prefix _libfaiss_stage/
26 changes: 26 additions & 0 deletions conda/faiss/build-pkg-osx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/sh
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

set -e


# Build swigfaiss.so/swigfaiss_avx2.so.
cmake -B _build_python_${PY_VER} \
-Dfaiss_ROOT=_libfaiss_stage/ \
-DFAISS_OPT_LEVEL=avx2 \
-DFAISS_ENABLE_GPU=OFF \
-DOpenMP_CXX_FLAGS=-fopenmp=libiomp5 \
-DOpenMP_CXX_LIB_NAMES=libiomp5 \
-DOpenMP_libiomp5_LIBRARY=$PREFIX/lib/libiomp5.dylib \
-DCMAKE_BUILD_TYPE=Release \
-DPython_EXECUTABLE=$PYTHON \
faiss/python

make -C _build_python_${PY_VER} -j$(nproc) swigfaiss swigfaiss_avx2

# Build actual python module.
cd _build_python_${PY_VER}/
$PYTHON setup.py install --single-version-externally-managed --record=record.txt --prefix=$PREFIX
19 changes: 11 additions & 8 deletions conda/faiss/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ source:

outputs:
- name: libfaiss
script: build-lib.sh # [x86_64 and not win]
script: build-lib-arm64.sh # [not x86_64]
script: build-lib.sh # [x86_64 and not win and not osx]
script: build-lib-osx.sh # [x86_64 and osx]
script: build-lib-arm64.sh # [not x86_64]
script: build-lib.bat # [win]
build:
string: "h{{ PKG_HASH }}_{{ number }}_cpu{{ suffix }}"
Expand All @@ -36,16 +37,17 @@ outputs:
requirements:
build:
- {{ compiler('cxx') }}
- sysroot_linux-64 =2.17 # [linux64]
- sysroot_linux-64 =2.17 # [linux64]
- llvm-openmp # [osx]
- cmake =3.23.1
- make # [not win]
- mkl-devel =2023 # [x86_64]
- mkl-devel =2023 # [x86_64]
host:
- mkl =2023 # [x86_64]
- openblas # [not x86_64]
- mkl =2023 # [x86_64]
- openblas # [not x86_64]
run:
- mkl =2023 # [x86_64]
- openblas # [not x86_64]
- openblas # [not x86_64]
test:
requires:
- conda-build
Expand All @@ -56,7 +58,8 @@ outputs:
- conda inspect objects -p $PREFIX $PKG_NAME # [osx]

- name: faiss-cpu
script: build-pkg.sh # [x86_64 and not win]
script: build-pkg.sh # [x86_64 and not win and not osx]
script: build-pkg-osx.sh # [x86_64 and osx]
script: build-pkg-arm64.sh # [not x86_64]
script: build-pkg.bat # [win]
build:
Expand Down