Note

This is the documentation for the latest development branch and may refer to features that are not available in released versions. If you are looking for the documentation for a specific release, use the drop-down menu on the left and select the desired version.

OpenBLAS Example#

OpenBLAS Overview#

OpenBLAS is an optimized BLAS computation library released under the BSD license. BLAS (Basic Linear Algebra Subprograms) is an API standard for numerical libraries that provide basic linear-algebra operations such as vector and matrix multiplication. OpenBLAS is one concrete implementation of the BLAS standard.

In K230 RTOS SDK, a prebuilt OpenBLAS library is already included under:

src/rtsmart/libs/openblas/

Users can directly link against this static library when building their own applications.

Build Examples#

This section explains how to build executables by using the prebuilt OpenBLAS static library in the SDK. The SDK provides four example programs under:

src/rtsmart/examples/3rd-party/openblas/

Code Structure#

openblas_cblas_saxpy
openblas_cblas_sgemm
openblas_cblas_sger
openblas_fortran_dgemm
CMakeLists.txt
build_app.sh
cmake/

Firmware Build#

If you want the examples to be built into the firmware, run make menuconfig from the K230 RTOS SDK root and enable:

RT-Smart UserSpace Examples Configuration
-> Enable build 3rd-party examples
-> Enable Build OpenBlas Sample Programs

The examples will be placed under sdcard/app/examples/3rd-party/openblas in the firmware image.

Example Build#

If you only want to build the OpenBLAS example programs, enter:

src/rtsmart/examples/3rd-party/openblas

and run:

./build_app.sh

After a successful build, the k230_bin directory contains the compiled elf files and related test files.

Run Examples#

openblas_cblas_saxpy#

This sample implements:

y = alpha * x + y

Representative result:

This is the result:
4 7 11 14
This is the reference:
4 7 11 14
{Test PASS}.

openblas_cblas_sgemm#

This sample implements:

C = alpha * A * B + beta * C

Representative result:

This is the result:
7 10 15 22
This is the reference:
7 10 15 22
{Test PASS}.

openblas_cblas_sger#

This sample implements:

A = alpha * x * y^T + beta * A

Representative result:

This is the result:
20 40 10 20 30 60
This is the reference:
20 40 10 20 30 60
{Test PASS}.

openblas_fortran_dgemm#

This sample demonstrates the Fortran-interface dgemm flow.

Representative result:

m=2,n=3,k=4,alpha=1.200000,beta=0.001000,sizeofc=6
This is matrix A
...
This is the result:
16.801 18.002 18.003 16.801 15.602 22.803
This is the reference:
16.801 18.002 18.003 16.801 15.602 22.803
{Test PASS}.
Comments list
Comments
Log in