Closed sumpfork closed 3 years ago
Thanks for the bug report. I've made some small changes to the setup.py
file now. Could you clone/download the repository and check if it works for you? (python setup.py build_ext --inplace --force
)
Works, though doesn't compile against openmp even if available, making the comment misleading: removing that code won't make the code compile against openmp on a mac.
Ok, good to know that it’s working.
I realize it doesn’t end up linking to OpenMP in macOS this way, but that’s not a big deal here, because the only functions which use OpenMP parallelization are topN (at the end, in the stage in which it argsorts each row result) and softmax predict (at the end, in the stage in which it selects according to probabilities), which for typical use-cases will save at most a few miliseconds by adding OpenMP.
Now, I’d like to have it link to OpenMP in every setup that supports it, but the issue is that it’s not possible – or at least I don’t how – to do it in a way that would work with all compiler configurations. For example, if you use gcc or icc on mac, the option -lomp
will not do the trick, and I think if you install clang and its modules by compiling them directly it wouldn’t work either. Also -lomp
I think sets the linkage to libomp
, which not every setup will have, whereas -fopenmp
will select the default one (typically libgomp
or libiomp
).
I’m open to better alternatives if you know of any, but I myself haven’t seen any other Python package with a setup.py
script that would work for all setups on macOS.
Solved as now it will run a test compile with these arguments and add openmp linkage in mac if it's installed.
I had to change a couple of things to get this compiling on Mac OS X:
extra_compile_args
member if none were specified-lomp
and preprocessor flag is differentSomething like: