Custom BLAS and LAPACK Cross-Compilation Framework for RISC-V
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
BLAS Added spikeargs Sep 15, 2018
CBLAS Added libf2c, c versions of BLAS routines Aug 31, 2018
CMAKE initial May 15, 2018
CUSTOM Added custom asm file Sep 15, 2018
DOCS initial May 15, 2018
INSTALL initial May 15, 2018
LAPACKE initial May 15, 2018
SRC initial May 15, 2018
TESTING Added libf2c, c versions of BLAS routines Aug 31, 2018
libf2c Fix integers in f2c Sep 15, 2018
.gitignore Added custom utility files Sep 15, 2018
.travis.yml initial May 15, 2018
CMakeLists.txt initial May 15, 2018
CTestConfig.cmake initial May 15, 2018 initial May 15, 2018
LICENSE initial May 15, 2018
Makefile Added custom utility files Sep 15, 2018 Add note on custom headers and source files Sep 15, 2018
appveyor.yml initial May 15, 2018 initial May 15, 2018
lapack_build.cmake initial May 15, 2018 initial May 15, 2018 Added spikeargs Sep 15, 2018 initial May 15, 2018


This repository provides a framework for writing and cross-compiling custom optimized BLAS routines for a custom RISC-V architecture.


The riscv64-unknown-linux-gnu toolchain must be on your PATH. riscv-gfortran must also be available. Note gfortran is typically not installed as part of a standard riscv-tools installation.

The default ISA is rv64gc, specified in You may want to change this.

To build librefblas, libcblas, and liblapack, run


libcblas.a is probably the most relevant for you. This library provides the standard C BLAS interface many other software packages expect.

Building gfortran

My hacky way to do this is to edit the generated Makefile in riscv-gnu-toolchain/build, and for every line with --enable-languages=c,c++ replace that with --enable-languages=c,c++,fortran. Then make all and make install.


Tests are available at BLAS/TESTING, CBLAS/TESTING, and LAPACK/TESTING. BLAS tests are probably the most relevant. To run these, make sure the correct spike version is available in your PATH.

make run


Relevant BLAS source files are at BLAS/SRC. The reference C implementations were translated from the reference fortran implementations using f2c. This allows you to easily insert custom inline assembler code.

Custom utility functions, or assembly kernels can be defined in CUSTOM/SRC and CUSTOM/include.


Build Status Appveyor codecov

  • VERSION 1.0 : February 29, 1992
  • VERSION 1.0a : June 30, 1992
  • VERSION 1.0b : October 31, 1992
  • VERSION 1.1 : March 31, 1993
  • VERSION 2.0 : September 30, 1994
  • VERSION 3.0 : June 30, 1999
  • VERSION 3.0 + update : October 31, 1999
  • VERSION 3.0 + update : May 31, 2000
  • VERSION 3.1 : November 2006
  • VERSION 3.1.1 : February 2007
  • VERSION 3.2 : November 2008
  • VERSION 3.2.1 : April 2009
  • VERSION 3.2.2 : June 2010
  • VERSION 3.3.0 : November 2010
  • VERSION 3.3.1 : April 2011
  • VERSION 3.4.0 : November 2011
  • VERSION 3.4.1 : April 2012
  • VERSION 3.4.2 : September 2012
  • VERSION 3.5.0 : November 2013
  • VERSION 3.6.0 : November 2015
  • VERSION 3.6.1 : June 2016
  • VERSION 3.7.0 : December 2016
  • VERSION 3.7.1 : June 2017
  • VERSION 3.8.0 : November 2017

LAPACK is a library of Fortran subroutines for solving the most commonly occurring problems in numerical linear algebra.

LAPACK is a freely-available software package. It can be included in commercial software packages (and has been). We only ask that that proper credit be given to the authors, for example by citing the LAPACK Users' Guide. The license used for the software is the modified BSD license, see:

Like all software, it is copyrighted. It is not trademarked, but we do ask the following: if you modify the source for these routines we ask that you change the name of the routine and comment the changes made to the original.

We will gladly answer any questions regarding the software. If a modification is done, however, it is the responsibility of the person who modified the routine to provide support.

LAPACK is available from github at:

LAPACK releases are also available on netlib at:

The distribution contains (1) the Fortran source for LAPACK, and (2) its testing programs. It also contains (3) the Fortran reference implementation of the Basic Linear Algebra Subprograms (the Level 1, 2, and 3 BLAS) needed by LAPACK. However this code is intended for use only if there is no other implementation of the BLAS already available on your machine; the efficiency of LAPACK depends very much on the efficiency of the BLAS. It also contains (4) CBLAS, a C interface to the BLAS, and (5) LAPACKE, a C interface to LAPACK.


  • LAPACK can be installed with make. The configuration have to be set in the file. A for a Linux machine running GNU compilers is given in the main directory. Some specific are also available in the INSTALL directory.
  • LAPACK includes also the CMake build. You will need to have CMake installed on your machine (CMake is available at CMake will allow an easy installation on a Windows Machine.
  • Specific information to run LAPACK under Windows is available at

User Support

LAPACK has been thoroughly tested, on many different types of computers. The LAPACK project supports the package in the sense that reports of errors or poor performance will gain immediate attention from the developers. Such reports, descriptions of interesting applications, and other comments should be sent by electronic mail to

For further information on LAPACK please read our FAQ at

A list of known problems, bugs, and compiler errors for LAPACK is maintained on netlib Please see as well

A User forum is also available to help you with the LAPACK library at You can also contact directly the LAPACK team at


LAPACK includes a thorough test suite. We recommend that, after compilation, you run the test suite.

For complete information on the LAPACK Testing please consult LAPACK Working Note 41 "Installation Guide for LAPACK".

User Guide

To view an HTML version of the Users' Guide please refer to the URL


LAPACK now includes the LAPACKE package. LAPACKE is a Standard C language API for LAPACK This was born from a collaboration of the LAPACK and INTEL Math Kernel Library teams. See: