-
-
Notifications
You must be signed in to change notification settings - Fork 82
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
allow threading backend to be replaced by caller #81
Conversation
Thanks for this cool contribution! So I have had a look into this and it looks like it is quite unobstrusive with the exisitng API; also, all tests are passing, which makes me confident about it. I'd like to see some benchmarks on how this works in real life (i.e. in combination with Julia's partr), but in principle I am +1 on merging this. Just tell me when this would be ready. |
Thanks @FrancescAlted! I just updated the test suite so that Travis runs all the tests with both native threads and a dummy (serial) callback backend (controlled by a It looks like the callback code is working, so I will now work on updating the Julia Blosc.jl package to use blosc2 and let you know what the scaling looks like when I enable a partr backend. |
I just tried it with the Julia 1.3 So, it looks good to me to merge whenever you are ready. |
Thanks @stevengj ! |
This PR adds a new function
blosc_set_threads_callback
that allows the caller to register a callback in order to change the threading backend at runtime — instead of spawning its own threads and passing work to them with a mutex, Blosc will pass an array of work (an array ofthread_context
) to the callback, which can execute the work in serial or in parallel using whatever mechanism it wants.Motivation: this allows Blosc threading to be composable with caller multithreading, instead of having Blosc and the caller fight over the same CPUs. In particular, this enables Blosc threading to be composable with:
The design and implementation is very similar to the new pluggable threading backend for FFTW (FFTW/fftw3#175), which worked out very well for us. Aside from a trivial refactoring of the
t_blosc
function, the actual new code seems pretty minimal — only a couple of dozen lines, with a practical overhead of a singleif
statement in theparallel_blosc
function for people not using this feature.Marking it as a WIP since I haven't tested it yet other than checking that it compiles, but I wanted to get some early feedback. (Moved from Blosc/c-blosc#276)