Gotoblas + lapack + lapack_wrapper
Rod Heylen has a good lapack wrapper, which can be used with ATLAS.
Find it here (http://itf.fys.kuleuven.be/~rob/computer/lapack_wrapper/index.html)
However, ATLAS is very hard and time consuming (>6hr for me) to
install. While, GotoBlas is said to have better performance than ATLAS
does, and is easy to install.
I tested to replace ATLAS with GotoBlas, and compile lapack_wrapper
examples successfully, on Ubuntu9.10, 32bit intel Core2DUO 2.2GHz,
gcc4.4. Of course, we need to change the lapack_wrapper a little. This
is because of some functions and variable declarations are
incompatible in ATLAS and GotoBlas.
Download GotoBLAS2-1.10.tar.gz.
Untar it to a directory, i.e. /home/shiming/GOTO
>>tar xvfz GotoBLAS2-1.10.tar.gz
cd to that directory
>> make
>>sudo cp libgoto2_* /usr/lib
>>sudo mkdir /usr/local/include/goto
>>sudo cp cblas.h /usr/local/include/goto
Download CLAPACK3.1.1, untar it, and copy CLAPACK-3.1.1/INCLUDE/f2c.h
and CLAPACK-3.1.1/INCLUDE/clapack.h to /usr/local/include/goto
>>cd /usr/local/include/goto
>>sudo chmod 755 *
>>cd /usr/lib
>>sudo ln -s libgoto2_*.a libgoto.a
>>sudo ln -s libgoto2_*.so libgoto.so
Change a little in lapack_wrapper.c. I do not list them here. To see
the difference, just download the original one, and use 'diff'
The changed version is available here
(http://sites.google.com/site/chuanese/lapack_wrapper_for_GotoBlas.tar?attredirects=0)
Also edit the cblas.h by adding one line
#define blasint int
And edit the f2c.h by changing the line on the 10th line to
typedef int integer;
To compile, use
>>gcc -o lapack_example lapack_example.c lapack_wrapper.c -lm -lgoto -lgfortran
>>./lapack_example
Everything works well.
In a machine that I have no 'root' right, there is a little difference to run the code.
For example, a PPC blade, RHEL, 64bit, gcc4.1.2. Just compile to GotoBlas and copy necessary header files and lib files to somewhere, i.e. /home/shiming1/goto, and chmod 755 *.
In the directory where lapack_example.c exists, compile with
>> gcc -o test lapack_example.c lapack_wrapper.c -lm -L../soc/goto -lgoto2 -lgfortran
Run it with
>>LD_LIBRARY_PATH=goto/:$LD_LIBRARY_PATH ./test
Here is a good article about using dynamic library
(http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html)
--------------------------------------------------------------------
One example about cblas_dgemv. Suppose matrix A is a 3 by 4 double, stored as a 'cvec' (row major).
A=[1 3 2; 6 4 1; 2 8 7, 3 4 5].
x1=[1; 1; 1]
x2=[1; 1; 1; 1]
y =Ax1
cblas_dgemv(CblasRowMajor, CblasNoTrans, 4, 3, 1.0, A, 4, x1, 1, 0.0, y, 1);
If y= A'x2
cblas_dgemv(CblasRowMajor, CblasTrans, 3, 4, 1.0, A, 3, x2, 1, 0.0, y, 1);
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment