-
Notifications
You must be signed in to change notification settings - Fork 529
[WIP] OpenMP EMD #192
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
[WIP] OpenMP EMD #192
Conversation
Sorry for the delay in getting this started. There are things that still need to be completed before a review. In particular,
|
523a7ac
to
712b3b7
Compare
run: | | ||
# install OpenMP (via homebrew) | ||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" | ||
brew install libomp |
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.
can you also keep a macos build without openmp so we can check it works on a fresh machine too? thx
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 indeed i would keep the classical build on macosx and add a build/test with openmp
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, I was planning on doing this (just after I fixed the issues with the full build)
@agramfort @rflamary Some insight/pointers would be appreciated. Although the package is being installed properly on all platforms (with correct flags it seems), it is for some reason not recognizing NOTE: The tests need to be modified to address the new changes, hence why some tests fail. |
Looks to me as if it builds bu do not link openmp. There is an option for the cython builder called |
Thanks for the quick reply. I'll give that a try! |
did you look how scikit-learn does it ? https://github.com/scikit-learn/scikit-learn/blob/master/setup.py#L137 it took a lot of time to @jeremiedbb to make it work on scikit-learn. |
@agramfort I did look into it, but would it be premature optimization? I say this because the implementation in scipy looks like it is meant to handle many submodules that contain C/C++ code to compile properly. Although I agree that approach is better (i.e. cleaner and more robust for future additions of C/C++ submodule(s)), we currently only have one module where C/C++ code is being used, hence why I thought it might have been easier to define how to cythonize the EMD module in Alternatively, since we have to check if OpenMP is supported within a user's system (so that we can run EMD computation with/without OpenMP support), we may have to end up mimicking how scipy is approaching this since the (a) compile flags would change accordingly. and (b) the cythonization would change depending on whether the system could support OpenMP. |
@ayushkarnawat are you suggesting that making sure it works on systems with or without openmp support automatically is premature optimization? |
Perhaps I was not clear enough. What I meant to say was the way scipy handles checking if OpenMP is supported in the the
I agree that (1) should also be done in POT since checking if the user's system supports OpenMP is important (as mentioned previously). This allows us to add the proper openmp linker to the compiler so that the generated What I meant by "premature optimization" was concerning (2). This is because it seems like it was meant to support cythonization of multiple C++ src files contained within different submodules, which we (currently) do not have with POT. To be pedantic, I don't think we need to define the cythonization in the fashion that scipy does it. I guess we simply can forgo that portion, if you agree. Let me know what you think and if this makes sense. |
as long as we check if a user's system supports OpenMP (through a small
test program)
and allow POT to work on a system without openmp it's fine for me.
… |
Thank you @ayushkarnawat for this work, You have motivated us to look into openMP also. we have another PR that has done the OpenMP implementation (actually both single thread and openMP) and currently build on all OS in #260 so I will close this PR. |
Very cool, apologies for not finishing this earlier; got busy with other things and sort of forgot about it. I'm happy to actually seeing this actually being done. :) |
Types of changes
Motivation and context / Related issue
Python 3.8 no longer supports forking a process (rather it spawns it on a new thread) on MacOS. In ideal conditions -- that is when the code can be trivially pickled to be sent to the individual threads -- this doesn't lead to any problems. However, cython code (which allows the CPP code to be called from within python) cannot be easily pickled. As such, to avoid picking errors and to fix the problems associated with forking a process on windows as well, it is better to use parallel processing in the core CPP code (w/ OpenMP). Resolves #187.
How has this been tested (if it applies)
Checklist