You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/03/15 02:20:49 UTC
[GitHub] szha closed pull request #10115: Compile MKLDNN in Mac.
szha closed pull request #10115: Compile MKLDNN in Mac.
URL: https://github.com/apache/incubator-mxnet/pull/10115
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/3rdparty/mkldnn b/3rdparty/mkldnn
index 464c268e544..f5218ff4fd2 160000
--- a/3rdparty/mkldnn
+++ b/3rdparty/mkldnn
@@ -1 +1 @@
-Subproject commit 464c268e544bae26f9b85a2acb9122c766a4c396
+Subproject commit f5218ff4fd2d16d13aada2e632afd18f2514fee3
diff --git a/Makefile b/Makefile
index 50b125baaef..862a40c3406 100644
--- a/Makefile
+++ b/Makefile
@@ -429,6 +429,13 @@ lib/libmxnet.so: $(ALLX_DEP)
@mkdir -p $(@D)
$(CXX) $(CFLAGS) -shared -o $@ $(filter-out %libnnvm.a, $(filter %.o %.a, $^)) $(LDFLAGS) \
-Wl,${WHOLE_ARCH} $(filter %libnnvm.a, $^) -Wl,${NO_WHOLE_ARCH}
+ifeq ($(USE_MKLDNN), 1)
+ifeq ($(UNAME_S), Darwin)
+ install_name_tool -change '@rpath/libmklml.dylib' '@loader_path/libmklml.dylib' lib/libmxnet.so
+ install_name_tool -change '@rpath/libiomp5.dylib' '@loader_path/libiomp5.dylib' lib/libmxnet.so
+ install_name_tool -change '@rpath/libmkldnn.0.dylib' '@loader_path/libmkldnn.0.dylib' lib/libmxnet.so
+endif
+endif
$(PS_PATH)/build/libps.a: PSLITE
diff --git a/prepare_mkldnn.sh b/prepare_mkldnn.sh
index 3cfd2dd455b..50552eb22f6 100755
--- a/prepare_mkldnn.sh
+++ b/prepare_mkldnn.sh
@@ -72,8 +72,14 @@ if [ ! -z "$HOME_MKLDNN" ]; then
fi
fi
+if [ $OSTYPE == "darwin16" ]; then
+ MKLDNN_LIBFILE="$MKLDNN_INSTALLDIR/lib/libmkldnn.dylib"
+else
+ MKLDNN_LIBFILE="$MKLDNN_INSTALLDIR/lib/libmkldnn.so"
+fi
+
if [ -z $MKLDNNROOT ]; then
-if [ ! -f "$MKLDNN_INSTALLDIR/lib/libmkldnn.so" ]; then
+if [ ! -f $MKLDNN_LIBFILE ]; then
mkdir -p $MKLDNN_INSTALLDIR
cd $MKLDNN_ROOTDIR
if [ -z $MKLROOT ] && [ ! -f $MKLDNN_INSTALLDIR/include/mkl_cblas.h ]; then
@@ -84,7 +90,16 @@ if [ ! -f "$MKLDNN_INSTALLDIR/lib/libmkldnn.so" ]; then
cd $MXNET_ROOTDIR
g++ --version >&2
cmake $MKLDNN_ROOTDIR -DCMAKE_INSTALL_PREFIX=$MKLDNN_INSTALLDIR -B$MKLDNN_BUILDDIR -DARCH_OPT_FLAGS="-mtune=generic" >&2
- make -C $MKLDNN_BUILDDIR -j$(cat /proc/cpuinfo | grep processor | wc -l) VERBOSE=1 >&2
+ NUM_PROC=1
+ if [[ ! -z $(command -v nproc) ]]; then
+ NUM_PROC=$(nproc)
+ elif [[ ! -z $(command -v sysctl) ]]; then
+ NUM_PROC=$(sysctl -n hw.ncpu)
+ else
+ >&2 echo "Can't discover number of cores."
+ fi
+ make -C $MKLDNN_BUILDDIR -j$(NUM_PROC) VERBOSE=1 >&2
+
make -C $MKLDNN_BUILDDIR install >&2
rm -rf $MKLDNN_BUILDDIR
mkdir -p $MKLDNN_LIBDIR
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services