8000 Upgrade to Lapack lite 3.2.2 by eric-wieser · Pull Request #8649 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Upgrade to Lapack lite 3.2.2 #8649

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

Merged
merged 4 commits into from
Mar 26, 2017
Merged

Conversation

eric-wieser
Copy link
Member
@eric-wieser eric-wieser commented Feb 21, 2017

Implements #8376. We pick the earliest acceptable version for the bug this was aiming to fix (dgelsd does not correctly compute iwork), because each new version throws more fortran features not supported by f2c at us.

This is fully functional, but a little hacky right now.

Not sure how best to structure the commits here. Unlike the last PR, these don't stand up by themselves - but I don't really want to stick a huge generated diff in the same place as hand-written code.

@charris
Copy link
Member
charris commented Feb 21, 2017

Given the huge number of -Wparentheses warnings in the test, it would be worth disabling that warning for gcc, see http://stackoverflow.com/questions/3378560/how-to-disable-gcc-warnings-for-a-few-lines-of-code. That should be OK for generated code where human readability for review is less a factor. I'd suggest the same for other compilers, but don't know if they actually generate relevant warning by default. Or might be worth checking if there is a less stringent warning flag for the tests.

@eric-wieser
Copy link
Member Author
eric-wieser commented Feb 21, 2017

Yep, previously we used a patched f2c that added the parentheses, but that patch was lost to time, and forcing numpy developers to recompile f2c is a bit mean.

This problem was actually present in #8381 - should have made more noise there!

I'll make a quick Pr for that at some point

@charris
Copy link
Member
charris commented Feb 21, 2017

I didn't see it when I compiled on my machine with -Wall -Wstrict-prototypes. I don't think we should apply fixes throughout, but disabling the check for the generated code makes sense.

8000
@eric-wieser
Copy link
Member Author
eric-wieser commented Feb 21, 2017

Hmm, I can't get travis to show me the warnings for that build either. Perhaps it only shows warnings if any errors occur? (there is a real error hiding in the logs here)

@charris
Copy link
Member
charris commented Feb 21, 2017

I'm wondering if pip picks up CFLAGS. However, I see that you introduced a new warning in 564b7cb

numpy/core/src/multiarray/shape.c:708:39: warning: passing argument 1 of ‘check_and_adjust_axis’ from incompatible pointer type [-Wincompatible-pointer-types]

- END DO
+C DO I = M, 1, -1
+C IF( A(I, J).NE.ZERO ) EXIT
+C END DO
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a pretty bad patch, that instead of actually rewriting this code in F77 style, just says "oh, we probably didn't need this anyway". The entire set of patches is rewriting this kind of loop.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a patch here that probably better fixes this, which I should probably copy here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eric-wieser - I was very surprised that this wouldn't just convert. Trying bit with f2c (as packaged by debian testing), the problem does not seem to be the do, enddo construction, but rather the exit statement. It should not be needed to do more than replace that with a goto <end-label>.

p.s. I wish we could just compile the fortran; gfortran is a very nice compiler...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can certainly give that a go - thanks @mhvk

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, if the other patch just works, then maybe that is easier. Anyway, let me know if there are issues; I'm old enough for most of my scientific code to have been written in fortran.

@eric-wieser eric-wieser force-pushed the lapack_lite-3.2.2 branch 2 times, most recently from 8e78d20 to 15bc60a Compare March 3, 2017 02:22
@eric-wieser
Copy link
Member Author
eric-wieser commented Mar 3, 2017

There's a now-hidden conversation here about the contents of the .patch files, that I should draw attention to.

I'm pretty sure that the f2c_[dszc]_lapack.f.patch files should all be the same - any recommendations for avoiding duplicating this information? (or better yet, the duplicated hunk within f2c_lapack.f.patch)

@charris
Copy link
Member
charris commented Mar 14, 2017

@eric-wieser What is the status of this?

@eric-wieser
Copy link
Member Author
eric-wieser commented Mar 14, 2017

@charris: Fortran patches probably need work, and I haven't found the time to improve them. It's possible the bits of code in need of patching are just optimizations though, and that everything is working correctly right now.

Also, if you can thing of a tidy way to not have essentially the same patch file four times, and then one patch with the same hunk four times, that would be handy

@eric-wieser
Copy link
Member Author

@charris: Patches are fixed as recommended by @mhvk

- IF( A(I, J).NE.ZERO ) EXIT
- END DO
+ IF( A(I, J).NE.ZERO ) GOTO 10
+ 10 END DO
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is correct for the EXIT, what you have here is equivalent to the C continue, whereas you want a break, i.e., GOTO the first statement after the END DO. See https://gcc.gnu.org/onlinedocs/gcc-3.4.4/g77/CYCLE-and-EXIT.html .

