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
option nogil=True not required for ufuncs and gufuncs #6445
Conversation
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.
CUDA ufuncs don't release the GIL, for various reasons (some Python code needed around to setup arguments, kernel launch asynchrony, etc.). When trying to use nogil=True
an error is produced. For example:
@vectorize(nogil=True, target='cuda')
def f(x, y):
return x + y
Gives:
KeyError: "cuda vectorize target does not support option: 'nogil'"
This is all fine with the functionality in this PR: However, I think the message in the warning is a little misleading - perhaps "ufuncs and gufuncs always release the GIL with the CPU target" would be more accurate?
Thanks for the review, I have modified the warning. |
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.
Thanks for the PR, just a couple of minor things to resolve else good to go! Thanks again!
warnings.warn("nogil option is not required, ufuncs and gufuncs " | ||
"always releases GIL for CPU target") |
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.
Suggest using numba.errors.NumbaWarning
as the warning category such that it's easier for users to filter out things from Numba.
warnings.warn("nogil option is not required, ufuncs and gufuncs " | ||
"always releases GIL for CPU target") |
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.
warnings.warn("nogil option is not required, ufuncs and gufuncs " | |
"always releases GIL for CPU target") | |
warnings.warn("The 'nogil' option is not required, ufuncs and gufuncs " | |
"always release the GIL on the CPU target") |
def test_warning_vectorize_with_nogil(self): | ||
@vectorize(nogil=True) |
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.
Would be good to check guvectorize
as well given the error message mentions it?
@pradkrish just enquiring about the state of this PR, where is it at? |
This pull request is marked as stale as it has had no activity in the past 3 months. Please respond to this comment if you're still interested in working on this. Many thanks! |
Closes #1317
nogil=True option is not required for ufuncs and gufuncs. Print a UserWarning if it is provided.