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

Instructions for Windows 10 users MKL / OpenBLAS properly formatted #1966

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mattslezak-shell
Copy link

Instructions given so OpenMP will work on Windows 10 with both MKL and OpenBLAS.

Instructions given so OpenMP will work on Windows 10 with both MKL and OpenBLAS.

On Windows, the Pythran configuration file is in:
``[python]/Lib/site-packages/pythran/pythran-win32.cfg``

Choose a reason for hiding this comment

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

I think convention are to use <python_prefix> here to make it clear that it needs to be adapted.

README.rst Outdated
On Windows, the Pythran configuration file is in:
``[python]/Lib/site-packages/pythran/pythran-win32.cfg``

How you set this up will depend on if you are using an ``Intel MKL`` linked NumPy/SciPy (such as in the Anaconda3 distribution), or if you're using pip installed NumPy/SciPy (which is linked to ``OpenBLAS``). There are some interesting differences in the setup files for each distribution - note the purpose here is to use the right OpenMP library:

Choose a reason for hiding this comment

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

nit: s/will depend/depends/

CC=clang-cl.exe
CXX=clang-cl.exe

In some cases, using ``Intel MKL`` will require a substitute ``cblas.h`` which isn't present with MKL. This is not an elegant solution -

Choose a reason for hiding this comment

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

s/will require/requires/

Note with the ``OpenBLAS`` package, you need to: ``pip install pythran-openblas`` so the library can be linked properly.


Using the LLVM linker (optional):

Choose a reason for hiding this comment

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

I think this is more than hacky, we cannot suggest to modify system files here :-) This is worth a configuration entry in the pythran config file though.

I'm curious about the motivation for using lld here?

@mattslezak-shell
Copy link
Author

mattslezak-shell commented Feb 24, 2022

Change whatever you feel is appropriate. I did notice on a very large project with OpenBLAS I had to change some settings around to get OpenMP working like this:

library_dirs='C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\lib\x64'
ldflags=\libomp.lib

So link the standard Windows Visual Studio OpenMP library instead of the LLVM one. Why this works on larger projects (100 lines of code) and not the LLVM one I have no idea. So rather than figure it out, I'd just provide it as an alternative if the first method fails... Someone smarter than me may be able to figure out why, although I imagine most users just want config settings to plug in to get their module built and could care less what happens behind the scenes, as long as it's using OpenMP.

@mattslezak-shell
Copy link
Author

I found that some random modules in my project were actually loading the libiomp5md.lib, causing my interpreter to crash when I tried to link libomp.lib in my Pythran modules. Note these are actually the same OpenMP files, but having both loaded into an environment at once will cause a crash (Windows can't tell they are the same, so multiple OpenMP DLLs loaded causes erratic behavior, OpenMP crashes the kernel). So I found a workaround for those that already installed the Intel OneAPI Intel MKL library by modifying the pythran-win32.cfg file as such:

library_dirs='C:\Program Files (x86)\Intel\oneAPI\compiler\latest\windows\compiler\lib\intel64_win'
ldflags=\libiomp5md.lib

My original instructions only showed how to link libomp.lib so this is how you go about linking the other OpenMP library. If I need to update the documentation let me know and I will when I get a chance.

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

Successfully merging this pull request may close these issues.

2 participants