library(Matrix) p = 6000 X = Matrix(rnorm(p**2), p) Y = Matrix(rnorm(p**2), p) s = proc.time(); Z = X %*% Y; proc.time() - s # user system elapsed # 20.646 0.137 5.193 s = proc.time(); Z = solve(X, Y); proc.time() - s # user system elapsed # 40.418 0.342 10.741 s = proc.time(); Z = crossprod(X, Y); proc.time() - s # user system elapsed # 22.706 0.128 5.986 s = proc.time(); Z = chol(X %*% t(X)); proc.time() - s # user system elapsed # 25.774 0.242 6.934 s = proc.time(); Z = solve(t(X) %*% X, X %*% Y); proc.time() - s # user system elapsed # 86.842 0.755 23.521
library(HiPLARM) p = 6000 X = Matrix(rnorm(p**2), p) Y = Matrix(rnorm(p**2), p) s = proc.time(); Z = X %*% Y; proc.time() - s # user system elapsed # 2.826 1.031 3.858 s = proc.time(); Z = solve(X, Y); proc.time() - s # user system elapsed # 4.295 1.343 5.642 s = proc.time(); Z = crossprod(X, Y); proc.time() - s # user system elapsed # 2.899 1.029 3.931 s = proc.time(); Z = chol(X %*% t(X)); proc.time() - s # user system elapsed # 4.165 1.333 5.504 s = proc.time(); Z = solve(t(X) %*% X, X %*% Y); proc.time() - s # user system elapsed # 10.440 3.377 13.825
HiPLARM is 1.6 times faster than the R without HiPLARM. I think that it will be much faster if the size of matrix is bigger. Since the memory of my gpu is 2GB, I can’t test bigger size matrix. The tests for smaller size matrix are almost the same because the data movement between host (CPU) and device (GPU). PS: I have ran the benchmark script(found in Simon Urbanek’s), but it is so slow that I do not put it on this post.
I simply introduce how to install HiPLARM. Since my R is compiled by icc and MKL, so I have some trouble in installing it. You can download the auto-installer in here. I ran the auto-installer with ALTAS (I can’t compile OpenBLAS and I don’t know why.) and it stopped at installing the R package caused by the environment variable. I solve this problem by add following line in the file .bashrc:
where /home/clarence/Downloads/LALibs/lib is the installation directory of magma, plasma and hwloc. After installation, you should add export R_PLASMA_NUM_THREADS=4 into .bashrc. Then you can use it!!
I have tried to compile plasma and magma with icc and MKL, the install script is present in following:
mkdir LALibs export BLDDIR=/home/clarence/Downloads/LALibs cd $BLDDIR mkdir lib mkdir include LIBDIR=$BLDDIR/lib INCDIR=$BLDDIR/include NUM_PHYS_CPU=`cat /proc/cpuinfo | grep 'physical id' | sort | uniq | wc -l` NUM_CORES=`cat /proc/cpuinfo | grep 'cpu cores' | uniq | sed 's/[a-z]//g' | sed 's/://g'` let TOTAL_CORES=$[NUM_PHYS_CPU * NUM_CORES]
## start install hwloc wget http://www.open-mpi.org/software/hwloc/v1.9/downloads/hwloc-1.9.tar.gz tar -xf hwloc-1.9.tar.gz cd hwloc-1.9 ./configure --prefix="$BLDDIR" make -j $NUM_CORES make install export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$LIBDIR/pkgconfig export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIBDIR cd $BLDDIR
I have two troubles in compiling magma. First one is failure on compiling magma with icc and success with switching the compiler to gcc. Another trouble is the function lapack_const which is defined in both plasma and magma, so I can’t compile and I use the suggestion on MAGMA forum to disable the magma-with-plasma routines. To disable the magma-with-plasma routines, you need to comment the line PLASMA = ... in the file Makefile.internal like this:
1 2
# Use Plasma to compile zgetfl and ztstrf # PLASMA = $(shell pkg-config --libs plasma 2> /dev/null )
My environment is ubuntu 14.04. My CPU is 3770K@4.3GHz and GPU is GTX 670. If you have some questions, you can reference following urls: