# Linux Kernel Module Cheat

#### 27.8.2. BLAS

Buildroot supports it, which makes everything just trivial:

    ./build-buildroot --config 'BR2_PACKAGE_OPENBLAS=y'
    ./build-userland --package openblas -- userland/libs/openblas/hello.c
    ./run --eval-after './libs/openblas/hello.out; echo $?'

Outcome: the test passes:

    0

Source: userland/libs/openblas/hello.c

The test performs a general matrix multiplication:

        |  1.0 -3.0 |   |  1.0  2.0  1.0 |       |  0.5  0.5  0.5 |   |  11.0 - 9.0  5.0 |
    1 * |  2.0  4.0 | * | -3.0  4.0 -1.0 | + 2 * |  0.5  0.5  0.5 | = | - 9.0  21.0 -1.0 |
        |  1.0 -1.0 |                            |  0.5  0.5  0.5 |   |   5.0 - 1.0  3.0 |

This can be deduced from the Fortran interfaces at

    less "$(./getvar buildroot_build_build_dir)"/openblas-*/reference/dgemmf.f

which we can map to our call as:

    C := alpha*op( A )*op( B ) + beta*C,
    SUBROUTINE DGEMMF(               TRANA,        TRANB,     M,N,K,  ALPHA,A,LDA,B,LDB,BETA,C,LDC)
    cblas_dgemm(      CblasColMajor, CblasNoTrans, CblasTrans,3,3,2  ,1,    A,3,  B,3,  2   ,C,3  );