This is an automated email from the ASF dual-hosted git repository.

zhasheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
     new f7fa49e  Compile MKLDNN in Mac. (#10115)
f7fa49e is described below

commit f7fa49e3068ab30a7379bbce1b288bf285fe5cde
Author: Da Zheng <zhengda1...@gmail.com>
AuthorDate: Wed Mar 14 19:20:47 2018 -0700

    Compile MKLDNN in Mac. (#10115)
    
    * Compile MKLDNN in Mac.
    
    * A more general way of finding #cores.
    
    * find the right dyn library of mkldnn.
---
 3rdparty/mkldnn   |  2 +-
 Makefile          |  7 +++++++
 prepare_mkldnn.sh | 19 +++++++++++++++++--
 3 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/3rdparty/mkldnn b/3rdparty/mkldnn
index 464c268..f5218ff 160000
--- a/3rdparty/mkldnn
+++ b/3rdparty/mkldnn
@@ -1 +1 @@
-Subproject commit 464c268e544bae26f9b85a2acb9122c766a4c396
+Subproject commit f5218ff4fd2d16d13aada2e632afd18f2514fee3
diff --git a/Makefile b/Makefile
index 50b125b..862a40c 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 3cfd2dd..50552eb 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

-- 
To stop receiving notification emails like this one, please contact
zhash...@apache.org.

Reply via email to