-
Notifications
You must be signed in to change notification settings - Fork 9
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
Feature request: temporary pinning (with do block) ? #81
Comments
I think that such a feature would be a nice addition.
That's doable. We can simply query and store the affinity mask of each thread at the beginning and then to restore it at the end. (see |
#82 works perfectly, tested with unpinthreads() # outer setup unpinned
with_pinthreads([10]) do
# runs on the 11th CPU, as expected
@benchmark sin.(x) setup=(x = rand(10))
end
# runs on a random CPU (tested several times), as expected
@benchmark sin.(x) setup=(x = rand(10))
pinthreads([0]) # outer setup pinned to the first CPU
with_pinthreads([10]) do
# runs on the 11th CPU, as expected
@benchmark sin.(x) setup=(x = rand(10))
end
# runs on the first CPU, as expected
@benchmark sin.(x) setup=(x = rand(10)) Thanks ! |
Great, I'll tag a new release. |
BTW, @ederag, if you care about ThreadPinning.jl in Pluto, I always wanted to have nicer support for
Maybe you want to give that a try? :) |
Sorry, I'd like to help but I'm not good enough at HTML display stuff. And I do not see how to get Pluto reactive updates for mutations (see fonsp/Pluto.jl#564). Pluto people on zulip or discourse do amazing things and would probably be more helpful. |
pinthreads
is able to stabilize benchmark runs inside Pluto too, thanks !It seems to play well with the new Pluto/Malt combination.
Yet it would be nice to encapsulate a block (e.g. a benchmark) inside
pinthreads
,leaving the rest of the notebook running normally.
For instance, defining
allows
Would that be in the
ThreadPinning
package scope ?Of course it would be better to store/restore the previous thread pinning (unpinned,
:core
, ...)instead of just
unpinthreads()
, but I fail to see how to do that.The text was updated successfully, but these errors were encountered: