Created
September 28, 2016 06:30
-
-
Save yuxhuang/7faf8e1a4f0d02694d87b25cdbb036a1 to your computer and use it in GitHub Desktop.
Bash script to build HiPLARM for R.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mkdir LALibs | |
export BLDDIR=/home/felix/src/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 | |
## start install PLASMA | |
export OMP_NUM_THREADS=1 | |
export MKL_NUM_THREADS=1 | |
wget http://icl.cs.utk.edu/projectsfiles/plasma/pubs/plasma-installer_2.8.0.tar.gz | |
tar -xf plasma-installer_2.8.0.tar.gz | |
cd plasma-installer_2.8.0 | |
./setup.py --prefix="$BLDDIR" --cc=gcc --fc=gfortran \ | |
--blaslib="-Wl,--no-as-needed -L${MKLROOT}/lib/intel64 -lmkl_intel_lp64 -lmkl_core -lmkl_sequential -lpthread -lm -ldl" \ | |
--cflags="-m64 -I${MKLROOT}/include -O3 -fPIC -I$BLDDIR/include" \ | |
--fflags="-O3 -fPIC" --noopt="-fPIC" \ | |
--ldflags_c="-I$BLDDIR/include"\ | |
--notesting --downlapc | |
# compile shared libraries | |
cd $LIBDIR | |
gcc -shared -o libplasma.so -Wl,-whole-archive libplasma.a -Wl,-no-whole-archive -L. -lhwloc -llapacke | |
gcc -shared -o libcoreblas.so -Wl,-whole-archive libcoreblas.a -Wl,-no-whole-archive -L. -llapacke | |
gcc -shared -o libquark.so -Wl,-whole-archive libquark.a -Wl,-no-whole-archive | |
gcc -shared -o libcoreblasqw.so -Wl,-whole-archive libcoreblasqw.a -Wl,-no-whole-archive -L. -llapacke | |
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$LIBDIR/pkgconfig | |
export PLASMA_NUM_THREADS=$TOTAL_CORES | |
export R_PLASMA_NUM_THREADS=$TOTAL_CORES | |
cd $BLDDIR | |
## start install MGMGA | |
export CUDADIR=/usr/local/cuda | |
export CUDALIB=$CUDADIR/lib64 | |
wget http://icl.cs.utk.edu/projectsfiles/magma/downloads/magma-2.1.0.tar.gz | |
tar -xf magma-2.1.0.tar.gz | |
cd magma-2.1.0 | |
echo "#include<cuda.h> | |
#include<cuda_runtime_api.h> | |
#include<stdio.h> | |
int main() { | |
int deviceCount = 0; | |
cudaError_t error_id = cudaGetDeviceCount(&deviceCount); | |
int dev, driverVersion = 0, runtimeVersion = 0; | |
struct cudaDeviceProp deviceProp; | |
int prev = 0; | |
for (dev = 0; dev < deviceCount; dev++) { | |
cudaGetDeviceProperties(&deviceProp, dev); | |
if(deviceProp.major > prev) | |
prev = deviceProp.major; | |
} | |
if(prev >= 2 && prev < 3) | |
printf(\"GPU_TARGET = Fermi\"); | |
else if(prev >= 3) | |
printf(\"GPU_TARGET = Kepler\"); | |
else | |
printf(\"GPU_TARGET = Tesla\"); | |
return 0; | |
} | |
" > getDevice.c | |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUDALIB | |
gcc getDevice.c -I$CUDADIR/include -o getDevice -L$CUDALIB -lcudart | |
./getDevice > make.inc | |
cat make.inc.mkl-gcc >> make.inc | |
make -j $NUM_CORES shared | |
cd lib | |
cp *.so $LIBDIR | |
cd ../ | |
cp include/*.h $BLDDIR/include/ | |
cd $BLDDIR | |
## install HiPLARM | |
wget https://cran.r-project.org/src/contrib/HiPLARM_0.1.tar.gz | |
R CMD INSTALL --configure-args="--with-lapack=-L$MKLROOT/lib/intel64 --with-plasma-lib=$BLDDIR --with-cuda-home=/usr/local/cuda --with-magma-lib=$BLDDIR" HiPLARM_0.1.tar.gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment