Linear Algebra standardization in C++

Thanks for sharing. It’s kind of provocative that the C++ folks are adopting a BLAS-like interface, while most contemporary Fortran users still go through the trouble of manually writing interfaces for the F77 routines (see Pure wrappers for impure procedures).

The mdspan mentioned in proposal P1673R7 sounds like the perfect container to wrap a Fortran array. You may have seen my recent experiment with the already standardized std::span and sorting in Fortran via C++ (edit: I forgot to add the link). I was pretty stunned by the simplicity of linking Fortran and C++. I think we should try and capitalise on these developments, or even get involved with the C++ community.

If a C++ BLAS became available, with a bit of glue code and the tools in “ISO_Fortran_binding.h” it would be pretty straightforward to have a Fortran BLAS interface based upon the C++ one. I wonder if the people who submitted the proposal are aware of this and are pushing it also for altruistic reasons.

A few more thoughts:

  • The C++ proposals discussed in the podcast were briefly mentioned in a previous post of mine - Automatic object of parameterized derived type - #22 by ivanpribec. Back then I didn’t imagine there might be a day, where I’ll be linking a C++ BLAS into Fortran, but now it sure seems things are heading in that direction.
  • Let’s not forget, with the right compile flags, Fortran compilers can already translate certain BLAS-like array expressions to optimised BLAS calls: Mapping matrix & vector arithmetic to BLAS calls. To achieve something similar in C++ would require expression templates, which are also mentioned in that proposal.
4 Likes