Skip to content

Commit

Permalink
Enable OpenMP for DNNL and ONNX Runtime on Mac
Browse files Browse the repository at this point in the history
  • Loading branch information
saudet committed May 27, 2020
1 parent 0c0403e commit a65e4f6
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 35 deletions.
7 changes: 4 additions & 3 deletions ci/install-travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ if [ "$TRAVIS_OS_NAME" == "osx" ]; then
sudo install_name_tool -change /usr/local/lib/gcc/7/libgcc_s.1.dylib @rpath/libgcc_s.1.dylib /usr/local/lib/gcc/7/libquadmath.0.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/libSDL-1.2.0.dylib /usr/local/lib/libSDL-1.2.0.dylib
sudo install_name_tool -add_rpath @loader_path/. -id @rpath/libusb-1.0.0.dylib /usr/local/lib/libusb-1.0.0.dylib

Expand Down Expand Up @@ -378,19 +379,19 @@ else
bash cppbuild.sh install $PROJ -platform=$OS -extension=$EXT; export BUILD_STATUS=0
elif [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
echo "Not a pull request so attempting to deploy"
mvn clean deploy -B -U -Dmaven.repo.local=$HOME/.m2/repository -Dmaven.repo.local=$HOME/.m2/repository --settings $TRAVIS_BUILD_DIR/ci/settings.xml -Dmaven.test.skip=true $MAVEN_RELEASE -Djavacpp.platform=$OS -Djavacpp.platform.extension=$EXT $BUILD_COMPILER $BUILD_OPTIONS $BUILD_ROOT -pl .,$PROJ; export BUILD_STATUS=$?
mvn clean deploy -B -U -Dmaven.repo.local=$HOME/.m2/repository --settings $TRAVIS_BUILD_DIR/ci/settings.xml -Dmaven.test.skip=true $MAVEN_RELEASE -Djavacpp.platform=$OS -Djavacpp.platform.extension=$EXT $BUILD_COMPILER $BUILD_OPTIONS $BUILD_ROOT -pl .,$PROJ; export BUILD_STATUS=$?
if [ $BUILD_STATUS -eq 0 ]; then
echo "Deploying platform step"
for i in ${PROJ//,/ }
do
cd $i
mvn clean deploy -B -U -Dmaven.repo.local=$HOME/.m2/repository -Dmaven.repo.local=$HOME/.m2/repository --settings $TRAVIS_BUILD_DIR/ci/settings.xml -f platform/${EXT:1}/pom.xml -Dmaven.test.skip=true $MAVEN_RELEASE -Djavacpp.platform=$OS -Djavacpp.platform.extension=$EXT; export BUILD_STATUS=$?
mvn clean deploy -B -U -Dmaven.repo.local=$HOME/.m2/repository --settings $TRAVIS_BUILD_DIR/ci/settings.xml -f platform/${EXT:1}/pom.xml -Dmaven.test.skip=true $MAVEN_RELEASE -Djavacpp.platform=$OS -Djavacpp.platform.extension=$EXT; export BUILD_STATUS=$?
cd ..
done
fi
else
echo "Pull request so install only"
mvn clean install -B -U -Dmaven.repo.local=$HOME/.m2/repository -Dmaven.repo.local=$HOME/.m2/repository --settings $TRAVIS_BUILD_DIR/ci/settings.xml -Dmaven.test.skip=true $MAVEN_RELEASE -Djavacpp.platform=$OS -Djavacpp.platform.extension=$EXT $BUILD_COMPILER $BUILD_OPTIONS $BUILD_ROOT -pl .,$PROJ; export BUILD_STATUS=$?
mvn clean install -B -U -Dmaven.repo.local=$HOME/.m2/repository --settings $TRAVIS_BUILD_DIR/ci/settings.xml -Dmaven.test.skip=true $MAVEN_RELEASE -Djavacpp.platform=$OS -Djavacpp.platform.extension=$EXT $BUILD_COMPILER $BUILD_OPTIONS $BUILD_ROOT -pl .,$PROJ; export BUILD_STATUS=$?
fi

echo "Build status $BUILD_STATUS"
Expand Down
2 changes: 1 addition & 1 deletion dnnl/cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ case $PLATFORM in
;;
macosx-x86_64)
sedinplace 's/__thread/thread_local/g' src/common/utils.hpp
"$CMAKE" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_INSTALL_LIBDIR="lib" -DARCH_OPT_FLAGS='' -DMKLDNN_BUILD_EXAMPLES=OFF -DMKLDNN_BUILD_TESTS=OFF .
"$CMAKE" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$INSTALL_PATH -DCMAKE_INSTALL_LIBDIR="lib" -DCMAKE_C_FLAGS="-I/usr/local/include -L/usr/local/lib -lomp" -DCMAKE_CXX_FLAGS="-I/usr/local/include -L/usr/local/lib -lomp" -DARCH_OPT_FLAGS='' -DMKLDNN_BUILD_EXAMPLES=OFF -DMKLDNN_BUILD_TESTS=OFF .
make -j $MAKEJ
make install/strip
;;
Expand Down
17 changes: 0 additions & 17 deletions dnnl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,6 @@
<plugin>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp</artifactId>
<executions>
<execution>
<id>javacpp-postbuild</id>
<phase>process-classes</phase>
<goals>
<goal>build</goal>
</goals>
<configuration>
<skip>${javacpp.compiler.skip}</skip>
<buildCommand>
<program>bash</program>
<argument>${project.basedir}/postbuild.sh</argument>
</buildCommand>
<workingDirectory>${project.basedir}</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
Expand Down
11 changes: 0 additions & 11 deletions dnnl/postbuild.sh

This file was deleted.

2 changes: 1 addition & 1 deletion dnnl/src/main/java/org/bytedeco/dnnl/presets/dnnl.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
compiler = "cpp11",
define = {"GENERIC_EXCEPTION_CLASS dnnl::error", "GENERIC_EXCEPTION_TOSTRING toStdString().c_str()"},
include = {"dnnl_types.h", "dnnl_config.h", /*"dnnl_debug.h",*/ "dnnl_version.h", "dnnl.h", "dnnl.hpp"},
link = "dnnl@.1", preload = {"gomp@.1", "iomp5"}, resource = {"include", "lib"}
link = "dnnl@.1", preload = {"gomp@.1", "iomp5", "omp"}, preloadpath = "/usr/local/lib", resource = {"include", "lib"}
),
},
target = "org.bytedeco.dnnl",
Expand Down
2 changes: 1 addition & 1 deletion onnxruntime/onnxruntime.patch
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ index 9a79115ed..7ddaeec32 100644
if(UNIX)
if (APPLE)
- set(ONNXRUNTIME_SO_LINK_FLAG " -Xlinker -dead_strip")
+ set(ONNXRUNTIME_SO_LINK_FLAG "")
+ set(ONNXRUNTIME_SO_LINK_FLAG "-L/usr/local/lib -lomp")
else()
- set(ONNXRUNTIME_SO_LINK_FLAG " -Xlinker --version-script=${SYMBOL_FILE} -Xlinker --no-undefined -Xlinker --gc-sections -z noexecstack")
+ set(ONNXRUNTIME_SO_LINK_FLAG "-Xlinker --no-undefined -Xlinker -z -Xlinker noexecstack")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"onnxruntime/core/providers/cuda/cuda_provider_factory.h",
"onnxruntime/core/providers/dnnl/dnnl_provider_factory.h"
},
link = "onnxruntime@.1.3.0"
link = "onnxruntime@.1.3.0",
preload = {"onnxruntime_providers_dnnl", "onnxruntime_providers_cuda"}
),
@Platform(
value = {"linux", "macosx", "windows"},
Expand Down

0 comments on commit a65e4f6

Please sign in to comment.