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

release the GIL in denoise_tv_bregman and denoise_bilateral #5400

Merged
merged 1 commit into from
May 18, 2021

Conversation

grlee77
Copy link
Contributor

@grlee77 grlee77 commented May 17, 2021

Description

I tried using apply_parallel with the various denoise_* functions in skimage.restoration. Most showed a substantial speedup, but denoise_tv_bregman and denoise_bilateral showed worse performance when calling with apply_parallel than without. This turns out to be because the GIL is not being released by these two functions.

As in #5399, this PR just adds a with nogil context block into each of these functions so the GIL will be released, allowing multithreading. I confirmed locally that this leads to the expected improvement.

The somewhat large diff is misleading as nearly all line differences are just the change in indentation.

Timing

For example for denoise_tv_bregman on an input of shape (2048, 4096) it takes:
normal call (single thread): 2.33 s
call with apply_parallel (prior to this PR, GIL not released): 3.2 s
call with apply_parallel (after this PR): 0.53 s

The result for denoise_bilateral is very similar.

measured approximately 6x better performance on a 10-core system  with
util.apply_parallel after this change
@alexdesiqueira alexdesiqueira merged commit 20dfde0 into scikit-image:main May 18, 2021
@alexdesiqueira
Copy link
Member

Thank you @grlee77!

@grlee77 grlee77 deleted the denoise_nogil branch July 8, 2021 20:39
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.

None yet

3 participants