|
| 1 | +#!/bin/bash |
| 2 | +# set -ex |
| 3 | +# |
| 4 | +# All modification made by Intel Corporation: © 2016 Intel Corporation |
| 5 | +# |
| 6 | +# All contributions by the University of California: |
| 7 | +# Copyright (c) 2014, 2015, The Regents of the University of California (Regents) |
| 8 | +# All rights reserved. |
| 9 | +# |
| 10 | +# All other contributions: |
| 11 | +# Copyright (c) 2014, 2015, the respective contributors |
| 12 | +# All rights reserved. |
| 13 | +# For the list of contributors go to https://github.com/BVLC/caffe/blob/master/CONTRIBUTORS.md |
| 14 | +# |
| 15 | +# |
| 16 | +# Redistribution and use in source and binary forms, with or without |
| 17 | +# modification, are permitted provided that the following conditions are met: |
| 18 | +# |
| 19 | +# * Redistributions of source code must retain the above copyright notice, |
| 20 | +# this list of conditions and the following disclaimer. |
| 21 | +# * Redistributions in binary form must reproduce the above copyright |
| 22 | +# notice, this list of conditions and the following disclaimer in the |
| 23 | +# documentation and/or other materials provided with the distribution. |
| 24 | +# * Neither the name of Intel Corporation nor the names of its contributors |
| 25 | +# may be used to endorse or promote products derived from this software |
| 26 | +# without specific prior written permission. |
| 27 | +# |
| 28 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 29 | +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 30 | +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 31 | +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE |
| 32 | +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 33 | +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 34 | +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 35 | +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 36 | +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 37 | +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 38 | +# |
| 39 | +FindLibrary() |
| 40 | +{ |
| 41 | + case "$1" in |
| 42 | + intel|1) |
| 43 | + LOCALMKL=`find $DST -name libmklml_intel.so` # name of MKL SDL lib |
| 44 | + ;; |
| 45 | + *) |
| 46 | + LOCALMKL=`find $DST -name libmklml_gnu.so` # name of MKL SDL lib |
| 47 | + ;; |
| 48 | + esac |
| 49 | + |
| 50 | +} |
| 51 | + |
| 52 | +GetVersionName() |
| 53 | +{ |
| 54 | +VERSION_LINE=0 |
| 55 | +if [ $1 ]; then |
| 56 | + VERSION_LINE=`grep __INTEL_MKL_BUILD_DATE $1/include/mkl_version.h 2>/dev/null | sed -e 's/.* //'` |
| 57 | +fi |
| 58 | +if [ -z $VERSION_LINE ]; then |
| 59 | + VERSION_LINE=0 |
| 60 | +fi |
| 61 | +echo $VERSION_LINE # Return Version Line |
| 62 | +} |
| 63 | + |
| 64 | +# MKL |
| 65 | +DST=`dirname $0` |
| 66 | +OMP=0 |
| 67 | +VERSION_MATCH=20160706 |
| 68 | +ARCHIVE_BASENAME=mklml_lnx_2017.0.0.20160801.tgz |
| 69 | +MKL_CONTENT_DIR=`echo $ARCHIVE_BASENAME | rev | cut -d "." -f 2- | rev` |
| 70 | +GITHUB_RELEASE_TAG=self_containted_MKLGOLD |
| 71 | +MKLURL="https://github.com/intel/caffe/releases/download/$GITHUB_RELEASE_TAG/$ARCHIVE_BASENAME" |
| 72 | +# there are diffrent MKL lib to be used for GCC and for ICC |
| 73 | +reg='^[0-9]+$' |
| 74 | +VERSION_LINE=`GetVersionName $MKLROOT` |
| 75 | +# Check if MKLROOT is set if positive then set one will be used.. |
| 76 | +if [ -z $MKLROOT ] || [ $VERSION_LINE -lt $VERSION_MATCH ]; then |
| 77 | + # ..if MKLROOT is not set then check if we have MKL downloaded in proper version |
| 78 | + VERSION_LINE=`GetVersionName $DST/$MKL_CONTENT_DIR` |
| 79 | + if [ $VERSION_LINE -lt $VERSION_MATCH ] ; then |
| 80 | + #...If it is not then downloaded and unpacked |
| 81 | + wget --no-check-certificate -P $DST $MKLURL -O $DST/$ARCHIVE_BASENAME |
| 82 | + tar -xzf $DST/$ARCHIVE_BASENAME -C $DST |
| 83 | + fi |
| 84 | + FindLibrary $1 |
| 85 | + MKLROOT=$PWD/`echo $LOCALMKL | sed -e 's/lib.*$//'` |
| 86 | +fi |
| 87 | + |
| 88 | +# Check what MKL lib we have in MKLROOT |
| 89 | +if [ -z `find $MKLROOT -name libmkl_rt.so -print -quit` ]; then |
| 90 | + LIBRARIES=`basename $LOCALMKL | sed -e 's/^.*lib//' | sed -e 's/\.so.*$//'` |
| 91 | + OMP=1 |
| 92 | +else |
| 93 | + LIBRARIES="mkl_rt" |
| 94 | +fi |
| 95 | + |
| 96 | + |
| 97 | +# return value to calling script (Makefile,cmake) |
| 98 | +echo $MKLROOT $LIBRARIES $OMP |
0 commit comments