-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
ENH: enable OpenBLAS on windows. #9645
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
@charris Is pytest supported? |
|
||
os: Visual Studio 2015 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still want to test MSVC as well, it needs to stay working. So instead of removing it all, I suggest to use a build matrix with a mix of the two build configs (without increasing the total number of builds).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which MSVC are you concerned about? This configuration should test 2008, 2010, and 2015. The "os" has nothing to do with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ralf - I'm guessing you mean a lapack-lite build, without OpenBLAS?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I didn't mean lapack-lite, that's okay to only test on Linux I think. The install
and build_script
part here explicitly add MINGW
to the path and in the whole file there are only references to Cygwin and MinGW. So if MSVC is still being used, it's very much non-obvious (plus it's unclear what the purpose of the MinGW stuff is).
So either something is wrong (like MSVC being dropped) or this needs a lot of comments explaining what is going on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MinGW is used to compile the OpenBLAS library. MSVC is used to compile everything else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC, all the compilers are installed in the appveyor VM regardless of this setting, and Python distutils generally finds MSVC based on registry entries rather than PATH.
If present, MSVC is used by default over mingw C compilers, even if the latter is on PATH.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's my understanding too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pv @matthew-brett not sure if you're arguing against including more documentation or not. My comment is not particular to the line os: Visual Studio 2015
. There's a lot of opaque stuff in this PR that simply needs explaining.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I'm just explaining why it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, more documentation would be good.
I hate to be annoying, but I have previously done the same work in the windows-wheel-builder repo - here's a PR : numpy/windows-wheel-builder#3 in case it's helpful.
So we have |
Would it be okay to xfail the three failing f2py tests since there is no way that they could have been run before? |
@xoviat We don't yet support pytest. |
@charris Let me clarify the question. There are additional tests run on this pull request because numpy.distutils is more capable now after my previous gfortran PR with gfortran on the PATH. Previously these tests were not run:
Now the are run but they fail, hence the red cross. So would it be acceptable to simply xfail these for now on windows? |
You can skip tests by adding |
The error that I receive is:
The tests apparently invoke the fortran compiler which generates a DLL that must be on the path for the generated module to work correctly. Normally this isn't a problem because the And then you have a couple Python 2.7 failures, because well, it's Python 2.7. |
Hrm...the tests that I marked should be skipped are still run. |
Nose runs setup() regardless of whether the test is marked skipped or not.
You'd probably need to add new setup() methods that raise SkipTest if to be
skipped, and otherwise call super().setup.
4.9.2017 6.29 "xoviat" <notifications@github.com> kirjoitti:
… Hrm...the tests that I marked should be skipped are still run.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#9645 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AACI5gZ8Pw8xbYBcuMSb7gkMQOd89B-Jks5se3ypgaJpZM4PLANo>
.
|
Make that KnownFailure actually -- this stuff is supposed to work also on
windows.
The issue probably is that due to the extra-dll stuff, plain modules
without __config__.py just don't work with the msvc+gfortran hack.
4.9.2017 6.29 "xoviat" <notifications@github.com> kirjoitti:
… Hrm...the tests that I marked should be skipped are still run.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#9645 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AACI5gZ8Pw8xbYBcuMSb7gkMQOd89B-Jks5se3ypgaJpZM4PLANo>
.
|
1. fail tests related to DLL load failure as they were previously untested. 2. fix have_compiler to return false on old compilers 3. xfail some tests that were not working on old Python versions.
I've updated the description; the PR should be ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The overall build config is the same as for Scipy, so I think everything is fine from implementation POV.
There are some outdated comments, and the non-f2py xfails could use extra comment.
appveyor.yml
Outdated
|
||
# Install the BLAS library | ||
# - install "openblas.lib" to PYTHON\lib | ||
# - install OpenBLAS.dll to MINGW\bin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These comments are outdated (only openblas.a is installed)
PYTHON_ARCH: 64 | ||
TEST_MODE: full | ||
|
||
- PYTHON: C:\Python27 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if the tag builds are actually needed for Numpy. The production wheels are built by a different CI config, this one is used only for integration testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think they're needed but they could be used to compare differences between the released wheels and the wheels used for testing. A major advantage of this appveyor configuration is that you can actually download the built wheels and inspect them yourself.
numpy/ma/tests/test_core.py
Outdated
@@ -3605,6 +3607,8 @@ def test_varstd(self): | |||
assert_almost_equal(np.sqrt(mXvar0[k]), | |||
mX[:, k].compressed().std()) | |||
|
|||
@dec.knownfailureif(sys.platform=='win32' and sys.version_info < (3, 6), | |||
msg='Fails on Python < 3.6') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually understand why this fails only on Windows?
If yes, best to add that to the msg= so we don't need to wonder about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, but this appears to have not been tested on the CI before. It's probably a new discovery.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I opened a new issue for this and updated the description with the issue number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I now remember these also appeared on Scipy, it's probably some issue in old MSVC CRTs.
numpy/testing/tests/test_utils.py
Outdated
@@ -263,6 +263,8 @@ def test_complex(self): | |||
self._assert_func(x, x) | |||
self._test_not_equal(x, y) | |||
|
|||
@dec.knownfailureif(sys.version_info < (3, 0), | |||
msg="Error message different on Python 2") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why wasn't this issue noticed before?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or maybe it's only on win32 (in which case there should be a platform check in the knownfailureif).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From log: https://ci.appveyor.com/project/charris/numpy/build/1.0.6743/job/b9ro4kpqo4h29ljf
AssertionError: '\nArrays are not equal\n\n(shapes (2L,), (1L, 2L) mismatch)\n x: array([1, 2])\n y: [repr failed for <matrix>: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()]' != '\nArrays are not equal\n\n(shapes (2,), (1, 2) mismatch)\n x: array([1, 2])\n y: [repr failed for <matrix>: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()]'
Probably would be simple to fix to accept also a second variant
msg2 = msg.replace("shapes (2,), (1, 2)", "shapes (2L,), (1L, 2L)")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pv To clarify, should we replace the message only on Python2 win32?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd maybe accept either one, assert_(err == msg or err == msg2, err)
.
iirc the Ls are due to the integer sizes on win32-32 so they could also appear on other plats.
@@ -68,7 +68,7 @@ def have_compiler(): | |||
try: | |||
if not compiler.initialized: | |||
compiler.initialize() # MSVC is different | |||
except DistutilsError: | |||
except (DistutilsError, ValueError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW this is because MSVC 2008 is a crappy compiler.
numpy/f2py/tests/util.py
Outdated
@@ -319,6 +319,7 @@ class F2PyTest(object): | |||
module = None | |||
module_name = None | |||
|
|||
@dec.knownfailureif(sys.platform=='win32', msg='Fails with MinGW64 Gfortran') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where would the best place be to put the comments? There are multiple tests all with the same cause.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe open an issue and just put the issue number.
Allow the error message to contain "large" arrays.
numpy/testing/tests/test_utils.py
Outdated
str(e), | ||
"\nArrays are not equal\n\n" | ||
msg = str(e) | ||
msg2 = msg.replace("shapes (2,), (1, 2)", "shapes (2L,), (1L, 2L)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arguments the other way around.
Also, the try: except: isn't necessary if you do replacement in str(e).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not thinking here; I copied the replace statement directly from the comment without looking at it myself.
@rgommers Do you have any other questions about this? |
try: | ||
self.assertEqual(msg, msg_reference) | ||
except AssertionError: | ||
self.assertEqual(msg2, msg_reference) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The try: except is not needed. You can make it simpler via msg = msg.replace(...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @xoviat, clearer already. I have put some comments for all places that are still hard to understand.
appveyor.yml
Outdated
} | ||
|
||
install: | ||
- C:\cygwin\bin\du -hs "%LOCALAPPDATA%\pip\Cache" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a comment above this line, I think something like
This `install` step only builds and installs OpenBLAS plus build/test dependencies.
SciPy itself is built with `build_script`. Cygwin is only needed for WHAT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cygwin is probably only needed for the unix tools (du, find etc) used for cleaning up the pip cache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cygwin has nothing to do with the build. This comes from experience dealing with appveyor caches.
appveyor.yml
Outdated
- C:\cygwin\bin\du -hs "%LOCALAPPDATA%\pip\Cache" | ||
|
||
on_finish: | ||
- ps: | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comment, uploads what to where? Not needed for all Appveyor scripts, so good to know why here
appveyor.yml
Outdated
mkdir dist | ||
pip wheel -v -v -v --wheel-dir=dist . | ||
|
||
ls dist -r | Foreach-Object { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be good to have a comment here, not sure what PushArtifact
does and why there's a Foreach-Object
(there should be only one wheel I think, built with pip wheel -v -v -v --wheel-dir=dist .
above?)
} Else { | ||
$OPENBLAS = $env:OPENBLAS_64 | ||
} | ||
$clnt = new-object System.Net.WebClient |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment here or above ps
would be useful. I think it's "downloads an already built OpenBLAS library from the path given by $OPENBLAS
". That build was done from repo XXX.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually don't know the repo but matthew is in charge of these builds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the comment above the ps
block.
Thanks @xoviat, all LGTM now |
I think this one's ready to merge? |
Let's give it a shot. The folks who know more about this than I do have signed off. |
Thanks @xoviat . |
Previously, #9431 allowed distutils to make use of gfortran to create fortran wrappers that worked with MSVC. For a quick review:
__config__
that includes the DLLs in the PATH.Here, we use distutils the link against the "unlinkable object" openblas.a. Distutils compiles openblas with gfortran as a DLL and then links against it. As a result of using OpenBLAS, performance restrictions on windows are addressed.
Because gfortran enables BLAS and fortran functionality, some new tests are run that were previously skipped. Some of these newly run tests fail. Such tests are marked as "known failures" on windows because they were previously untested on the CI, thus they are not regressions.