Copy link
Member Author
@eric-wieser eric-wieser Mar 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the generated code, I can confirm you're correct. Darn.

@charris
Copy link
Member
charris commented Mar 25, 2017

I don't think the EXIT fixes are correct.

@eric-wieser
Copy link
Member Author

Alarming that tests didn't catch that.

@eric-wieser
Copy link
Member Author

Ok, I've added a pair of fixup commits that resolve that. If they look ok, then I'll rebase them in

The output C files in git use the LAPACK source from the LAPACK_ page, using
version 3.2.2. Unfortunately, the newer version use newer and newer FORTRAN
features that are increasingly not supported bt ``f2c``. As these are found,
the patch files need to be changed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'will need'

released version of LAPACK available at the LAPACK_ page.
The output C files in git use the LAPACK source from the LAPACK_ page, using
version 3.2.2. Unfortunately, the newer version use newer and newer FORTRAN
features that are increasingly not supported bt ``f2c``. As these are found,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'bt' <- 'by'. Maybe just one "newer"

Copy link
Member
@charris charris Mar 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So

"Unfortunately, newer versions use newer FORTRAN features ..."

@@ -107,7 +106,6 @@ doublereal dlamch_(char *cmach)


if (first) {
first = FALSE_;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any particular reason to move this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the oracle that is f2c decided to. This is generated code beyond my control

@@ -239,7 +237,6 @@ doublereal dlamch_(char *cmach)


if (first) {
first = FALSE_;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above. I think it is easier to follow setting first here, i.e., execute only the first time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And so on for the rest.

@@ -23,7 +23,7 @@
# Arguments to pass to f2c. You'll always want -A for ANSI C prototypes
# Others of interest: -a to not make variables static by default
# -C to check array subscripts
F2C_ARGS = ['-A']
F2C_ARGS = ['-A', '-Nx800']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the -N option?

Copy link
Member Author
@eric-wieser eric-wieser Mar 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something to do with function table sizes. Without it, f2c would error asking for it to be provided. It might no longer be needed now that dlapack is actually just the d functions

- IF( V( LASTV, I ).NE.ZERO ) EXIT
+ IF( V( LASTV, I ).NE.ZERO ) GO TO 35
END DO
+ 35 CONTINUE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd put the label on the next statement, but really, that is total nitpicking. This certainly works...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the whole point in CONTINUE though, right?

Did this because it makes the patch more self-contained

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, that makes sense.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, another old Fortran guy. I remember when the compiler was written in assembly, came on paper tape, and ran in several kilobytes of memory. Not only that, but a single human being could read the code and understand it.

Copy link
Contributor
@mhvk mhvk Mar 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't used paper tape, but did use punch cards... But I fear my real early programming experience was in BASIC on a PET 2001... (plus 6205 assembly...)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, different generation. The good thing about paper tape was that you could edit it with a razor blade and scotch tape 8-)

Anyway, I confess that the first computer I programmed for was one of the bigger ones in the country at that time, an IBM 360 with two megabytes of memory.

@charris
Copy link
Member
charris commented Mar 25, 2017

Patches look good, couple of other comments. Why the big increase in size? More functions or more complex code?

@eric-wieser
Copy link
Member Author

Why the big increase in size?

I think a lot of the documentation got better. Remember that we're looking at 10 years of development to LAPACK here

@eric-wieser
Copy link
Member Author
eric-wieser commented Mar 25, 2017

Should I remove the author from the README and/or add myself?

I'm not too keen on putting my email address that visible on the easily-scrapable web, but I could put a github username in that file if it helps?


Readme is fixed, and fixup commits have been squashed

This doesn't yet actually generate the files, since they would cause the diff to balloon
These are copied from the libf2c source code, which is presumably where all
the others came from
@charris
Copy link
Member
charris commented Mar 25, 2017

LGTM. Could you add something to the 1.13 release notes?

@charris
Copy link
Member
charris commented Mar 25, 2017

I think you could just add your name and a date. If anyone wants to find out more they can use git blame to track it back to the relevant commit.

@charris
Copy link
Member
charris commented Mar 25, 2017

Or you could just leave it be. Pearu's name is still in some of the f2py files as an histori D215 cal artifact even though others have worked on the source since.

Also, update authors of lapack_lite

[ci skip]
@charris charris merged commit b1c1d7c into numpy:master Mar 26, 2017
@charris
Copy link
Member
charris commented Mar 26, 2017

In it goes. Thanks Eric.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0