Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 29 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -74,7 +80,7 @@ endif

# Caffe Plugin
ifdef CAFFE_PATH
CFLAGS += -DMXNET_USE_CAFFE=1
CFLAGS += -DMXNET_USE_CAFFE=1
endif

ifndef LINT_LANG
Expand All @@ -91,7 +97,9 @@ else
endif

ifeq ($(USE_OPENMP), 1)
CFLAGS += -fopenmp
ifneq ($(UNAME_S), Darwin)
CFLAGS += -fopenmp
endif
endif

ifeq ($(USE_NNPACK), 1)
Expand All @@ -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
Expand Down Expand Up @@ -180,16 +194,16 @@ 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.
CUDA_ARCH := $(shell echo $(CUDA_ARCH) | sed 's/sm_\([0-9]*\)$$/[sm_\1,compute_\1]/')
# 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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion dmlc-core
2 changes: 1 addition & 1 deletion mshadow
26 changes: 20 additions & 6 deletions prepare_mkl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/ci_build/Dockerfile.mklml_gpu
Original file line number Diff line number Diff line change
Expand Up @@ -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