LAPACK + GPU = MAGMA
使用gotoblas2+CUDA安装magma1.1.0(227)
准备阶段:
1 安装CUDA
2安装cpu BLAS
3安装LAPACK
安装过程:
1 按照README文档进行安装
2 在make.inc lib'中加入-lgfortran
3 出现error
gcc -O3 -DADD_ -DGPUSHMEM=130 -fPIC -Xlinker -zmuldefs -DGPUSHMEM=130 testing_zhetrd.o -o testing_zhetrd lin/liblapacktest.a -L../lib \
-lcuda -lmagma -lmagmablas -lmagma -L/opt/GotoBLAS2 -L/usr/local/cuda/lib64 -L/usr/lib64 /opt/GotoBLAS2/libgoto.a -lgoto -lpthread -lcublas -lcudart -llapack -lm -lgfortran
../lib/libmagma.a(zlatrd.o): In function `magma_zlatrd':
zlatrd.cpp:(.text+0x3be): undefined reference to `zdotc'
collect2: ld returned 1 exit status
make: *** [testing_zhetrd] 错误 1
解决方案:参考http://icl.cs.utk.edu/magma/forum/viewtopic.php?f=2&t=278和http://www.pavanky.com/installing-magma-with-gotoblas2/
The forum post linked above talks about how to fix the issue in zlatrd.cpp and clatrd.cpp by replacingblasf77_*dotc withcblas_*dotc_sub.
Be aware that the function is used twice. The first around line 256, and the second around line 325. Here are the changes to be made inzlatrd.cpp(在src目录下)
cblas_zdotc_sub(i, W(0, iw), ione, A(0, i), ione, &value); // Line 256
//blasf77_zdotc(&value, &i, W(0, iw), &ione, A(0, i), &ione);
...
...
cblas_zdotc_sub(i_n, W(i +1, i), ione,A(i +1, i), ione, &value); // Line 326
//blasf77_zdotc(&value, &i_n, W(i+1,i), &ione, A(i+1, i), &ione);
4 运行时无法找到libgoto.so
OPTIONS
Firstly, MAGMA needs a CPU LAPACK and BLAS backend installed on your machine.
There are four options for this.
Each of the four options can be configured by one of the files make.inc.$(LIB). LIB is eithermkl,acml, atlas or goto. I wanted to go the opensource all the way with this.For reasons inexplicable, I chose GOTOBLAS2 over ATLAS.
GOTOBLAS2
That meant, I had to build GOTOBLAS2 first. It was mostly painless; Except, I had gcc 4.6. Which meant the compiler started complaining about-l flags with nothing mentioned to the right. It was quickly evident that a parser was broken in the pipeline. After digging through perl code (with which I have *no* experience) for a few minutes, I had the fix. The following patch had to be made tof_check inside the root directory of gotoblas.
$link =~ s/\-rpath\s+/\-rpath\@/g; $link =~ s/\-l\ /\-l/g; # Add this new line around line 237.
MAGMA
Finally, with everything setup, I had to make a change or two to make.inc.goto.
- Change GPU_TARGET = 1 (because I use a fermi card. Leave as 0 if you have pre-fermi cards).
- Change lgoto to lgoto2
- Copy make.inc.goto to make.inc
Doing a make at this point halts with a linker error.
The forum post linked above talks about how to fix the issue in zlatrd.cpp and clatrd.cpp by replacingblasf77_*dotc withcblas_*dotc_sub.
Be aware that the function is used twice. The first around line 256, and the second around line 325. Here are the changes to be made inzlatrd.cpp
如下
cblas_zdotc_sub(i, W(0, iw), ione, A(0, i), ione, &value); // Line 256
//blasf77_zdotc(&value, &i, W(0, iw), &ione, A(0, i), &ione);
...
...
cblas_zdotc_sub(i_n, W(i +1, i), ione,A(i +1, i), ione, &value); // Line 326
//blasf77_zdotc(&value, &i_n, W(i+1,i), &ione, A(i+1, i), &ione)
http://www.pavanky.com/installing-magma-with-gotoblas2/
2在深圳超算上安装MAGMA
./testing_sgeqrf: error while loading shared libraries: libcublas.so.4: failed to map segment from shared object: Cannot allocate memory
不知道是cuda没有安装好(因为权限问题驱动没有装好),还是系统的问题?
3安装CLMAGMA
需要opencl blas(这个从可以从AMD得到)
需要cpu blas 和 cpu lapack (使用 mkl)
大概还需要amd app
测试中报错,放弃。