You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by mu...@apache.org on 2017/08/30 00:14:04 UTC

[incubator-mxnet] branch master updated: update mklml and mkl mac support (#7587)

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

muli 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 546b917  update mklml and mkl mac support (#7587)
546b917 is described below

commit 546b917e3fd2d1d387fcb130f63ada0b46231ce5
Author: Sheng Zha <sz...@users.noreply.github.com>
AuthorDate: Tue Aug 29 17:14:01 2017 -0700

    update mklml and mkl mac support (#7587)
---
 Makefile                            | 46 +++++++++++++++++++++++--------------
 dmlc-core                           |  2 +-
 mshadow                             |  2 +-
 prepare_mkl.sh                      | 26 ++++++++++++++++-----
 tests/ci_build/Dockerfile.mklml_gpu |  2 +-
 5 files changed, 52 insertions(+), 26 deletions(-)

diff --git a/Makefile b/Makefile
index 300f901..b42621e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,11 @@
 ROOTDIR = $(CURDIR)
 
+ifeq ($(OS),Windows_NT)
+	UNAME_S := Windows
+else
+	UNAME_S := $(shell uname -s)
+endif
+
 ifndef config
 ifdef CXXNET_CONFIG
 	config = $(CXXNET_CONFIG)
@@ -74,7 +80,7 @@ endif
 
 # Caffe Plugin
 ifdef CAFFE_PATH
-  CFLAGS += -DMXNET_USE_CAFFE=1
+	CFLAGS += -DMXNET_USE_CAFFE=1
 endif
 
 ifndef LINT_LANG
@@ -91,7 +97,9 @@ else
 endif
 
 ifeq ($(USE_OPENMP), 1)
-	CFLAGS += -fopenmp
+	ifneq ($(UNAME_S), Darwin)
+		CFLAGS += -fopenmp
+	endif
 endif
 
 ifeq ($(USE_NNPACK), 1)
@@ -105,11 +113,17 @@ ifeq ($(USE_MKL2017), 1)
 	CFLAGS += -I$(ROOTDIR)/src/operator/mkl/
 	CFLAGS += -I$(MKLML_ROOT)/include
 	LDFLAGS += -L$(MKLML_ROOT)/lib
-ifeq ($(USE_MKL2017_EXPERIMENTAL), 1)
-	CFLAGS += -DMKL_EXPERIMENTAL=1
-else
-	CFLAGS += -DMKL_EXPERIMENTAL=0
-endif
+	ifeq ($(USE_MKL2017_EXPERIMENTAL), 1)
+		CFLAGS += -DMKL_EXPERIMENTAL=1
+	else
+		CFLAGS += -DMKL_EXPERIMENTAL=0
+	endif
+	ifeq ($(UNAME_S), Darwin)
+		LDFLAGS += -lmklml
+	else
+		LDFLAGS += -Wl,--as-needed -lmklml_intel -lmklml_gnu
+	endif
+	LDFLAGS +=  -liomp5
 endif
 
 # verify existence of separate lapack library when using blas/openblas/atlas
@@ -180,8 +194,8 @@ ifeq ($(CUDA_ARCH),)
 	# Run nvcc on a zero-length file to check architecture-level support.
 	# Create args to include SASS in the fat binary for supported levels.
 	CUDA_ARCH := $(foreach arch,$(KNOWN_CUDA_ARCHS), \
-                  $(shell $(NVCC) -arch=sm_$(arch) -E --x cu /dev/null >/dev/null 2>&1 && \
-                          echo -gencode arch=compute_$(arch),code=sm_$(arch)))
+				$(shell $(NVCC) -arch=sm_$(arch) -E --x cu /dev/null >/dev/null 2>&1 && \
+						echo -gencode arch=compute_$(arch),code=sm_$(arch)))
 	# Convert a trailing "code=sm_NN" to "code=[sm_NN,compute_NN]" to also
 	# include the PTX of the most recent arch in the fat-binaries for
 	# forward compatibility with newer GPUs.
@@ -189,7 +203,7 @@ ifeq ($(CUDA_ARCH),)
 	# Add fat binary compression if supported by nvcc.
 	COMPRESS := --fatbin-options -compress-all
 	CUDA_ARCH += $(shell $(NVCC) -cuda $(COMPRESS) --x cu /dev/null -o /dev/null >/dev/null 2>&1 && \
-	                     echo $(COMPRESS))
+						 echo $(COMPRESS))
 endif
 endif
 
@@ -231,20 +245,18 @@ PLUGIN_OBJ =
 PLUGIN_CUOBJ =
 include $(MXNET_PLUGINS)
 
-# scala package profile
-ifeq ($(OS),Windows_NT)
+ifeq ($(UNAME_S), Windows)
 	# TODO(yizhi) currently scala package does not support windows
 	SCALA_PKG_PROFILE := windows
 else
-	UNAME_S := $(shell uname -s)
 	ifeq ($(UNAME_S), Darwin)
 		WHOLE_ARCH= -all_load
 		NO_WHOLE_ARCH= -noall_load
 		SCALA_PKG_PROFILE := osx-x86_64
 	else
-		SCALA_PKG_PROFILE := linux-x86_64
 		WHOLE_ARCH= --whole-archive
 		NO_WHOLE_ARCH= --no-whole-archive
+		SCALA_PKG_PROFILE := linux-x86_64
 	endif
 endif
 
@@ -307,9 +319,9 @@ lib/libmxnet.a: $(ALLX_DEP)
 	ar crv $@ $(filter %.o, $?)
 
 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}
