python-for-android icon indicating copy to clipboard operation
python-for-android copied to clipboard

Enhancement request: lapack recipe using OpenBLAS

Open RobertFlatt opened this issue 2 years ago • 8 comments

Description

The current lapack recipe implementation using LEGACY_NDK is clever but somewhat baroque. And not all users can navigate the steps.

Consider using lapack from OpenBLAS, it contains lapack (the same version 3.10.1) that has been run through f2c. So lapack can be be built with a C compiler, no extra NDK!

This is now the default behavior of OpenBLAS, so we might reasonably think it is stable.

From https://www.openblas.net/Changelog.txt

Version 0.3.21 07-Aug-2022

general:

  • Updated the included LAPACK to Reference-LAPACK release 3.10.1
  • when no Fortran compiler is available, OpenBLAS builds will now automatically build LAPACK from an f2c-converted copy of LAPACK 3.9.0 unless the NO_LAPACK option is specified

An alternative might be to use f2c directly, since OpenBLAS contains C not Fortran it is possible this translation has issues with automation. Impossible to know without trying it.

RobertFlatt avatar May 30 '23 04:05 RobertFlatt

Oh, that's nice!

+1 for getting rid of LEGACY_NDK, as it's legacy, and it will break sometimes in the future + is not available for Apple Silicon users (like me)

Are you considering trying yourself or we should schedule/advertise the proposal? 😁

misl6 avatar May 30 '23 18:05 misl6

Advertise, I have external things going on.

And I look at all the issues I just posted as possible training projects to allow other people to get inside the tools a little (one more enhancement request to come).

RobertFlatt avatar May 30 '23 21:05 RobertFlatt

Hi @mzakharo! (sorry for the ping)

I do not know if it happen that you're still active on python-for-android related projects (and maybe you also still make use of lapack).

I was wondering if you may be interested in working on this proposal, as you're the https://github.com/kivy/python-for-android/pull/2615 author, and you're likely (100% sure) most knowledgeable than me on lapack and scipy.

misl6 avatar May 31 '23 19:05 misl6

Lapack is not the end goal. Scipy needs Fortran last time I checked. Is this no longer the case?

mzakharo avatar May 31 '23 20:05 mzakharo

Lapack is not the end goal. Scipy needs Fortran last time I checked. Is this no longer the case?

You're right.

As I said, you're more knowledgeable than me on scipy and lapack 😀

misl6 avatar Jun 02 '23 06:06 misl6

Will Scipy run through f2c?

If not a built cache would address the complexity issue for most users. https://github.com/kivy/python-for-android/issues/2823

RobertFlatt avatar Jun 03 '23 00:06 RobertFlatt

Currently, Scipy is relying on Meson for their cross-compilation and meson seems to be supporting ios and android. So may be we can try to venture into Meson and try out the cross-compilation for scipy. Next, we have the open-sourced methodology for cross -compilation for android by Chaquopy and for ios through Beeware. They have been successful in cross-compiling their own gfortran used for cross compiling scipy. https://github.com/chaquo/chaquopy/tree/master/server/pypi/packages https://github.com/freakboy3742/chaquopy/tree/iOS-support/server/pypi https://docs.scipy.org/doc/scipy/building/cross_compilation.html https://github.com/scipy/scipy/issues/14812

Old repo but possibly showing the methodology for cross-compilation for android irrespective of ndk version (??): https://github.com/buffer51/android-gfortran

Samael-TLB avatar Oct 25 '23 17:10 Samael-TLB