I want to use Atlas as the BLAS backend for GSL on Raspbian. With these make options:
ldflags = $(shell pkg-config --libs gsl) -L:libatlas.so.3
producing this link step:
gcc -lgsl -lgslcblas -lm -L:libatlas.so.3 -o my-app main.o
The most basic example builds and runs successfully:
#include <stdio.h>
#include <gsl/gsl_blas.h>
int
main (void)
{
double a[] = { 0.11, 0.12, 0.13,
0.21, 0.22, 0.23 };
double b[] = { 1011, 1012,
1021, 1022,
1031, 1032 };
double c[] = { 0.00, 0.00,
0.00, 0.00 };
gsl_matrix_view A = gsl_matrix_view_array(a, 2, 3);
gsl_matrix_view B = gsl_matrix_view_array(b, 3, 2);
gsl_matrix_view C = gsl_matrix_view_array(c, 2, 2);
/* Compute C = A B */
gsl_blas_dgemm (CblasNoTrans, CblasNoTrans,
1.0, &A.matrix, &B.matrix,
0.0, &C.matrix);
printf ("[ %g, %g\n", c[0], c[1]);
printf (" %g, %g ]\n", c[2], c[3]);
return 0;
}
How can I verify that it's using the Atlas backend? Either making a runtime call, or figuring it out via GDB if necessary.
The answer is basically
ldflags
needs to be-L/usr/lib/arm-linux-gnueabihf/atlas -lblas -lgsl -lgslcblas -lm
;gdb
,b cblas_dgemm
, saying yes to future library symbol loading and running. If you land in/usr/lib/arm-linux-gnueabihf/libblas.so.3
- which is a symlink to Atlas via the alternatives system - then yes, it is using Atlas.