numba
numba copied to clipboard
Fix build for mingw toolchain
Many thanks for the PR! Could you please provide some details about the environment / setup in which this patch is useful? E.g. how is MinGW installed, how was LLVM / llvmlite setup, what versions of tools and Numba dependencies are in use?
(Basically - how would one get set up to test these fixes?)
I am using clang in msys2/mingw-w64 environment.
- Some info about the toolchain https://www.msys2.org/docs/environments/
- llvmlite setup https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-python-llvmlite
- numba setup https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-python-numba
@Biswa96 Many thanks for the info - unfortunately none of the Numba / llvmlite maintainers are users of MinGW, so it's quite hard for us to see how to get set up to test this patch - can you provide some guidance as to how to set up an environment to test the patch please?
Understood. Let me check if I can setup any GitHub Actions for mingw environment.
Hi @Biswa96, I have a Windows machine and can try your patch. If you provide a high level description of the necessary steps, that would be helpful.
Verbose documentation can be found here https://www.msys2.org/. Here is the gist:
- Download the msys2 installer from that page and install it.
- Run
C:\msys64\clang64.exe
or the clang64 shortcut in start menu. - Update packages with
pacman -Syyu
twice. - Install required packages
pacman -S pacboy; pacboy -S git cc:p python:p python-setuptools:p
and other required dependencies for this project. The:p
is necessary because it is translated intomingw-w64-clang64-x86_64-
prefix. - Make sure there is no other python in
$PATH
.which python.exe
will show/clang64/bin/python.exe
. - Now do the regular development steps.
- This project was built with tbb disabled, see pkgbuild.
Thanks, @Biswa96. I'll try it in the upcoming days.
Hi @Biswa96, thanks for the info. I can confirm your patch works and I was able to successfully build Numba with it. I also tried to build Numba main branch, which failed because it could not build omppool.o
.
Below I will copy the steps I did for the "regular development steps" to compile Numba on Windows with msys2:
-
pacboy -S python-llvmlite:p python-numpy:p openmp:p
- Since llvmlite on msys2 is old (v0.38), I had to manually disable the
_ensure_llvm()
check onnumba/__init__.py
- Build numba with
python setup.py build_ext --inplace
- Tried a simple test case:
$ cat file.py
from numba import njit
import numpy as np
@njit
def foo(a):
return np.arange(a)
print(foo(3))
$ python file.py
[0, 1, 2]
If it is of any help, I'll post the output of numba -s
here as well:
$ python -m numba -s
System info:
--------------------------------------------------------------------------------
__Time Stamp__
Report started (local time) : 2022-08-05 01:16:47.760237
UTC start time : 2022-08-05 04:16:47.760237
Running time (s) : 0.510999
__Hardware Information__
Machine : AMD64
CPU Name : znver3
CPU Count : 24
Number of accessible CPUs : ?
List of accessible CPUs cores : ?
CFS Restrictions (CPUs worth of runtime) : None
CPU Features : 64bit adx aes avx avx2 bmi bmi2
clflushopt clwb clzero cmov crc32
cx16 cx8 f16c fma fsgsbase fxsr
invpcid lzcnt mmx movbe mwaitx
pclmul popcnt prfchw rdpid rdrnd
rdseed sahf sha shstk sse sse2
sse3 sse4.1 sse4.2 sse4a ssse3
vaes vpclmulqdq wbnoinvd xsave
xsavec xsaveopt xsaves
Memory Total (MB) : 59534
Memory Available (MB) : 17989
__OS Information__
Platform Name : Windows-10-10.0.22000-SP0
Platform Release : 10
OS Name : Windows
OS Version : 10.0.22000
OS Specific Version : 10 10.0.22000 SP0 Multiprocessor Free
Libc Version : ?
__Python Information__
Python Compiler : GCC Clang 14.0.4 64 bit (AMD64)
Python Implementation : CPython
Python Version : 3.10.5
Python Locale : en_US.cp1252
__Numba Toolchain Versions__
Numba Version : 0.57.0dev0+155.gee52198b7.dirty
llvmlite Version : 0.38.1
__LLVM Information__
LLVM Version : 14.0.4
__CUDA Information__
CUDA Device Initialized : True
CUDA Driver Version : 11.6
CUDA Runtime Version : ?
CUDA NVIDIA Bindings Available : ?
CUDA NVIDIA Bindings In Use : ?
CUDA Detect Output:
Found 1 CUDA devices
id 0 b'NVIDIA GeForce RTX 2060' [SUPPORTED]
Compute Capability: 7.5
PCI Device ID: 0
PCI Bus ID: 7
UUID: GPU-38147fdc-0f91-fc91-a84a-e35edc3de1da
Watchdog: Enabled
Compute Mode: WDDM
FP32/FP64 Performance Ratio: 32
Summary:
1/1 devices are supported
CUDA Libraries Test Output:
None
__NumPy Information__
NumPy Version : 1.23.1
NumPy Supported SIMD features : ('MMX', 'SSE', 'SSE2', 'SSE3', 'SSSE3', 'SSE41', 'POPCNT', 'SSE42', 'AVX', 'F16C', 'FMA3', 'AVX2')
NumPy Supported SIMD dispatch : ('SSSE3', 'SSE41', 'POPCNT', 'SSE42', 'AVX', 'F16C', 'FMA3', 'AVX2', 'AVX512F', 'AVX512CD', 'AVX512_KNL', 'AVX512_SKX', 'AVX512_CLX', 'AVX512_CNL', 'AVX512_ICL')
NumPy Supported SIMD baseline : ('SSE', 'SSE2', 'SSE3')
NumPy AVX512_SKX support detected : False
__SVML Information__
SVML State, config.USING_SVML : False
SVML Library Loaded : False
llvmlite Using SVML Patched LLVM : False
SVML Operational : False
__Threading Layer Information__
TBB Threading Layer Available : False
+--> Disabled due to Unknown import problem.
OpenMP Threading Layer Available : True
+-->Vendor: Intel
Workqueue Threading Layer Available : True
+-->Workqueue imported successfully.
__Numba Environment Variable Information__
None found.
__Conda Information__
Conda not available.
__Installed Packages__
Package Version
---------------------- -------
distlib 0.3.5
llvmlite 0.38.1
numpy 1.23.1
pip 22.2.1
python-distutils-extra 2.39
setuptools 63.2.0
No errors reported.
__Warning log__
Warning (cuda): Probing CUDA failed (device and driver present, runtime problem?)
(cuda) <class 'FileNotFoundError'>: [WinError 3] The system cannot find the path specified: 'C:/msys64/clang64/DLLs'
Warning: Conda not available.
Error was [WinError 2] The system cannot find the file specified
Warning (psutil): psutil cannot be imported. For more accuracy, consider installing it.
--------------------------------------------------------------------------------
If requested, please copy and paste the information between
the dashed (----) lines, or from a given specific section as
appropriate.
=============================================================
IMPORTANT: Please ensure that you are happy with sharing the
contents of the information present, any information that you
wish to keep private you should remove before sharing.
=============================================================
cc @esc
mingw is not an entirely different "platform". In simple terms,
- The first commit applies the same compiler flags from Linux to Windows.
- The second commit removes the misconception that
_MSC_VER
means Windows platform._WIN32
should be used to check the target OS.
I ran this on the Anaconda build farm and the build was all green (numba_smoketest_cpu_yaml_119
).