OpenBLAS是BLAS(Basic Linear Algebra Subprograms)的优化版。
OpenBLAS官网:http://www.openblas.net/
OpenBLAS公开课:https://www.leiphone.com/news/201704/Puevv3ZWxn0heoEv.html
OpenBLAS用户手册:https://github.com/xianyi/OpenBLAS/wiki/User-Manual
用户手册里提到可以通过查看intel MKL的手册来了解OpenBLAS中函数的功能。
第一步:安装OpenBLAS
sudo git clone https://github.com/xianyi/OpenBLAS.git
cd OpenBLAS
sudo make TARGET=NEHALEM
sudo make PREFIX=/opt/OpenBLAS install
二.测试
#include
#include
void main()
{
int i=0;
double A[6] = {1.0,2.0,1.0,-3.0,4.0,-1.0};
double B[6] = {1.0,2.0,1.0,-3.0,4.0,-1.0};
double C[9] = {.5,.5,.5,.5,.5,.5,.5,.5,.5};
cblas_dgemm(CblasColMajor, CblasNoTrans, CblasTrans,3,3,2,1,A, 3, B, 3,2,C,3);
for(i=0; i<9; i++)
printf("%lf ", C[i]);
printf("\n");
}
//编译运行
$ gcc test.c -o test -I /opt/OpenBLAS/include/ -L /opt/OpenBLAS/lib/ -lopenblas -lpthread
$ ./test
11.000000 -9.000000 5.000000 -9.000000 21.000000 -1.000000 5.000000 -1.000000 3.000000
可能出现问题:
libopenblas.so.0: cannot open shared object file: No such file or
directory
sudo vi /etc ld.so.conf
source ldconfig