Skip to content

Link with CBLAS & LAPACK

Ilya Yaroshenko edited this page Nov 14, 2018 · 5 revisions

mir-blas requires a library with CBLAS ABI. mir-lapack requires a library with LAPACK ABI. Almost all LAPACK and CBLAS implementations require BLAS ABI.

The default library for Posix systems that combines all ABIs is OpenBLAS. Intel MKL is default in Windows.

Note, that OpenBLAS may be compiled without CBLAS and/or LAPACK API. Check that arguments for make contain NO_CBLAS=0 and NO_LAPACK=0.

Intel MKL is free to use, but it requires registration to download.

The following instruction uses SDL format for dub configurations.

Windows + Intel MKL

Both 32bit and 64bit executables can be built with both DMD and LDC. To build 32bit executable with DUB and DMD x86_mscoff architecture must be specified:

$ dub build --arch=x86_mscoff ...

There are predefined configuration for Intel MKL. For example, single thread, LP, static:

# in dub.sdl
subConfiguraiton "mir-lapack" "mkl-sequential"

or, if mir-lapack is not used

# in dub.sdl
subConfiguraiton "mir-blas" "mkl-sequential"

Library path may need to be specified for MSVC linker. Mir uses default installation paths, but it may be overridden.

# in dub.sdl
lflags "/LIBPATH:<PATH_TO_REQUIRED_LIBS>"

See also dub.sdl for mir-blas.

Ubuntu

$ sudo apt install libopenblas-dev

The default configution for mir-blas and mir-lapack is "openblas"

Note: Ubuntu Trusty and previous has deprecated OpenBLAS that may not have all required for you ABI. For deprecated ubuntu use liblapack-dev instead and add the following sub configuration in your project

# in dub.sdl
subConfiguraiton "mir-lapack" "blas"

or, if mir-lapack is not used

# in dub.sdl
subConfiguraiton "mir-blas" "blas"

Linux with separate libcblas

If your Linux distribution setup has both libblas and libcblas then use

# in dub.sdl
subConfiguraiton "mir-lapack" "threelib"

or, if mir-lapack is not used

# in dub.sdl
subConfiguraiton "mir-blas" "twolib"

macOS

Install OpenBLAS using brew package manager.

$ brew install openblas
$ brew link openblas

or link with Apple Accelerate:

# in dub.sdl
subConfiguraiton "mir-lapack" "blas"

or, if mir-lapack is not used

# in dub.sdl
subConfiguraiton "mir-blas" "blas"

Custom configuration

To specify your own libraries use:

# in dub.sdl
subConfiguraiton "mir-lapack" "zerolib"
libs "<YOUR_LIB1>" "<YOUR_LIB2>" ...

or, if mir-lapack is not used

# in dub.sdl
subConfiguraiton "mir-blas" "zerolib"
libs "<YOUR_LIB1>" "<YOUR_LIB2>" ...
Clone this wiki locally
You can’t perform that action at this time.