Skip to content

Commit f809cf0

Browse files
algoriddlefacebook-github-bot
authored andcommitted
fix osx openmp (facebookresearch#2857)
Summary: Pull Request resolved: facebookresearch#2857 Reviewed By: alexanderguzhva Differential Revision: D45791625 Pulled By: algoriddle fbshipit-source-id: 52ec30f0ec66812f60a08843947aabe8be876afa
1 parent eea4a48 commit f809cf0

File tree

4 files changed

+80
-18
lines changed

4 files changed

+80
-18
lines changed

conda/faiss-gpu/meta.yaml

+16-10
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ source:
2626

2727
outputs:
2828
- name: libfaiss
29-
script: build-lib.sh
29+
script: build-lib.sh # [x86_64 and not win]
30+
script: build-lib-arm64.sh # [not x86_64]
31+
script: build-lib.bat # [win]
3032
build:
3133
string: "h{{ PKG_HASH }}_{{ number }}_cuda{{ cudatoolkit }}{{ suffix }}"
3234
run_exports:
@@ -36,28 +38,32 @@ outputs:
3638
requirements:
3739
build:
3840
- {{ compiler('cxx') }}
39-
- sysroot_linux-64 =2.17 # [linux64]
41+
- sysroot_linux-64 =2.17 # [linux64]
4042
- llvm-openmp # [osx]
4143
- cmake =3.23.1
4244
- make # [not win]
43-
- mkl-devel =2023
45+
- mkl-devel =2023 # [x86_64]
4446
host:
45-
- mkl =2023
47+
- mkl =2023 # [x86_64]
48+
- openblas # [not x86_64]
4649
- cudatoolkit {{ cudatoolkit }}
4750
run:
48-
- mkl =2023
51+
- mkl =2023 # [x86_64]
52+
- openblas # [not x86_64]
4953
- {{ pin_compatible('cudatoolkit', max_pin='x.x') }}
5054
test:
5155
requires:
5256
- conda-build
5357
commands:
54-
- test -f $PREFIX/lib/libfaiss.so # [linux]
55-
- test -f $PREFIX/lib/libfaiss.dylib # [osx]
58+
- test -f $PREFIX/lib/libfaiss$SHLIB_EXT # [not win]
59+
- test -f $PREFIX/lib/libfaiss_avx2$SHLIB_EXT # [x86_64 and not win]
5660
- conda inspect linkages -p $PREFIX $PKG_NAME # [not win]
5761
- conda inspect objects -p $PREFIX $PKG_NAME # [osx]
5862

5963
- name: faiss-gpu
60-
script: build-pkg.sh
64+
script: build-pkg.sh # [x86_64 and not win]
65+
script: build-pkg-arm64.sh # [not x86_64]
66+
script: build-pkg.bat # [win]
6167
build:
6268
string: "py{{ PY_VER }}_h{{ PKG_HASH }}_{{ number }}_cuda{{ cudatoolkit }}{{ suffix }}"
6369
requirements:
@@ -86,9 +92,9 @@ outputs:
8692
- cp tests/common_faiss_tests.py faiss/gpu/test
8793
- python -X faulthandler -m unittest discover -v -s faiss/gpu/test/ -p "test_*"
8894
- python -X faulthandler -m unittest discover -v -s faiss/gpu/test/ -p "torch_*"
89-
- sh test_cpu_dispatch.sh # [linux]
95+
- sh test_cpu_dispatch.sh # [linux64]
9096
files:
91-
- test_cpu_dispatch.sh # [linux]
97+
- test_cpu_dispatch.sh # [linux64]
9298
source_files:
9399
- tests/
94100
- faiss/gpu/test/

conda/faiss/build-lib-osx.sh

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
# Copyright (c) Facebook, Inc. and its affiliates.
3+
#
4+
# This source code is licensed under the MIT license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
set -e
8+
9+
10+
# Build libfaiss.so/libfaiss_avx2.so.
11+
cmake -B _build \
12+
-DBUILD_SHARED_LIBS=ON \
13+
-DBUILD_TESTING=OFF \
14+
-DFAISS_OPT_LEVEL=avx2 \
15+
-DFAISS_ENABLE_GPU=OFF \
16+
-DFAISS_ENABLE_PYTHON=OFF \
17+
-DBLA_VENDOR=Intel10_64lp \
18+
-DOpenMP_CXX_FLAGS=-fopenmp=libiomp5 \
19+
-DOpenMP_CXX_LIB_NAMES=libiomp5 \
20+
-DOpenMP_libiomp5_LIBRARY=$PREFIX/lib/libiomp5.dylib \
21+
-DCMAKE_INSTALL_LIBDIR=lib \
22+
-DCMAKE_BUILD_TYPE=Release .
23+
24+
make -C _build -j$(nproc) faiss faiss_avx2
25+
26+
cmake --install _build --prefix $PREFIX
27+
cmake --install _build --prefix _libfaiss_stage/

conda/faiss/build-pkg-osx.sh

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/sh
2+
# Copyright (c) Facebook, Inc. and its affiliates.
3+
#
4+
# This source code is licensed under the MIT license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
set -e
8+
9+
10+
# Build swigfaiss.so/swigfaiss_avx2.so.
11+
cmake -B _build_python_${PY_VER} \
12+
-Dfaiss_ROOT=_libfaiss_stage/ \
13+
-DFAISS_OPT_LEVEL=avx2 \
14+
-DFAISS_ENABLE_GPU=OFF \
15+
-DOpenMP_CXX_FLAGS=-fopenmp=libiomp5 \
16+
-DOpenMP_CXX_LIB_NAMES=libiomp5 \
17+
-DOpenMP_libiomp5_LIBRARY=$PREFIX/lib/libiomp5.dylib \
18+
-DCMAKE_BUILD_TYPE=Release \
19+
-DPython_EXECUTABLE=$PYTHON \
20+
faiss/python
21+
22+
make -C _build_python_${PY_VER} -j$(nproc) swigfaiss swigfaiss_avx2
23+
24+
# Build actual python module.
25+
cd _build_python_${PY_VER}/
26+
$PYTHON setup.py install --single-version-externally-managed --record=record.txt --prefix=$PREFIX

conda/faiss/meta.yaml

+11-8
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ source:
2626

2727
outputs:
2828
- name: libfaiss
29-
script: build-lib.sh # [x86_64 and not win]
30-
script: build-lib-arm64.sh # [not x86_64]
29+
script: build-lib.sh # [x86_64 and not win and not osx]
30+
script: build-lib-osx.sh # [x86_64 and osx]
31+
script: build-lib-arm64.sh # [not x86_64]
3132
script: build-lib.bat # [win]
3233
build:
3334
string: "h{{ PKG_HASH }}_{{ number }}_cpu{{ suffix }}"
@@ -36,16 +37,17 @@ outputs:
3637
requirements:
3738
build:
3839
- {{ compiler('cxx') }}
39-
- sysroot_linux-64 =2.17 # [linux64]
40+
- sysroot_linux-64 =2.17 # [linux64]
41+
- llvm-openmp # [osx]
4042
- cmake =3.23.1
4143
- make # [not win]
42-
- mkl-devel =2023 # [x86_64]
44+
- mkl-devel =2023 # [x86_64]
4345
host:
44-
- mkl =2023 # [x86_64]
45-
- openblas # [not x86_64]
46+
- mkl =2023 # [x86_64]
47+
- openblas # [not x86_64]
4648
run:
4749
- mkl =2023 # [x86_64]
48-
- openblas # [not x86_64]
50+
- openblas # [not x86_64]
4951
test:
5052
requires:
5153
- conda-build
@@ -56,7 +58,8 @@ outputs:
5658
- conda inspect objects -p $PREFIX $PKG_NAME # [osx]
5759

5860
- name: faiss-cpu
59-
script: build-pkg.sh # [x86_64 and not win]
61+
script: build-pkg.sh # [x86_64 and not win and not osx]
62+
script: build-pkg-osx.sh # [x86_64 and osx]
6063
script: build-pkg-arm64.sh # [not x86_64]
6164
script: build-pkg.bat # [win]
6265
build:

0 commit comments

Comments
 (0)