2016-04-28 13:48:11 +02:00
#!/bin/bash
WGET_OPTIONS = "--no-check-certificate"
MRO_VERSION = "3.2.4"
2016-05-01 22:36:35 +02:00
CHECKPOINT_DATE = "2016-04-01"
2016-05-19 19:11:33 +02:00
R_BENCHMARK_SCRIPT = "benchmark-sample.R"
2016-05-15 13:04:27 +02:00
DIR_BLAS = "/opt/blas-libs"
2016-04-28 13:48:11 +02:00
2016-05-17 19:47:27 +02:00
if [ ! -f ./cpuinfo ] ; then
echo "Intel processor family information utility not found, aborting..."
exit 1
fi
PROCESSOR_CORES = ` ./cpuinfo -g | grep -oP 'Cores( +):( +)\K(\d+)' `
PROCESSOR_CPUS = ` ./cpuinfo -g | grep -oP 'Processors\(CPUs\)( +):( +)\K(\d+)' `
NPROC = ${ PROCESSOR_CORES }
2016-05-01 22:36:35 +02:00
function mro_install {
2016-04-28 13:48:11 +02:00
2016-05-03 12:09:43 +02:00
echo "Started installing Microsoft R Open and dependencies"
2016-05-19 19:11:33 +02:00
# save host info
./cpuinfo -g | grep -oP 'Processor name( +):( +)\K(.+)' > host-info.log
cat /proc/meminfo | grep -oP 'MemTotal:( +)\K(\d+)' >> host-info.log
lspci -nn | grep -oP "VGA.*\KNVIDIA.*?]" >> host-info.log
2016-04-29 22:24:51 +02:00
2016-05-01 22:36:35 +02:00
# update debian repos & upgrade packages
2016-05-14 18:19:34 +02:00
echo "deb http://snapshot.debian.org/archive/debian/20160411T102554Z/ jessie-backports main" >> /etc/apt/sources.list
apt-get -o Acquire::Check-Valid-Until= false update
2016-05-01 22:36:35 +02:00
DEBIAN_FRONTEND = noninteractive apt-get -y -o Dpkg::Options::= "--force-confdef" -o Dpkg::Options::= "--force-confnew" upgrade
2016-04-28 13:48:11 +02:00
2016-05-15 15:07:06 +02:00
# install core packages
2016-05-17 19:47:27 +02:00
apt-get -y install build-essential gfortran ed htop libxml2-dev ca-certificates curl libcurl4-openssl-dev gdebi-core sshpass git cpufrequtils cmake initramfs-tools linux-headers-$( uname -r) nvidia-detect bc
2016-04-28 13:48:11 +02:00
2016-05-01 22:36:35 +02:00
# disable CPU throttling for ATLAS multi-threading
echo performance | tee /sys/devices/system/cpu/cpu**/cpufreq/scaling_governor
2016-04-28 13:48:11 +02:00
2016-05-01 22:36:35 +02:00
# hack with Microsoft R Open deps
wget ${ WGET_OPTIONS } http://ftp.pl.debian.org/debian/pool/main/libj/libjpeg8/libjpeg8_8d1-2_amd64.deb
gdebi -n libjpeg8_8d1-2_amd64.deb
rm libjpeg8_8d1-2_amd64.deb
2016-04-28 20:11:50 +02:00
2016-05-01 22:36:35 +02:00
# install Microsoft R Open
wget ${ WGET_OPTIONS } https://mran.microsoft.com/install/mro/${ MRO_VERSION } /MRO-${ MRO_VERSION } -Ubuntu-15.4.x86_64.deb
gdebi -n MRO-${ MRO_VERSION } -Ubuntu-15.4.x86_64.deb
rm MRO-${ MRO_VERSION } -Ubuntu-15.4.x86_64.deb
2016-05-01 01:31:19 +02:00
2016-05-01 22:36:35 +02:00
# make symbolic link to R libraries dir
ln -s /usr/lib64/MRO-${ MRO_VERSION } /R-${ MRO_VERSION } /lib/R/lib/ /opt/MRO-lib
2016-04-28 20:11:50 +02:00
2016-05-01 22:36:35 +02:00
# prepare R checkpoint
mkdir ~/.checkpoint
Rscript -e " library(checkpoint); checkpoint(' ${ CHECKPOINT_DATE } ') "
2016-05-19 19:11:33 +02:00
sed -i " 1i\library(checkpoint); checkpoint(' ${ CHECKPOINT_DATE } ', scanForPackages=FALSE, verbose=FALSE) " benchmark-sample.R
sed -i " 1i\library(checkpoint); checkpoint(' ${ CHECKPOINT_DATE } ', scanForPackages=FALSE, verbose=FALSE) " benchmark-urbanek.R
sed -i " 1i\library(checkpoint); checkpoint(' ${ CHECKPOINT_DATE } ', scanForPackages=FALSE, verbose=FALSE) " benchmark-revolution.R
2016-05-20 12:54:32 +02:00
sed -i " 1i\library(checkpoint); checkpoint(' ${ CHECKPOINT_DATE } ', scanForPackages=FALSE, verbose=FALSE) " benchmark-gcbd.R
2016-05-01 22:36:35 +02:00
# make directory for BLAS and LAPACK libraries
2016-05-15 13:04:27 +02:00
mkdir -p ${ DIR_BLAS }
2016-05-01 22:36:35 +02:00
# clean archives
apt-get clean
2016-05-03 12:09:43 +02:00
echo "Finished installing Microsoft R Open and dependencies"
2016-05-01 22:36:35 +02:00
}
2016-04-28 20:11:50 +02:00
2016-04-29 14:07:28 +02:00
##############################################################
##############################################################
## CPU ##
##############################################################
##############################################################
2016-04-28 20:11:50 +02:00
2016-04-29 14:07:28 +02:00
##############################################################
# netlib #
# - http://www.netlib.org/ #
# - BLAS + LAPACK #
# - single-threaded (reference) #
##############################################################
2016-04-28 20:11:50 +02:00
2016-05-15 13:04:27 +02:00
DIR_NETLIB = " ${ DIR_BLAS } /netlib "
2016-05-01 22:36:35 +02:00
function netlib_install {
2016-05-03 12:09:43 +02:00
echo "Started installing netlib"
2016-05-01 22:36:35 +02:00
mkdir ${ DIR_NETLIB }
apt-get -y install libblas3 liblapack3
2016-04-28 20:11:50 +02:00
2016-05-01 22:36:35 +02:00
cp /usr/lib/libblas/libblas.so.3.0 ${ DIR_NETLIB }
cp /usr/lib/lapack/liblapack.so.3.0 ${ DIR_NETLIB }
2016-04-28 20:11:50 +02:00
2016-05-05 12:26:35 +02:00
apt-get -y purge libblas3 liblapack3
apt-get -y autoremove
2016-05-01 22:36:35 +02:00
apt-get clean
echo "Installed files:"
find ${ DIR_NETLIB } -type f
2016-04-28 20:11:50 +02:00
2016-05-01 22:36:35 +02:00
echo "Finished installing netlib."
}
2016-05-05 12:26:35 +02:00
function netlib_remove {
echo "Started removing netlib"
rm ${ DIR_NETLIB } -r
echo "Finished removing netlib."
}
2016-05-01 22:36:35 +02:00
function netlib_check {
2016-05-19 19:11:33 +02:00
echo "Started checking netlib"
2016-05-01 22:36:35 +02:00
2016-05-19 19:11:33 +02:00
LD_PRELOAD = " ${ DIR_NETLIB } /libblas.so.3.0 ${ DIR_NETLIB } /liblapack.so.3.0 " Rscript -e " blasLibName='netlib'; source(' ${ R_BENCHMARK_SCRIPT } ') "
2016-05-01 22:36:35 +02:00
2016-05-03 12:09:43 +02:00
echo "Finished checking netlib"
2016-05-01 22:36:35 +02:00
}
2016-04-29 14:07:28 +02:00
##############################################################
# ATLAS (st) #
# - http://math-atlas.sourceforge.net/ #
# - BLAS + LAPACK #
# - single-threaded #
##############################################################
2016-05-15 13:04:27 +02:00
DIR_ATLAS_ST = " ${ DIR_BLAS } /atlas-st "
2016-05-01 22:36:35 +02:00
function atlas_st_install {
2016-04-29 14:07:28 +02:00
2016-05-03 12:09:43 +02:00
echo "Started installing ATLAS (single-threaded)"
2016-04-29 14:07:28 +02:00
2016-05-01 22:36:35 +02:00
mkdir ${ DIR_ATLAS_ST }
2016-04-29 14:07:28 +02:00
2016-05-01 22:36:35 +02:00
apt-get -y install libatlas3-base
cp /usr/lib/atlas-base/libatlas.so.3 ${ DIR_ATLAS_ST }
cp /usr/lib/atlas-base/atlas/libblas.so.3 ${ DIR_ATLAS_ST }
cp /usr/lib/atlas-base/atlas/liblapack.so.3 ${ DIR_ATLAS_ST }
2016-05-05 12:26:35 +02:00
apt-get -y purge libatlas3-base
2016-05-05 16:42:20 +02:00
apt-get -y autoremove
2016-05-01 22:36:35 +02:00
apt-get clean
echo "Installed files:"
find ${ DIR_ATLAS_ST } -type f
2016-05-03 12:09:43 +02:00
echo "Finished installing ATLAS (single-threaded)"
2016-05-01 22:36:35 +02:00
}
function atlas_st_check {
2016-05-03 12:09:43 +02:00
echo "Started checking ATLAS (single-threaded)"
2016-05-01 22:36:35 +02:00
2016-05-19 19:11:33 +02:00
LD_PRELOAD = " ${ DIR_ATLAS_ST } /libatlas.so.3 ${ DIR_ATLAS_ST } /libblas.so.3 ${ DIR_ATLAS_ST } /liblapack.so.3 " Rscript -e " blasLibName='atlas_st'; source(' ${ R_BENCHMARK_SCRIPT } ') "
2016-05-01 22:36:35 +02:00
2016-05-03 12:09:43 +02:00
echo "Finished checking ATLAS (single-threaded)"
2016-05-01 22:36:35 +02:00
}
2016-04-29 14:07:28 +02:00
2016-05-05 12:26:35 +02:00
function atlas_st_remove {
echo "Started removing ATLAS (single-threaded)"
rm ${ DIR_ATLAS_ST } -r
echo "Finished removing ATLAS (single-threaded)"
}
2016-04-29 14:07:28 +02:00
##############################################################
# OpenBLAS #
# - http://www.openblas.net/ #
# - BLAS + LAPACK #
# - multi-threaded #
##############################################################
2016-04-28 20:11:50 +02:00
2016-05-15 13:04:27 +02:00
DIR_OPENBLAS = " ${ DIR_BLAS } /openblas "
2016-05-01 22:36:35 +02:00
function openblas_install {
2016-05-03 12:09:43 +02:00
echo "Started installing OpenBLAS"
2016-04-29 14:07:28 +02:00
2016-05-01 22:36:35 +02:00
mkdir ${ DIR_OPENBLAS }
2016-04-29 14:07:28 +02:00
2016-05-01 22:36:35 +02:00
apt-get -y install libopenblas-base
2016-04-29 14:07:28 +02:00
2016-05-01 22:36:35 +02:00
cp /usr/lib/libopenblas.so.0 ${ DIR_OPENBLAS }
cp /usr/lib/openblas-base/libblas.so.3 ${ DIR_OPENBLAS }
cp /usr/lib/openblas-base/liblapack.so.3 ${ DIR_OPENBLAS }
2016-05-05 12:26:35 +02:00
apt-get -y purge libopenblas-base
2016-05-05 16:42:20 +02:00
apt-get -y autoremove
2016-05-01 22:36:35 +02:00
apt-get clean
echo "Installed files:"
find ${ DIR_OPENBLAS } -type f
2016-05-03 12:09:43 +02:00
echo "Finished installing OpenBLAS"
2016-05-01 22:36:35 +02:00
}
function openblas_check {
2016-05-03 12:09:43 +02:00
echo "Started checking OpenBLAS"
2016-05-01 22:36:35 +02:00
2016-05-19 19:11:33 +02:00
LD_PRELOAD = " ${ DIR_OPENBLAS } /libopenblas.so.0 ${ DIR_OPENBLAS } /libblas.so.3 ${ DIR_OPENBLAS } /liblapack.so.3 " Rscript -e " blasLibName='openblas'; source(' ${ R_BENCHMARK_SCRIPT } ') "
2016-05-01 22:36:35 +02:00
2016-05-03 12:09:43 +02:00
echo "Finished checking OpenBLAS"
2016-05-01 22:36:35 +02:00
}
2016-04-29 14:07:28 +02:00
2016-05-05 12:26:35 +02:00
function openblas_remove {
echo "Started removing OpenBLAS"
rm ${ DIR_OPENBLAS } -r
echo "Finished removing OpenBLAS"
}
2016-04-29 14:07:28 +02:00
##############################################################
# ATLAS (mt) #
# - http://math-atlas.sourceforge.net/ #
2016-05-01 22:36:35 +02:00
# - BLAS + netlib LAPACK #
2016-04-29 14:07:28 +02:00
# - multi-threaded #
##############################################################
2016-05-15 13:04:27 +02:00
DIR_ATLAS_MT = " ${ DIR_BLAS } /atlas-mt "
2016-05-01 22:36:35 +02:00
function atlas_mt_install {
2016-05-03 12:09:43 +02:00
echo "Started installing ATLAS (multi-threaded)"
2016-04-28 20:11:50 +02:00
2016-05-01 22:36:35 +02:00
mkdir ${ DIR_ATLAS_MT }
2016-04-28 20:11:50 +02:00
2016-05-01 22:36:35 +02:00
curl -L https://sourceforge.net/projects/math-atlas/files/Developer%20%28unstable%29/3.11.38/atlas3.11.38.tar.bz2/download > atlas3.11.38.tar.bz2
tar -xvf atlas3.11.38.tar.bz2
rm atlas3.11.38.tar.bz2
2016-04-28 20:11:50 +02:00
2016-05-01 22:36:35 +02:00
cd ATLAS
mkdir build
cd build
2016-04-28 20:11:50 +02:00
2016-05-01 22:36:35 +02:00
wget ${ WGET_OPTIONS } http://www.netlib.org/lapack/lapack-3.6.0.tgz
2016-04-28 13:48:11 +02:00
2016-05-18 17:58:08 +02:00
sed -i "1423i\thrchk=0;" ../CONFIG/src/config.c
2016-05-01 22:36:35 +02:00
../configure --shared --with-netlib-lapack-tarfile= ` pwd ` /lapack-3.6.0.tgz
make
2016-04-29 14:07:28 +02:00
2016-05-01 22:36:35 +02:00
cp lib/libtatlas.so ${ DIR_ATLAS_MT }
cd ../../
rm -r ATLAS
echo "Installed files:"
find ${ DIR_ATLAS_MT } -type f
2016-05-03 12:09:43 +02:00
echo "Finished installing ATLAS (multi-threaded)"
2016-05-01 22:36:35 +02:00
}
function atlas_mt_check {
2016-05-03 12:09:43 +02:00
echo "Started checking ATLAS (multi-threaded)"
2016-05-01 22:36:35 +02:00
2016-05-19 19:11:33 +02:00
LD_PRELOAD = " ${ DIR_ATLAS_MT } /libtatlas.so " Rscript -e " blasLibName='atlas_mt'; source(' ${ R_BENCHMARK_SCRIPT } ') "
2016-05-01 22:36:35 +02:00
2016-05-03 12:09:43 +02:00
echo "Finished checking ATLAS (multi-threaded)"
2016-05-01 22:36:35 +02:00
}
2016-04-29 14:07:28 +02:00
2016-05-05 12:26:35 +02:00
function atlas_mt_remove {
echo "Started removing ATLAS (multi-threaded)"
rm ${ DIR_ATLAS_MT } -r
echo "Finished removing ATLAS (multi-threaded)"
}
2016-04-29 14:07:28 +02:00
##############################################################
# GotoBLAS2 #
# - https://prs.ism.ac.jp/~nakama/SurviveGotoBLAS2/ #
# - BLAS + LAPACK #
# - multi-threaded #
##############################################################
2016-04-28 20:11:50 +02:00
2016-05-15 13:04:27 +02:00
DIR_GOTOBLAS2 = " ${ DIR_BLAS } /gotoblas2 "
2016-05-01 22:36:35 +02:00
function gotoblas2_install {
2016-05-03 12:09:43 +02:00
echo "Started installing GotoBLAS2"
2016-05-01 22:36:35 +02:00
mkdir ${ DIR_GOTOBLAS2 }
2016-04-28 20:11:50 +02:00
2016-05-01 22:36:35 +02:00
wget ${ WGET_OPTIONS } https://prs.ism.ac.jp/~nakama/SurviveGotoBLAS2/SurviveGotoBLAS2_3.141.tar.gz
tar -xvf SurviveGotoBLAS2_3.141.tar.gz
rm SurviveGotoBLAS2_3.141.tar.gz
2016-04-28 20:11:50 +02:00
2016-05-01 22:36:35 +02:00
cd survivegotoblas2-3.141
2016-05-17 19:47:27 +02:00
make REFBLAS_ANTILOGY = 1 NO_CBLAS = 1 GOTOBLASLIBSONAME = libgoto2blas.so GOTOLAPACKLIBSONAME = libgoto2lapack.so -j ${ NPROC }
2016-05-01 22:36:35 +02:00
cp exports/libgoto2blas.so ${ DIR_GOTOBLAS2 }
cp exports/libgoto2lapack.so ${ DIR_GOTOBLAS2 }
cd ..
rm -r survivegotoblas2-3.141
Rscript -e " library(checkpoint); checkpoint(' ${ CHECKPOINT_DATE } ', scanForPackages=FALSE, verbose=FALSE); install.packages('RhpcBLASctl') "
echo "Installed files:"
find ${ DIR_GOTOBLAS2 } -type f
2016-04-28 20:11:50 +02:00
2016-05-03 12:09:43 +02:00
echo "Finished installing GotoBLAS2"
2016-05-01 22:36:35 +02:00
}
2016-04-28 20:11:50 +02:00
2016-05-01 22:36:35 +02:00
function gotoblas2_check {
2016-05-03 12:09:43 +02:00
echo "Started checking GotoBLAS2"
2016-05-01 22:36:35 +02:00
2016-05-01 22:57:06 +02:00
echo " ${ DIR_GOTOBLAS2 } " > /etc/ld.so.conf.d/gotoblas2.conf
ldconfig
2016-05-01 22:36:35 +02:00
2016-05-27 00:07:49 +02:00
LD_PRELOAD = " ${ DIR_GOTOBLAS2 } /libgoto2blas.so ${ DIR_GOTOBLAS2 } /libgoto2lapack.so " GOTO_NUM_THREADS = 1 Rscript -e " blasLibName='gotoblas2'; library(checkpoint); checkpoint(' ${ CHECKPOINT_DATE } ', scanForPackages=FALSE, verbose=FALSE); library(RhpcBLASctl); blas_set_num_threads( ${ NPROC } ); source(' ${ R_BENCHMARK_SCRIPT } ') "
2016-05-01 22:36:35 +02:00
2016-05-01 22:57:06 +02:00
rm /etc/ld.so.conf.d/gotoblas2.conf
ldconfig
2016-05-01 22:36:35 +02:00
2016-05-03 12:09:43 +02:00
echo "Finished checking GotoBLAS2"
2016-05-01 22:36:35 +02:00
}
2016-04-28 20:11:50 +02:00
2016-05-05 12:26:35 +02:00
function gotoblas2_remove {
echo "Started removing GotoBLAS2"
rm ${ DIR_GOTOBLAS2 } -r
echo "Finished removing GotoBLAS2"
}
2016-04-29 14:07:28 +02:00
##############################################################
# MKL #
# - https://mran.microsoft.com/documents/rro/multithread/ #
# - BLAS + LAPACK #
# - multi-threaded #
##############################################################
2016-04-28 20:11:50 +02:00
2016-05-15 13:04:27 +02:00
DIR_MKL = " ${ DIR_BLAS } /mkl "
2016-05-01 22:36:35 +02:00
function mkl_install {
2016-05-03 12:09:43 +02:00
echo "Started installing MKL"
2016-05-01 22:36:35 +02:00
mkdir ${ DIR_MKL }
wget ${ WGET_OPTIONS } https://mran.microsoft.com/install/mro/${ MRO_VERSION } /RevoMath-${ MRO_VERSION } .tar.gz
tar -xvzf RevoMath-${ MRO_VERSION } .tar.gz
rm RevoMath-${ MRO_VERSION } .tar.gz
cp RevoMath/mkl/libs/*.so ${ DIR_MKL }
rm RevoMath -r
echo "Installed files:"
find ${ DIR_MKL } -type f
2016-05-03 12:09:43 +02:00
echo "Finished installing MKL"
2016-05-01 22:36:35 +02:00
}
2016-04-28 13:48:11 +02:00
2016-05-01 22:36:35 +02:00
function mkl_check {
2016-04-28 13:48:11 +02:00
2016-05-03 12:09:43 +02:00
echo "Started checking MKL"
2016-04-29 14:07:28 +02:00
2016-05-19 19:11:33 +02:00
LD_PRELOAD = " ${ DIR_MKL } /libRblas.so ${ DIR_MKL } /libRlapack.so ${ DIR_MKL } /libmkl_vml_mc3.so ${ DIR_MKL } /libmkl_vml_def.so ${ DIR_MKL } /libmkl_gnu_thread.so ${ DIR_MKL } /libmkl_core.so ${ DIR_MKL } /libmkl_gf_lp64.so ${ DIR_MKL } /libiomp5.so ${ DIR_MKL } /libmkl_gf_ilp64.so " MKL_INTERFACE_LAYER = "GNU,LP64" MKL_THREADING_LAYER = "GNU" Rscript -e " blasLibName='mkl'; source(' ${ R_BENCHMARK_SCRIPT } ') "
2016-05-01 22:36:35 +02:00
2016-05-03 12:09:43 +02:00
echo "Finished checking MKL"
2016-05-01 22:36:35 +02:00
}
2016-04-29 14:07:28 +02:00
2016-05-05 12:26:35 +02:00
function mkl_remove {
echo "Started removing MKL"
rm ${ DIR_MKL } -r
echo "Finished removing MKL"
}
2016-04-29 14:07:28 +02:00
##############################################################
# BLIS #
# - https://github.com/flame/blis #
# - BLAS #
# - multi-threaded #
##############################################################
2016-05-15 13:04:27 +02:00
DIR_BLIS = " ${ DIR_BLAS } /blis "
2016-05-01 22:36:35 +02:00
function blis_install {
2016-05-03 12:09:43 +02:00
echo "Started installing BLIS"
2016-05-01 22:36:35 +02:00
mkdir ${ DIR_BLIS }
git clone https://github.com/flame/blis.git
cd blis
2016-05-18 17:58:08 +02:00
git checkout 32db0adc218ea4ae370164dbe8d23b41cd3526d3 # 17.05.2016
2016-05-01 22:36:35 +02:00
./configure -t pthreads --enable-shared auto
2016-05-17 19:47:27 +02:00
make -j ${ NPROC }
2016-05-01 22:36:35 +02:00
cd ..
2016-04-28 13:48:11 +02:00
2016-05-01 22:36:35 +02:00
cp ` find ./blis/ -name "libblis.so" ` ${ DIR_BLIS }
2016-04-28 13:48:11 +02:00
2016-05-01 22:36:35 +02:00
rm -r blis
echo "Installed files:"
find ${ DIR_BLIS } -type f
2016-04-28 20:11:50 +02:00
2016-05-03 12:09:43 +02:00
echo "Finished installing BLIS"
2016-05-01 22:36:35 +02:00
}
2016-04-28 20:11:50 +02:00
2016-05-01 22:36:35 +02:00
function blis_check {
2016-05-03 12:09:43 +02:00
echo "Started checking BLIS"
2016-05-01 22:36:35 +02:00
2016-05-17 19:47:27 +02:00
# auto set threading variables (more or less) according to https://github.com/flame/blis/wiki/Multithreading
CPU_L3_PRESENT = ` ./cpuinfo -c | grep -coP "^L3" `
CPU_L3_PRIVATE = ` ./cpuinfo -c | grep -coP "^L3(.*)no sharing" `
CPU_L2_PRIVATE = ` ./cpuinfo -c | grep -coP "^L2(.*)no sharing" `
CPU_L1_PRIVATE = ` ./cpuinfo -c | grep -coP "^L1(.*)no sharing" `
COUNT_JC = 1
COUNT_IC = 1
COUNT_JR = 1
COUNT_IR = 1
PARALLEL_STEPS = ` echo " l( ${ NPROC } )/l(2) " | bc -l | grep -oP "^\d+" `
PARALLEL_I_LOOP = 0
PARALLEL_J_LOOP = 0
while [ $PARALLEL_STEPS -gt 0 ]
do
if [ $PARALLEL_I_LOOP -lt $PARALLEL_J_LOOP ] ; then
if [ ${ CPU_L2_PRIVATE } -eq 1 ] ; then
COUNT_IC = $(( ${ COUNT_IC } * 2 ))
PARALLEL_I_LOOP = $(( ${ PARALLEL_I_LOOP } + 1 ))
elif [ ${ CPU_L3_PRESENT } -eq 1 -a ${ CPU_L3_PRIVATE } -eq 1 ] ; then
COUNT_JC = $(( ${ COUNT_JC } * 2 ))
PARALLEL_J_LOOP = $(( ${ PARALLEL_J_LOOP } + 1 ))
elif [ ${ CPU_L1_PRIVATE } -eq 1 ] ; then
COUNT_JR = $(( ${ COUNT_JR } * 2 ))
PARALLEL_J_LOOP = $(( ${ PARALLEL_J_LOOP } + 1 ))
else
COUNT_IR = $(( ${ COUNT_IR } * 2 ))
PARALLEL_I_LOOP = $(( ${ PARALLEL_I_LOOP } + 1 ))
fi
elif [ $PARALLEL_J_LOOP -lt $PARALLEL_I_LOOP ] ; then
if [ ${ CPU_L3_PRESENT } -eq 1 -a ${ CPU_L3_PRIVATE } -eq 1 ] ; then
COUNT_JC = $(( ${ COUNT_JC } * 2 ))
PARALLEL_J_LOOP = $(( ${ PARALLEL_J_LOOP } + 1 ))
elif [ ${ CPU_L1_PRIVATE } -eq 1 ] ; then
COUNT_JR = $(( ${ COUNT_JR } * 2 ))
PARALLEL_J_LOOP = $(( ${ PARALLEL_J_LOOP } + 1 ))
elif [ ${ CPU_L2_PRIVATE } -eq 1 ] ; then
COUNT_IC = $(( ${ COUNT_IC } * 2 ))
PARALLEL_I_LOOP = $(( ${ PARALLEL_I_LOOP } + 1 ))
else
COUNT_IR = $(( ${ COUNT_IR } * 2 ))
PARALLEL_I_LOOP = $(( ${ PARALLEL_I_LOOP } + 1 ))
fi
else
if [ ${ CPU_L3_PRESENT } -eq 1 -a ${ CPU_L3_PRIVATE } -eq 1 ] ; then
COUNT_JC = $(( ${ COUNT_JC } * 2 ))
PARALLEL_J_LOOP = $(( ${ PARALLEL_J_LOOP } + 1 ))
elif [ ${ CPU_L2_PRIVATE } -eq 1 ] ; then
COUNT_IC = $(( ${ COUNT_IC } * 2 ))
PARALLEL_I_LOOP = $(( ${ PARALLEL_I_LOOP } + 1 ))
elif [ ${ CPU_L1_PRIVATE } -eq 1 ] ; then
COUNT_JR = $(( ${ COUNT_JR } * 2 ))
PARALLEL_J_LOOP = $(( ${ PARALLEL_J_LOOP } + 1 ))
else
COUNT_IR = $(( ${ COUNT_IR } * 2 ))
PARALLEL_I_LOOP = $(( ${ PARALLEL_I_LOOP } + 1 ))
fi
fi
( ( PARALLEL_STEPS--) )
done
2016-05-19 19:11:33 +02:00
LD_PRELOAD = " ${ DIR_BLIS } /libblis.so " BLIS_JC_NT = ${ COUNT_JC } BLIS_IC_NT = ${ COUNT_IC } BLIS_JR_NT = ${ COUNT_JR } BLIS_IR_NT = ${ COUNT_IR } Rscript -e " blasLibName='blis'; source(' ${ R_BENCHMARK_SCRIPT } ') "
2016-05-01 22:36:35 +02:00
2016-05-03 12:09:43 +02:00
echo "Finished checking BLIS"
2016-05-01 22:36:35 +02:00
}
2016-04-28 20:11:50 +02:00
2016-05-05 12:26:35 +02:00
function blis_remove {
echo "Started removing BLIS"
rm ${ DIR_BLIS } -r
echo "Finished removing BLIS"
}
2016-04-29 14:07:28 +02:00
##############################################################
##############################################################
## GPU ##
##############################################################
##############################################################
2016-04-28 20:11:50 +02:00
2016-04-29 14:07:28 +02:00
##############################################################
# cuBLAS (NVBLAS) #
# - https://developer.nvidia.com/cublas #
# - BLAS #
# - CUDA #
##############################################################
2016-04-28 20:11:50 +02:00
2016-05-15 13:04:27 +02:00
DIR_CUBLAS = " ${ DIR_BLAS } /cublas "
2016-05-01 22:36:35 +02:00
function cublas_install {
2016-05-17 19:47:27 +02:00
if [ $( nvidia-detect | grep -c "No NVIDIA GPU detected." ) -eq 1 ] ; then
echo "No NVIDIA GPU detected, cuBLAS installation aborted"
return 1
fi
2016-05-03 12:09:43 +02:00
echo "Started installing cuBLAS"
2016-05-01 22:36:35 +02:00
2016-05-15 13:04:27 +02:00
mkdir ${ DIR_CUBLAS }
2016-05-01 01:31:19 +02:00
2016-05-18 21:53:12 +02:00
# see: https://nouveau.freedesktop.org/wiki/KernelModeSetting/ and https://askubuntu.com/questions/16998/switch-between-nvidia-current-and-nouveau-without-a-reboot
echo 0 > /sys/class/vtconsole/vtcon1/bind
2016-05-03 12:09:43 +02:00
modprobe -r nouveau
2016-05-01 01:31:19 +02:00
2016-05-15 15:27:10 +02:00
DEBIAN_FRONTEND = noninteractive apt-get install nvidia-driver nvidia-modprobe libcuda1 libnvblas6.5 -y -o Dpkg::Options::= "--force-confdef" -o Dpkg::Options::= "--force-confnew"
2016-04-29 22:24:51 +02:00
2016-05-03 12:09:43 +02:00
nvidia-modprobe
2016-05-01 01:31:19 +02:00
2016-05-15 13:04:27 +02:00
echo "
2016-05-18 21:53:12 +02:00
NVBLAS_LOGFILE /dev/null
2016-05-15 13:04:27 +02:00
NVBLAS_CPU_BLAS_LIB ${ DIR_MKL } /libRblas.so
2016-05-01 22:36:35 +02:00
NVBLAS_GPU_LIST ALL0
NVBLAS_TILE_DIM 2048
2016-05-18 21:53:12 +02:00
#NVBLAS_AUTOPIN_MEM_ENABLED" > ${DIR_CUBLAS}/nvblas.conf
2016-05-15 15:07:06 +02:00
2016-05-01 22:36:35 +02:00
apt-get clean
2016-05-01 01:31:19 +02:00
2016-05-03 12:09:43 +02:00
echo "Finished installing cuBLAS"
}
2016-05-30 17:49:09 +02:00
function cublas_optimize {
if [ $( nvidia-detect | grep -c "No NVIDIA GPU detected." ) -eq 1 ] ; then
echo "No NVIDIA GPU detected, cuBLAS installation aborted"
return 1
fi
echo "Started optimizing cuBLAS"
dims_arr = ( 128 256 512 1024 2048 4096)
best_dim_val = -1
best_dim_time = -1
for dim in ${ dims_arr [*] }
do
echo -n " $dim - "
echo "
NVBLAS_LOGFILE /dev/null
NVBLAS_CPU_BLAS_LIB ${ DIR_MKL } /libRblas.so
NVBLAS_GPU_LIST ALL0
NVBLAS_TILE_DIM $dim
#NVBLAS_AUTOPIN_MEM_ENABLED" > ${DIR_CUBLAS}/nvblas.conf
cu_out = $( cublas_check | tail -2 | head -1)
echo $cu_out
if [ $best_dim_val -eq -1 ] ; then
echo "first"
best_dim_val = $dim
best_dim_time = $cu_out
elif [ $( echo " $cu_out < $best_dim_time " | bc) -eq 1 ] ; then
echo "better"
best_dim_time = $cu_out
best_dim_val = $dim
fi
done
echo " best: ${ best_dim_val } ${ best_dim_time } "
echo "
NVBLAS_LOGFILE /dev/null
NVBLAS_CPU_BLAS_LIB ${ DIR_MKL } /libRblas.so
NVBLAS_GPU_LIST ALL0
NVBLAS_TILE_DIM $best_dim_val
#NVBLAS_AUTOPIN_MEM_ENABLED" > ${DIR_CUBLAS}/nvblas.conf
echo "Finished optimizing cuBLAS"
}
2016-05-15 15:07:06 +02:00
# CUDA 7.5 currently supports linux kernel 3.x
#
2016-05-05 16:42:20 +02:00
#function cublas_online_install {
#
2016-05-17 19:47:27 +02:00
# if [ $(nvidia-detect | grep -c "No NVIDIA GPU detected.") -eq 1 ]; then
# echo "No NVIDIA GPU detected, cuBLAS online installation aborted"
# return 1
# fi
#
2016-05-15 15:07:06 +02:00
# echo "Started installing online cuBLAS"
#
# mkdir ${DIR_CUBLAS}
#
2016-05-18 21:53:12 +02:00
# # see: https://nouveau.freedesktop.org/wiki/KernelModeSetting/ and https://askubuntu.com/questions/16998/switch-between-nvidia-current-and-nouveau-without-a-reboot
# echo 0 > /sys/class/vtconsole/vtcon1/bind
2016-05-15 15:07:06 +02:00
# modprobe -r nouveau
#
2016-05-05 16:42:20 +02:00
# # Ubuntu dependencies
# wget ${WGET_OPTIONS} http://de.archive.ubuntu.com/ubuntu/pool/main/x/x-kit/python3-xkit_0.5.0ubuntu2_all.deb
# wget ${WGET_OPTIONS} http://de.archive.ubuntu.com/ubuntu/pool/main/s/screen-resolution-extra/screen-resolution-extra_0.17.1_all.deb
# gdebi -n python3-xkit_0.5.0ubuntu2_all.deb
# gdebi -n screen-resolution-extra_0.17.1_all.deb
#
# wget ${WGET_OPTIONS} http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1504/x86_64/cuda-repo-ubuntu1504_7.5-18_amd64.deb
# dpkg -i cuda-repo-ubuntu1504_7.5-18_amd64.deb
2016-05-15 15:07:06 +02:00
# apt-get -o Acquire::Check-Valid-Until=false update
#
# DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" install cuda-drivers cuda-cublas-7-5 nvidia-modprobe libcuda1-352
#
# nvidia-modprobe
#
# echo "
2016-05-18 21:53:12 +02:00
# NVBLAS_LOGFILE /dev/null
2016-05-15 15:07:06 +02:00
# NVBLAS_CPU_BLAS_LIB ${DIR_MKL}/libRblas.so
# NVBLAS_GPU_LIST ALL0
# NVBLAS_TILE_DIM 2048
2016-05-18 21:53:12 +02:00
# #NVBLAS_AUTOPIN_MEM_ENABLED" > ${DIR_CUBLAS}/nvblas.conf
2016-05-15 15:07:06 +02:00
#
2016-05-05 16:42:20 +02:00
# rm python3-xkit_0.5.0ubuntu2_all.deb
# rm screen-resolution-extra_0.17.1_all.deb
# rm cuda-repo-ubuntu1504_7.5-18_amd64.deb
2016-05-15 15:07:06 +02:00
#
2016-05-05 16:42:20 +02:00
# apt-get clean
2016-05-15 15:07:06 +02:00
#
# echo "Finished installing online cuBLAS"
2016-05-05 16:42:20 +02:00
#}
2016-05-04 12:42:23 +02:00
2016-05-03 17:35:06 +02:00
function cublas_check {
2016-05-03 12:09:43 +02:00
2016-05-17 19:47:27 +02:00
if [ $( nvidia-detect | grep -c "No NVIDIA GPU detected." ) -eq 1 ] ; then
echo "No NVIDIA GPU detected, cuBLAS check aborted"
return 1
fi
2016-05-03 12:09:43 +02:00
echo "Started checking cuBLAS"
2016-05-19 19:11:33 +02:00
NVBLAS_CONFIG_FILE = " ${ DIR_CUBLAS } /nvblas.conf " LD_PRELOAD = "/usr/lib/x86_64-linux-gnu/libnvblas.so.6.5 /usr/lib/x86_64-linux-gnu/libcublas.so.6.5" Rscript -e " blasLibName='cublas'; source(' ${ R_BENCHMARK_SCRIPT } ') "
2016-05-03 12:09:43 +02:00
echo "Finished checking cuBLAS"
}
2016-05-05 16:42:20 +02:00
2016-05-01 22:36:35 +02:00
##############################################################
##############################################################
if [ $# -eq 0 ] ; then
echo "No arguments supplied"
else
for i in " $@ "
2016-05-17 19:47:27 +02:00
do
case " $i " in
nproc_cores)
NPROC = ${ PROCESSOR_CORES }
; ;
nproc_cpus)
NPROC = ${ PROCESSOR_CPUS }
; ;
2016-05-18 17:58:08 +02:00
test_sample)
2016-05-19 19:11:33 +02:00
R_BENCHMARK_SCRIPT = "benchmark-sample.R"
2016-05-18 17:58:08 +02:00
; ;
test_urbanek)
2016-05-19 19:11:33 +02:00
R_BENCHMARK_SCRIPT = "benchmark-urbanek.R"
2016-05-18 17:58:08 +02:00
; ;
test_revolution)
2016-05-19 19:11:33 +02:00
R_BENCHMARK_SCRIPT = "benchmark-revolution.R"
2016-05-18 17:58:08 +02:00
; ;
2016-05-20 12:54:32 +02:00
test_gcbd)
R_BENCHMARK_SCRIPT = "benchmark-gcbd.R"
; ;
2016-05-17 19:47:27 +02:00
*)
$i
esac
2016-05-01 22:36:35 +02:00
done
fi