Skip to content

Commit

Permalink
Refix openmp on mac
Browse files Browse the repository at this point in the history
  • Loading branch information
HGuillemet committed Jun 24, 2024
1 parent 5b9e86c commit 286b915
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
15 changes: 10 additions & 5 deletions .github/actions/deploy-macosx/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@ runs:
sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/MacOSX10*
fi
brew uninstall --force --ignore-dependencies gcc gcc@7 gcc@8 gcc@9 gcc@10 gcc@11 gcc@12 gcc@13 little-cms2 maven openblas r
brew install boost ccache swig autoconf-archive automake cmake libomp libtool libusb ant nasm xz pkg-config sdl2 gpg1 bison flex perl ragel binutils gradle gmp isl libmpc mpfr geoip pcre ssdeep yajl
brew link --force libomp
brew uninstall --force --ignore-dependencies gcc gcc@7 gcc@8 gcc@9 gcc@10 gcc@11 gcc@12 gcc@13 little-cms2 maven openblas r # imagemagick libraw
brew install boost ccache swig autoconf-archive automake cmake libtool libusb ant nasm xz pkg-config sdl2 gpg1 bison flex perl ragel binutils gradle gmp isl libmpc mpfr geoip pcre ssdeep yajl
# Install version of libomp for llvm 15
# brew uninstall -f libomp
#curl -LO https://mac.r-project.org/openmp/openmp-15.0.7-darwin20-Release.tar.gz
#tar fvxz openmp-15.0.7-darwin20-Release.tar.gz -C /
# echo Installing an older less buggy version of CMake
# curl -LO https://raw.githubusercontent.com/Homebrew/homebrew-core/30a3e5e02420a515f9bad02e3cfcde95316db529/Formula/cmake.rb
# brew unlink cmake
Expand Down Expand Up @@ -55,7 +59,7 @@ runs:
otool -L /usr/local/lib/gcc/10/*.dylib
fi
sudo install_name_tool -add_rpath @loader_path/. -id @rpath/libomp.dylib /usr/local/opt/libomp/lib/libomp.dylib
#sudo install_name_tool -add_rpath @loader_path/. -id @rpath/libomp.dylib /usr/local/opt/libomp/lib/libomp.dylib
sudo install_name_tool -add_rpath @loader_path/. -id @rpath/libSDL2-2.0.0.dylib /usr/local/opt/sdl2/lib/libSDL2-2.0.0.dylib
sudo install_name_tool -add_rpath @loader_path/. -id @rpath/libusb-1.0.0.dylib /usr/local/opt/libusb/lib/libusb-1.0.0.dylib
Expand Down Expand Up @@ -111,6 +115,7 @@ runs:
git --version
clang --version
/usr/local/bin/gcc-* --version || true
which cmake
cmake --version
gradle --version
mvn -version
Expand Down
17 changes: 16 additions & 1 deletion pytorch/cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ case $PLATFORM in
macosx-arm64)
export CC="clang"
export CXX="clang++"
export PATH=$(brew --prefix llvm@15)/bin:$PATH # Use brew LLVM 15 instead of Xcode LLVM 14
export CMAKE_OSX_ARCHITECTURES=arm64 # enable cross-compilation on a x86_64 host machine
export USE_MKLDNN=OFF
export USE_QNNPACK=OFF # not compatible with arm64 as of PyTorch 2.1.2
Expand All @@ -151,6 +152,7 @@ case $PLATFORM in
macosx-x86_64)
export CC="clang"
export CXX="clang++"
export PATH=$(brew --prefix llvm@15)/bin:$PATH # Use brew LLVM 15 instead of Xcode LLVM 14
;;
windows-x86_64)
if which ccache.exe; then
Expand Down Expand Up @@ -211,9 +213,22 @@ sedinplace 's/const std::string& interface)/const std::string\& interface_name)/
# and see if choosing experimental works. See Issue #1503.
# On Linux, pytorch FindOpenMP.cmake picks llvm libomp over libgomp. See Issue #1504.
# Keep it on MacOS since it appends the correct -Xpreprocessor -fopenmp -I/usr/local/include flags
if [[ ! $PLATFORM == macosx-* ]]; then
#if [[ ! $PLATFORM == macosx-* ]]; then
rm cmake/Modules/FindOpenMP.cmake
sedinplace 's/include(${CMAKE_CURRENT_LIST_DIR}\/Modules\/FindOpenMP.cmake)/find_package(OpenMP)/g' cmake/Dependencies.cmake
if [[ $PLATFORM == macosx-* ]]; then
# export CXXFLAGS=-I/usr/local/include
brew ls libomp
export CMAKE_INCLUDE_PATH=`brew ls libomp|grep include`
export CMAKE_LIBRARY_PATH=${CMAKE_INCLUDE_PATH%%include/}lib
echo Setting CMAKE_INCLUDE_PATH=$CMAKE_INCLUDE_PATH
echo Setting CMAKE_LIBRARY_PATH=$CMAKE_LIBRARY_PATH
#export LD_LIBRARY_PATH=/usr/local/lib
#export DYLD_LIBRARY_PATH=/usr/local/lib
#export OpenMP_C_INCLUDE_DIR=/usr/local/include
#export OpenMP_CXX_INCLUDE_DIR=/usr/local/include
#curl -O https://mac.r-project.org/openmp/openmp-14.0.6-darwin20-Release.tar.gz
#tar fvxz openmp-14.0.6-darwin20-Release.tar.gz -C /
fi

#USE_FBGEMM=0 USE_KINETO=0 USE_GLOO=0 USE_MKLDNN=0 \
Expand Down

0 comments on commit 286b915

Please sign in to comment.