+	@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}
 
 $(PS_PATH)/build/libps.a: PSLITE
 
diff --git a/dmlc-core b/dmlc-core
index e880afe..a527100 160000
--- a/dmlc-core
+++ b/dmlc-core
@@ -1 +1 @@
-Subproject commit e880afeb932d746e55eb92e8c6eb3ff1b3697c48
+Subproject commit a527100d7d5001efc4954848a2fc6027e48c05f4
diff --git a/mshadow b/mshadow
index 380f825..51c4043 160000
--- a/mshadow
+++ b/mshadow
@@ -1 +1 @@
-Subproject commit 380f825b84e28216516377e71199a8e14f12352f
+Subproject commit 51c40430711bbea807efd256ee2dbacce0081276
diff --git a/prepare_mkl.sh b/prepare_mkl.sh
index 9769731..139a7aa 100755
--- a/prepare_mkl.sh
+++ b/prepare_mkl.sh
@@ -75,10 +75,16 @@ MXNET_ROOT=`dirname $0`
 USE_MKLML=0
 # NOTE: if you update the following line, please also update the dockerfile at
 # tests/ci_build/Dockerfile.mkl
-VERSION_MATCH=20170425
-ARCHIVE_BASENAME=mklml_lnx_2018.0.20170425.tgz
+VERSION_MATCH=20170720
+PLATFORM=$(uname)
+if [ $PLATFORM == "Darwin" ]; then
+    INFIX=mac
+elif [ $PLATFORM == "Linux" ]; then
+    INFIX=lnx
+fi
+ARCHIVE_BASENAME=mklml_${INFIX}_2018.0.20170720.tgz
 MKL_CONTENT_DIR=`echo $ARCHIVE_BASENAME | rev | cut -d "." -f 2- | rev`
-MKLURL="https://github.com/01org/mkl-dnn/releases/download/v0.7/$ARCHIVE_BASENAME"
+MKLURL="https://github.com/01org/mkl-dnn/releases/download/v0.10/$ARCHIVE_BASENAME"
 # there are diffrent MKL lib to be used for GCC and for ICC
 reg='^[0-9]+$'
 VERSION_LINE=`GetVersionName $MKLROOT`
@@ -90,18 +96,26 @@ if [ -z $MKLROOT ]; then
     #echo $VERSION_LINE
     if [ $VERSION_LINE -lt $VERSION_MATCH ] ; then
       #...If it is not then downloaded and unpacked
-      wget --quiet --no-check-certificate -P $MXNET_ROOT $MKLURL -O $MXNET_ROOT/$ARCHIVE_BASENAME
+      if [ $PLATFORM == "Darwin" ]; then
+        curl -L -o $MXNET_ROOT/$ARCHIVE_BASENAME $MKLURL
+      elif [ $PLATFORM == "Linux" ]; then
+        wget --quiet --no-check-certificate -P $MXNET_ROOT $MKLURL -O $MXNET_ROOT/$ARCHIVE_BASENAME
+      fi
       tar -xzf $MXNET_ROOT/$ARCHIVE_BASENAME -C $MXNET_ROOT
       #echo $HOME_MKL
       yes | cp -rf $MXNET_ROOT/$MKL_CONTENT_DIR/* $HOME_MKL
       rm -rf $MXNET_ROOT/$MKL_CONTENT_DIR
     fi
-  MKLLIB=`find $HOME_MKL -name libmklml_gnu.so`
+  if [ $PLATFORM == "Darwin" ]; then
+    MKLLIB=`find $HOME_MKL -name libmklml.dylib`
+  elif [ $PLATFORM == "Linux" ]; then
+    MKLLIB=`find $HOME_MKL -name libmklml_gnu.so`
+  fi
   MKLROOT=`echo $MKLLIB | sed -e 's/lib.*$//'`
 fi
 
 # Check what MKL lib we have in MKLROOT
-if [ -z `find $MKLROOT -name libmklml_gnu.so -print -quit` ]; then
+if [ -z `find $MKLROOT -name libmklml_gnu.so -o -name libmklml.dylib -print -quit` ]; then
   USE_MKLML=0
 elif [ -z `find $MKLROOT -name libmkl_core.so -print -quit` ]; then
   USE_MKLML=1
diff --git a/tests/ci_build/Dockerfile.mklml_gpu b/tests/ci_build/Dockerfile.mklml_gpu
index 1c29ca3..36f51c2 100644
--- a/tests/ci_build/Dockerfile.mklml_gpu
+++ b/tests/ci_build/Dockerfile.mklml_gpu
@@ -9,7 +9,7 @@ RUN /install/ubuntu_install_python.sh
 COPY install/ubuntu_install_scala.sh /install/
 RUN /install/ubuntu_install_scala.sh
 
-RUN wget --no-check-certificate -O /tmp/mklml.tgz https://github.com/01org/mkl-dnn/releases/download/v0.7/mklml_lnx_2018.0.20170425.tgz
+RUN wget --no-check-certificate -O /tmp/mklml.tgz https://github.com/01org/mkl-dnn/releases/download/v0.10/mklml_lnx_2018.0.20170720.tgz
 RUN tar -zxvf /tmp/mklml.tgz && cp -rf mklml_*/* /usr/local/ && rm -rf mklml_*
 
 ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib

-- 
To stop receiving notification emails like this one, please contact
['"commits@mxnet.apache.org" <co...@mxnet.apache.org>'].