Skip to content

Commit 82b4f31

Browse files
authored
[MRG] Detecting openmp flags on macOS (with libomp from brew) (#789)
* Detecting openmp flags on macOS (with libomp from brew) * Detecting openmp flags on macOS (with libomp from brew) --lint * Release.md update
1 parent 26f1380 commit 82b4f31

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

RELEASES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ This new release adds support for sparse cost matrices and a new lazy EMD solver
1717
- Fix deprecated JAX function in `ot.backend.JaxBackend` (PR #771, Issue #770)
1818
- Add test for build from source (PR #772, Issue #764)
1919
- Fix device for batch Ot solver in `ot.batch` (PR #784, Issue #783)
20+
- Fix openmp flags on macOS (PR #789)
2021

2122
## 0.9.6.post1
2223

ot/helpers/openmp_helpers.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,18 @@ def get_openmp_flag(compiler):
3333
# Default flag for GCC and clang:
3434
omp_flag = ["-fopenmp"]
3535
if sys.platform.startswith("darwin"):
36-
omp_flag += ["-Xpreprocessor", "-lomp"]
36+
omp_flag = ["-Xpreprocessor", "-fopenmp"]
37+
omp_flag += ["-I/usr/local/opt/libomp/include"]
38+
# Assuming `brew install libomp` on recent macOS
39+
if os.path.isfile("/opt/homebrew/opt/libomp/lib/libomp.dylib"):
40+
omp_flag += ["-I/opt/homebrew/opt/libomp/include"]
41+
omp_flag += ["/opt/homebrew/opt/libomp/lib/libomp.dylib"]
42+
else:
43+
# Assuming `brew install libomp` on old macOS
44+
if os.path.isfile("/usr/local/opt/libomp/lib/libomp.dylib"):
45+
omp_flag += ["-I/usr/local/opt/libomp/include"]
46+
omp_flag += ["/usr/local/opt/libomp/lib/libomp.dylib"]
47+
3748
return omp_flag
3849

3950

0 commit comments

Comments
 (0)