Skip to content

Alternatives to lapacke.h #300

@LecrisUT

Description

@LecrisUT

I think it is good to consider the new C++26 proposal for <linalg>, specifically section 9.2

Nevertheless, we have excluded LAPACK-like functionality from this proposal, for the following reasons:

  1. LAPACK is a Fortran library, unlike the BLAS, which is a multilanguage standard.
  2. We intend to support more general element types, beyond the four that LAPACK supports. It’s much more straightforward to make a C++ BLAS work for general element types, than to make LAPACK algorithms work generically.

First, unlike the BLAS, LAPACK is a Fortran library, not a standard. LAPACK was developed concurrently with the “level 3” BLAS functions, and the two projects share contributors. Nevertheless, only the BLAS and not LAPACK got standardized

...

For these reasons, we have left LAPACK-like functionality for future work. It would be natural for a future LAPACK-like C++ library to build on our proposal.

It seems unlikely that LAPACK interface would be ported to standard library and when BLAS is ported to C++ std, I don't believe the BLAS provider projects would have much benefit. Even currently there are issues:

  • lapacke.h is not packaged in all providers
  • distro packages are outdated in their build system and provides for pkg-config support
  • FindLAPACK.cmake does not actually add the relevant include to work properly

The paper recommends other C++ native libraries like Armadillo, Eigen3, etc. It might be useful to look into how the support for these would look like. But in the meantime let's discuss a plan of action

Short-term

Continue to use lapacke.h and test for the presence of the header, and fail the build if it's not present. The user would have to define themselves overrides like BLA_VENDOR to select the vendor that is compatible like OpenBLAS. There are various bugs that need to be addressed upstream:

  • distro packages should add the pkg-config files
  • FindLAPACK.cmake should have an interface to override the include directory
  • the phono3py would need an intermediate support package until these issues are fixed upstream

With regards to the packaged wheels, these will contain bundled BLAS and LAPACK implementations compatible with cibuildwheel. How well this works, we will have to find out and work with cibuildwheel folks. But hopefully the user can rely on the sdist builds to work on their arbitrary environments.

Future

For the future support we should consider some other options:

  • bundling lapacke wrappers
  • alternative C++ eigensolver packages that can be FetchContent in case the user does not have the package
  • using scipy or other PyPI friendly packages
  • splitting the performance critical backend from the python interface

If it's possible to get some performance benchmarking or profiling that would be very helpful for guiding which approach is most suitable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions