8000 MAINT: Increase minimum required LAPACK version to 3.3.1 by insertinterestingnamehere · Pull Request #6051 · scipy/scipy · GitHub
[go: up one dir, main page]

Skip to content

MAINT: Increase minimum required LAPACK version to 3.3.1 #6051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

insertinterestingnamehere
Copy link
Member

This needs some discussion on the mailing list.

It increases the minimum required LAPACK version to 3.3.1 (it's currently 3.1.0). The version of LAPACK available by default on Travis CI is 3.3.1, so I don't expect this to cause trouble with the CI systems. Since 3.3.1 isn't quite as old as 3.1.0, I still need to mention the requirement in various places in the docs. Other than some extra documentation, this should all be working now though.

There are a few advantages. One is that explicitly requiring more recent versions lets us avoid errors like #5039. Another is that this lets us provide a more complete Cython LAPACK API. The functions exported to Cython currently include only the routines common to every LAPACK version from 3.1.0 to 3.6.0. Increasing the minimum requirement lets us export another 169 routines through that interface. In particular, this adds:

  • cbbcsd
  • cgbequb
  • cgeequb
  • cgeqr2p
  • cgeqrfp
  • cheequb
  • cheswapr
  • chetri2
  • chetri2x
  • chetrs2
  • chfrk
  • chla_transtype
  • clanhf
  • clapmr
  • clarfgp
  • cpftrf
  • cpftri
  • cpftrs
  • cpoequb
  • cpstf2
  • cpstrf
  • csyconv
  • csyequb
  • csyswapr
  • csytri2
  • csytri2x
  • csytrs2
  • ctfsm
  • ctftri
  • ctfttp
  • ctfttr
  • ctpttf
  • ctpttr
  • ctrttf
  • ctrttp
  • cunbdb
  • cuncsd
  • dbbcsd
  • dgbequb
  • dgeequb
  • dgejsv
  • dgeqr2p
  • dgeqrfp
  • dgesvj
  • dgsvj0
  • dgsvj1
  • dlansf
  • dlapmr
  • dlarfgp
  • dlartgp
  • dlartgs
  • dlasq3
  • dlasq4
  • dlat2s
  • dorbdb
  • dorcsd
  • dpftrf
  • dpftri
  • dpftrs
  • dpoequb
  • dpstf2
  • dpstrf
  • dsfrk
  • dsposv
  • dsyconv
  • dsyequb
  • dsyswapr
  • dsytri2
  • dsytri2x
  • dsytrs2
  • dtfsm
  • dtftri
  • dtfttp
  • dtfttr
  • dtpttf
  • dtpttr
  • dtrttf
  • dtrttp
  • ilaclc
  • ilaclr
  • iladiag
  • iladlc
  • iladlr
  • ilaprec
  • ilaslc
  • ilaslr
  • ilatrans
  • ilauplo
  • ilazlc
  • ilazlr
  • sbbcsd
  • sgbequb
  • sgeequb
  • sgejsv
  • sgeqr2p
  • sgeqrfp
  • sgesvj
  • sgsvj0
  • sgsvj1
  • slansf
  • slapmr
  • slarfgp
  • slartgp
  • slartgs
  • slasq3
  • slasq4
  • sorbdb
  • sorcsd
  • spftrf
  • spftri
  • spftrs
  • spoequb
  • spstf2
  • spstrf
  • ssfrk
  • ssyconv
  • ssyequb
  • ssyswapr
  • ssytri2
  • ssytri2x
  • ssytrs2
  • stfsm
  • stftri
  • stfttp
  • stfttr
  • stpttf
  • stpttr
  • strttf
  • strttp
  • xerbla_array
  • zbbcsd
  • zcgesv
  • zcposv
  • zgbequb
  • zgeequb
  • zgeqr2p
  • zgeqrfp
  • zheequb
  • zheswapr
  • zhetri2
  • zhetri2x
  • zhetrs2
  • zhfrk
  • zlanhf
  • zlapmr
  • zlarfgp
  • zlat2c
  • zpftrf
  • zpftri
  • zpftrs
  • zpoequb
  • zpstf2
  • zpstrf
  • zsyconv
  • zsyequb
  • zsyswapr
  • zsytri2
  • zsytri2x
  • zsytrs2
  • ztfsm
  • ztftri
  • ztfttp
  • ztfttr
  • ztpttf
  • ztpttr
  • ztrttf
  • ztrttp
  • zunbdb
  • zuncsd

8000

@codecov-io
Copy link
@@            master   #6051   diff @@
======================================
  Files          238     238       
  Stmts        43908   43908       
  Branches      8233    8233       
  Methods          0       0       
======================================
  Hit          34336   34336       
  Partial       2604    2604       
  Missed        6968    6968       

Review entire Coverage Diff as of 209c279

Powered by Codecov. Updated on successful CI builds.

@pv
Copy link
Member
pv commented Apr 10, 2016

What does OSX Accelerate provide?

@insertinterestingnamehere
Copy link
Member Author

Hmm. It appears that, as of OSX 10.10, it still only provides 3.2.1. Since that was the last LAPACK version to support CLAPACK, I don't know if they have any plans to update.
There's some inherent tension between using an up-to-date LAPACK and supporting the CLAPACK interface. I'm not sure what the best resolution is though.

@sturlamolden
Copy link
Contributor

The only option for Accelerate would be to ship and build LAPACK 3.3.1 against the BLAS in Accelerate. It is basically just a bunch of Fortran files we can build as a library. No special build process is needed. It will incur a small performance hit though. (Albeit not much worse than what we get for ATLAS and OpenBLAS.)

@insertinterestingnamehere
Copy link
Member Author

Yep. In general, I see three ways forward here:

  • Leave the minimum at 3.2.1 indefinitely
  • Drop support for Accelerate
  • Build a more recent LAPACK from source with our CBLAS ABI wrappers.

None of these options are at all good. Dropping support for Accelerate seems like the "least bad" option to me personally, but others are very likely to disagree.

@sturlamolden
Copy link
Contributor

Accelerate makes it very easy to build SciPy on OSX. Dropping it seems like a bad idea, at least I would object. If I have to mess with ATLAS again, chances are I would not bother to contribute. It would also set back the performance of free SciPy builds tremendously.

The part of Accelerate we really need is BLAS. If we do a real house cleaning, we could build something like libVecFort, which would overshadow most of BLAS and (in our case) all of LAPACK, and we could even do away with the ABI wrappers.

@sturlamolden
Copy link
Contributor

My suggestion would then be a forth option, not on your list.

@sturlamolden
Copy link
Contributor
  • On Accelerate, overshadow some of BLAS like libVecFort and our sgemv fix, overshadow all of LAPACK.

@matthew-brett
Copy link
Contributor

It would be a shame to make it difficult to compile scipy with Accelerate.

First - that is by far the easiest way to get BLAS / LAPACK on Mac.

Second - some people want Accelerate specifically - see : http://vtk.1045678.n5.nabble.com/VTK-and-Python-on-OS-X-El-Capitan-tp5734265p5734280.html

@pv pv added needs-decision Items that need further discussion before they are merged or closed scipy.linalg labels Apr 30, 2016
@rgommers
Copy link
Member
rgommers commented Jun 12, 2016

Dropping support for Accelerate would be quite painful, doesn't seem worth it. Here's another suggestion:

  • require 3.3.1 except when Accelerate is used
  • ship the sources from reference LAPACK for the added routines between 3.2.1 and 3.3.1
  • if Accelerate is detected, then build just the missing routines separately

@sturlamolden this seems a bit different from what you suggest, although I don't completely understand your libVecFort idea.

@sturlamolden
Copy link
Contributor

@rgommers Your auggestion would work too, but it might require a BLAS with gfortran ABI (depending on which BLAS function the added routines will call). Your suggestion certainly means shipping less code than mine.

What I suggested is when Accelerate is present:

  • Use Accelerate to build a BLAS with gfortran ABI
  • Build LAPACK on top of this
  • Drop the g77 ABI wrappers from SciPy

This requires us to use a feature in OSX called DLL overshadowing. This is what we use to correct SGEMV and what libVecFort use to create a BLAS with gfortran ABI on top of Accelerate.

I would also like to point out that libVecFort already does most of this. So if their license allows it we could just use their code.

8000

@sturlamolden
Copy link
Contributor

@rgommers If we are going to use your suggestion, we have to be careful to compile the missing parts of LAPACK with g77 ABI, and then make sure they are exposed to SciPy with gfortran ABI.

@rgommers
Copy link
Member

I would also like to point out that libVecFort already does most of this. So if their license allows it we could just use their code.

vecLibFort (https://github.com/mcg1969/vecLibFort) not libVecFort - took a bit of effort to find:) It uses the Boost license, which is BSD-compatible.

@pv
Copy link
Member
pv commented Jun 12, 2016

I think we can fairly easily bundle the missing routines, for use with Accelerate.

@rgommers
Copy link
Member

Of the 3 ways to use vecLibFort, the static linking one seems most appropriate. It's not that much code, so could be a decent option.

@pv
Copy link
Member
pv commented Jun 12, 2016

I'm not sure if we need vecLibFort --- afaics, it is similar to what we currently do, with the difference that it shadows the symbols rather than renaming them. Namely, remember that we have patched our fortran source codes with replaced names for the functions.

Since MKL also appears to need g77 abi wrappers, if we switch to shadowing (and revert the replaced names in the fortran sources), we need to verify that the way we shadow works on all supported platforms, not only osx.

@pv
Copy link
Member
pv commented Jun 12, 2016

However, since the deprecated/new lapack routines afaics are just subroutines, they are abi compatible as-is. So afaics, the discussion about abi wrappers is not directly relevant for including the missing lapack routines. (Provided we make the corresponding symbol renames in the lapack sources.)

@sturlamolden
Copy link
Contributor

Ok, but we need to compile the missing routines with -ff2c in case they happen to call functions like SDOT in Accelerate.

@sturlamolden
Copy link
Contributor

Sorry, we can of course patch the lapack sources.

@pv
Copy link
Member
pv commented Jun 12, 2016

Yes, we are currently using the patching approach everywhere, so we'd need to do that also to the new LAPACK sources.
We can of course change the way we deal with the abi issue, but that's probably more work.

@pv
Copy link
Member
pv commented Jun 12, 2016

For ARPACK, the necessary patching incantation is here: https://github.com/scipy/scipy/blob/master/scipy/sparse/linalg/eigen/arpack/ARPACK/README.scipy#L14

@sturlamolden
Copy link
Contributor

I was not aware that we are currently patching all our Fortran sources. Let's just continue with that, although it is more tedious in the long run.

@insertinterestingnamehere
Copy link
Member Author

Thanks for reviving this. I'll go ahead and start updating it to include the missing routines.
Is mixing newer LAPACK sources with functions built as a part of an older LAPACK library generally a safe approach? Some of the newer routines may rely on stability fixes in their dependencies. That said, it seems like most new things in LAPACK come packaged as entirely new routines, so that may not be a concern.

generating script to no longer exclude functions not available with a
uniform interface before version 3.3.1.
BLAS/LAPACK API. The line endings aren't handled automatically by GIT
since the files are currently flagged as binary. Most compilers can handle
both types of line endings, so it's not a huge issue. This makes sure that
the autogeneration script can also handle both types of line endings.
wrappers for Cython BLAS/LAPACK API. This is needed for some of the
routines included in LAPACK releases 3.3.1 and up.
specifiers for different arguments used by the subroutine wrappers for
Fortran functions (as opposed to subroutines) that are included in the
Cython BLAS/LAPACK API. These special cases allow the wrappers to be
generated for LAPACK version 3.3.1 as opposed to LAPACK 3.1.0.
signature generating script for Cython BLAS/LAPACK API.
@cgohlke
Copy link
Contributor
cgohlke commented Sep 14, 2017

Please consider LAPACK <= 3.4.0 as long as building Scipy for Python 2.7 on Windows with Visual Studio 2008, Intel Fortran compilers, and Intel MKL is supported.
The last version of the Intel compiler suite which is compatible with Visual Studio 2008 is "Composer XE 2013 SP1". It includes MKL 11.1.4 and LAPACK 3.4.0 according to the header files on my system.

@rgommers
Copy link
Member

Thanks @cgohlke, I didn't think about that! 3.4.0 it is then, for a couple more years.

@rgommers
Copy link
Member

But many of these concerns can be eliminated if those users stick to their SciPy versions
...
So I have the feeling that we are protecting users that don't exist.

That's a common argument made when discussing decisions like this, and it's hard to prove or disprove. @GaelVaroquaux lectures us regularly on users in labs he's worked in that are stuck on clusters with old Linux distros though, so they do exist:)

Anyway, moot argument now that @cgohlke pointed out the MKL + Python 2.7 problem I think. We can't not support that combo, so can only go past LAPACK 3.4.0 once we drop Python 2.7.

@ilayn
Copy link
Member
ilayn commented Sep 15, 2017

@GaelVaroquaux lectures us regularly on users in labs he's worked in that are stuck on clusters with old Linux distros though, so they do exist:)

I'm not saying that people stuck in legacy machines don't exist. I'm just saying that they won't be able to upgrade in any case. Hence my argument.

@cgohlke Does it help to use CMAKE system introduced in 3.4.0 for your wheels? Because 3.4.1 and 3.4.2 are bug fix releases. You can find additional details here

@pv
Copy link
Member
pv commented Sep 15, 2017 via email

@insertinterestingnamehere
Copy link
Member Author

Yah, as I understand it the issue with newer versions of MKL is having to use a different C standard library than the one linked to the Python 2.7 binaries. It's probably possible to get the older versions of the Intel compilers to build against a newer MKL and then rely on the fact that BLAS/LAPACK don't let resources cross their interface boundaries, but I'm not sure how much of a pain that'd be to set up.

@rgommers
Copy link
Member

I'm just saying that they won't be able to upgrade in any case

Still part of a commonly heard argument, and not really the case. It's fairly straightforward to compile SciPy on Linux, and that doesn't need admin rights.

@sturlamolden
Copy link
Contributor

@rgommers If we build LAPACK on top of Accelerate (i.e. overshadow) we are left with that one bug which is also present in ATLAS.

@sturlamolden
Copy link
Contributor

Personally I am in favor of dropping support for anything but MKL and OpenBLAS.

@ilayn
Copy link
Member
ilayn commented Sep 16, 2017

Still part of a commonly heard argument, and not really the case.

Well there must be a reason for it to be common. I don't see the point of trying to be up-to-date on a legacy system. Either you are stuck or you update your system. Out of our own clusters in Eindhoven we are not even allowed to adjust the time let alone building something.

@rgommers
Copy link
Member

I've added this in the 1.0.0 release notes:

This is also the last release to support LAPACK 3.1.x - 3.3.x.  Moving the
lowest supported LAPACK version to >3.2.x was long blocked by Apple Accelerate
providing the LAPACK 3.2.1 API.  We have decided that it's time to either drop
Accelerate or, if there is enough interest, provide shims for functions added
in more recent LAPACK versions so it can still be used.

Will now move this issue to the 1.1.0 milestone.

@rgommers
Copy link
Member

This PR needs an update, but can now be merged in principle. Could be extended as well, to LAPACK 3.4.0 (not higher, due to MKL + py27, see comments higher up). We're going to branch 1.1.x in the near future, can be either before or after that. @insertinterestingnamehere are you still interested in updating this PR?

@insertinterestingnamehere
Copy link
Member Author

Definitely still interested. I'll see if I can get the ball rolling on this again.

@rgommers
Copy link
Member

Great!

@ilayn
Copy link
Member
ilayn commented Mar 27, 2018

@insertinterestingnamehere If you need an extra hand for wrapping LAPACK routines let me know please :)

F438

@insertinterestingnamehere
Copy link
Member Author

@ilayn the wrappers should be autogenerated once I update the script. That's not so bad. I could really use help getting the ci tests updated for osx and removing the accelerate specific code though. I can do a lot of that, but I don't have an osx machine to test with locally so it'll be a slow process waiting for builds to finish. I'm planning on improving the wrapper updates here in a separate PR, but things like removing the osx ci fixes could probably be done separately anyway.

@matthew-brett
Copy link
Contributor

@insertinterestingnamehere - I am sure we can find you an OSX machine to log into, if that would help? Let me know via email?

@insertinterestingnamehere
Copy link
Member Author

@matthew-brett sent. Do you have a current download link for OpenBLAS on OSX as well?

@matthew-brett
Copy link
Contributor

@insertinterestingnamehere
Copy link
Member Author

Awesome, thanks for the link. I'll try pointing the SciPy OSX CI tests there.

@insertinterestingnamehere
Copy link
Member Author

Okay, I've posted an updated version of the work here in #8670. Changes for OSX are still in progress, but it's a start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-work Items that are pending response from the author scipy.linalg
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants
0