From 5a700a1bab60231cc8017cf169b31756bc6b8455 Mon Sep 17 00:00:00 2001 From: Jacek Czaja Date: Tue, 30 Aug 2016 11:40:39 +0200 Subject: [PATCH 1/2] - Fix prepare_mkl for MKLGOLD - Makefile cleanup - cosmetic changes - Fix to interrupted binaries download Desc: When downloading of binaries is interrupted then restarting the process will make binaries downloaded with diffrent name and then first (broken) archive aws unpacked. This is now fixed by fixing archive name --- Makefile | 4 ---- Makefile.config.example | 2 ++ external/mkl/prepare_mkl.sh | 47 ++++++++++++++++++++----------------- 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 2a81f3919..02b98f16c 100644 --- a/Makefile +++ b/Makefile @@ -434,9 +434,6 @@ ifeq ($(MKL_EXTERNAL), 1) MKL_LDFLAGS+=-Wl,-rpath,$(MKLROOT)/lib endif -#$(info "RETURN_STRING: "$(RETURN_STRING)) -#$(info "MKLROOT: "$(MKLROOT)) - COMMON_FLAGS += -DUSE_MKL BLAS_INCLUDE ?= $(MKLROOT)/include BLAS_LIB ?= $(MKLROOT)/lib $(MKLROOT)/lib/intel64 @@ -558,7 +555,6 @@ ifeq ($(USE_OPENMP), 1) endif endif - # MPI support ifeq ($(USE_MPI), 1) COMMON_FLAGS += -DUSE_MPI diff --git a/Makefile.config.example b/Makefile.config.example index 291c4532b..b89f7c78f 100644 --- a/Makefile.config.example +++ b/Makefile.config.example @@ -9,6 +9,8 @@ # Uncomment to use optimized MKL2017 primitives by default for supported layers # USE_MKL2017_AS_DEFAULT_ENGINE := 1 + +# Uncomment to use MKLDNN primitives as default engine (EXPERIMENTAL) # USE_MKLDNN_AS_DEFAULT_ENGINE := 1 # uncomment to disable IO dependencies and corresponding data layers diff --git a/external/mkl/prepare_mkl.sh b/external/mkl/prepare_mkl.sh index b729bed98..1e9625bba 100755 --- a/external/mkl/prepare_mkl.sh +++ b/external/mkl/prepare_mkl.sh @@ -12,35 +12,40 @@ FindLibrary() esac } + +GetVersionName() +{ +VERSION_LINE=0 +if [ $1 ]; then + VERSION_LINE=`grep __INTEL_MKL_BUILD_DATE $1/include/mkl_version.h 2>/dev/null | sed -e 's/.* //'` +fi +if [ -z $VERSION_LINE ]; then + VERSION_LINE=0 +fi +echo $VERSION_LINE # Return Version Line +} + # MKL DST=`dirname $0` OMP=0 -MKLURL="https://github.com/intelcaffe/caffe/releases/download/self_containted_GOLD/mklml_lnx_2017.0.0.20160801.tgz " -if [ $MKLROOT ]; then - VERSION_LINE=`grep __INTEL_MKL_BUILD_DATE $MKLROOT/include/mkl_version.h 2>/dev/null | sed -e 's/.* //'` -fi +VERSION_MATCH=20160801 +ARCHIVE_BASENAME=mklml_lnx_2017.0.0.$VERSION_MATCH.tgz +MKL_CONTENT_DIR=`echo $ARCHIVE_BASENAME | rev | cut -d "." -f 2- | rev` +GITHUB_RELEASE_TAG=self_containted_MKLGOLD +MKLURL="https://github.com/intel/caffe/releases/download/$GITHUB_RELEASE_TAG/$ARCHIVE_BASENAME" # there are diffrent MKL lib to be used for GCC and for ICC -FindLibrary $1 reg='^[0-9]+$' -if [ -z $VERSION_LINE ]; then - VERSION_LINE=0 -else - if ! [[ $VERSION_LINE =~ $reg ]]; then - VERSION_LINE=0 - fi -fi -# Check if MKL_ROOT is set if positive then set one will be used.. +VERSION_LINE=`GetVersionName $MKLROOT` +# Check if MKLROOT is set if positive then set one will be used.. if [ -z $MKLROOT ] || [ $VERSION_LINE -lt 20160706 ]; then - # ..if MKLROOT is not set then check if we have MKL downloaded.. - if [ -z $LOCALMKL ] || [ ! -f $LOCALMKL ]; then + # ..if MKLROOT is not set then check if we have MKL downloaded in proper version + VERSION_LINE=`GetVersionName $DST/$MKL_CONTENT_DIR` + if [ $VERSION_LINE -lt 20160706 ] ; then #...If it is not then downloaded and unpacked - wget --no-check-certificate -P $DST $MKLURL - tar -xzf $DST/mklml_lnx*.tgz -C $DST - FindLibrary $1 + wget --no-check-certificate -P $DST $MKLURL -O $DST/$ARCHIVE_BASENAME + tar -xzf $DST/$ARCHIVE_BASENAME -C $DST fi - # set MKL env vars are to be done via generated script - # this will help us export MKL env to existing shell - + FindLibrary $1 MKLROOT=$PWD/`echo $LOCALMKL | sed -e 's/lib.*$//'` fi From 94b90010d32e1f378059697cf0b0e3e3081ef08b Mon Sep 17 00:00:00 2001 From: Jacek Czaja Date: Tue, 30 Aug 2016 16:02:38 +0200 Subject: [PATCH 2/2] - Fixes from review: Version match usage applied and adjusted --- external/mkl/prepare_mkl.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/external/mkl/prepare_mkl.sh b/external/mkl/prepare_mkl.sh index 1e9625bba..947b20e4c 100755 --- a/external/mkl/prepare_mkl.sh +++ b/external/mkl/prepare_mkl.sh @@ -28,8 +28,8 @@ echo $VERSION_LINE # Return Version Line # MKL DST=`dirname $0` OMP=0 -VERSION_MATCH=20160801 -ARCHIVE_BASENAME=mklml_lnx_2017.0.0.$VERSION_MATCH.tgz +VERSION_MATCH=20160706 +ARCHIVE_BASENAME=mklml_lnx_2017.0.0.20160801.tgz MKL_CONTENT_DIR=`echo $ARCHIVE_BASENAME | rev | cut -d "." -f 2- | rev` GITHUB_RELEASE_TAG=self_containted_MKLGOLD MKLURL="https://github.com/intel/caffe/releases/download/$GITHUB_RELEASE_TAG/$ARCHIVE_BASENAME" @@ -37,10 +37,10 @@ MKLURL="https://github.com/intel/caffe/releases/download/$GITHUB_RELEASE_TAG/$AR reg='^[0-9]+$' VERSION_LINE=`GetVersionName $MKLROOT` # Check if MKLROOT is set if positive then set one will be used.. -if [ -z $MKLROOT ] || [ $VERSION_LINE -lt 20160706 ]; then +if [ -z $MKLROOT ] || [ $VERSION_LINE -lt $VERSION_MATCH ]; then # ..if MKLROOT is not set then check if we have MKL downloaded in proper version VERSION_LINE=`GetVersionName $DST/$MKL_CONTENT_DIR` - if [ $VERSION_LINE -lt 20160706 ] ; then + if [ $VERSION_LINE -lt $VERSION_MATCH ] ; then #...If it is not then downloaded and unpacked wget --no-check-certificate -P $DST $MKLURL -O $DST/$ARCHIVE_BASENAME tar -xzf $DST/$ARCHIVE_BASENAME -C $DST