Skip to content
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

Patch ldflags and libs in GCC_compile under windows #947

Merged
merged 1 commit into from
May 7, 2022

Conversation

lucianopaz
Copy link
Contributor

Closes #944

On windows systems, the dll or lib libraries don't follow gcc's library naming convention, which means that their file name doesn't have the lib prefix (e.g. libmkl_core.dll). For this reason, gcc's library search fails to find these dynamic link libraries or static libs. An undesired consequence was that aesara (and old theano) was not able to set the correct blas__ldflags to link with mkl, even if the library had been correctly installed.

This PR introduces two GCC_compiler static methods that patch the libs or ldflags that are used during compilation. The static methods specifically target dll and lib files. They search for the library files in the provided library directories, and if a dll or lib is found, the ldflag is set to the absolute path that points to the dll or lib file. As a sidenote, dlls are preferred over libs.

As a consequence, the normal unix-like ldflags will be patched to work in windows as they do in unix. Thanks to this, aesara is now able to set the correct ldflags in windows to link to mkl installations.

@lucianopaz
Copy link
Contributor Author

Does anyone know how to fix the unreachable code error from mypy? That code only runs on windows, and mypy doesn’t complain when I run it on windows.

@lucianopaz
Copy link
Contributor Author

It looks like mypy is failing because of this bug

@brandonwillard
Copy link
Member

brandonwillard commented May 5, 2022

It looks like mypy is failing because of this bug

It looks more like this one: python/mypy#5678. (Not the generators/yield parts, but the way Mypy is handing sys.platform.) Actually, they appear to both be fundamentally the same problem.

In general, it looks like Mypy is taking the value of sys.platform too literally.

Anyway, you can add a # type: ignore there.

@lucianopaz
Copy link
Contributor Author

The failing test (tests/sparse/sandbox/test_sp.py::TestSP::test_maxpool) passes locally. Maybe the test is flaky?

@brandonwillard
Copy link
Member

The failing test (tests/sparse/sandbox/test_sp.py::TestSP::test_maxpool) passes locally. Maybe the test is flaky?

Yeah, that looks like a bad, unseeded test.

@codecov
Copy link

codecov bot commented May 6, 2022

Codecov Report

Merging #947 (0dc06ef) into main (b60cf72) will increase coverage by 0.06%.
The diff coverage is 97.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #947      +/-   ##
==========================================
+ Coverage   78.92%   78.98%   +0.06%     
==========================================
  Files         152      152              
  Lines       47701    47795      +94     
  Branches    10862    10888      +26     
==========================================
+ Hits        37649    37753     +104     
+ Misses       7550     7542       -8     
+ Partials     2502     2500       -2     
Impacted Files Coverage Δ
aesara/link/c/cmodule.py 52.40% <97.22%> (+1.33%) ⬆️
aesara/tensor/elemwise.py 88.17% <0.00%> (-0.27%) ⬇️
aesara/compile/function/types.py 79.91% <0.00%> (-0.14%) ⬇️
aesara/scalar/basic.py 79.05% <0.00%> (ø)
aesara/scan/op.py 84.84% <0.00%> (+0.24%) ⬆️
aesara/tensor/elemwise_cgen.py 95.74% <0.00%> (+0.29%) ⬆️
aesara/printing.py 51.66% <0.00%> (+3.07%) ⬆️

aesara/link/c/cmodule.py Outdated Show resolved Hide resolved
@hectormz
Copy link
Contributor

hectormz commented May 7, 2022

Looking forward to this PR! Was just scratching my head about this on Windows. Thanks @lucianopaz

@lucianopaz
Copy link
Contributor Author

Codecov seems to be linking the old commit instead of the new one

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

Successfully merging this pull request may close these issues.

Aesara fails to set the correct default blas ldflags to link with MKL on windows
3 participants