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

Add support for interactive threads #56

Closed
simsurace opened this issue Feb 7, 2023 · 6 comments
Closed

Add support for interactive threads #56

simsurace opened this issue Feb 7, 2023 · 6 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@simsurace
Copy link

Julia 1.9 will introduce an interactive thread pools. Maybe the interactive threads can be pinned to specific cores/cpu threads as well?

@carstenbauer
Copy link
Owner

carstenbauer commented Feb 7, 2023

Absolutely! Since these "interactive threads" aren't particularly special with respect to affinity, you can already pin them right now:

(julia +1.9 -t 2,3)

julia> using ThreadPinning

julia> [getcpuid(i) for i in 1:Threads.maxthreadid()]
5-element Vector{Int64}:
 17
 12
 14
 16
 18

julia> for i in 1:Threads.maxthreadid()
           pinthread(i, i)
       end

julia> [getcpuid(i) for i in 1:Threads.maxthreadid()]
5-element Vector{Int64}:
 1
 2
 3
 4
 5

It'd still be nice to have "proper" support for the new threadpool feature in ThreadPinning.jl (in particular in getcpuid(s), pinthread(s), and threadinfo). I've already started with this (@tspawnat works and threadinfo has a premature threadpool option) but my short sprint was halfhearted at best.

If you're willing to, please open a PR! I'd be happy to help with comments and pointers.

@carstenbauer carstenbauer added enhancement New feature or request good first issue Good for newcomers labels Feb 7, 2023
@simsurace
Copy link
Author

Funny you get 5 threads here. Any thoughts on this question on Slack?

@simsurace
Copy link
Author

JuliaLang/julia#48580

@carstenbauer
Copy link
Owner

Funny you get 5 threads here.

Note that I use Threads.maxthreadid() (rather than Threads.nthreads()). Up to the fact that, in principle, the number of Julia threads isn't strictly constant anymore in Julia 1.9 (AFAIU, the number can vary when one does parallel C/C++ interop of some kind), this is essentially equivalent to nthreads(:default) + nthreads(:interactive) and thus gives 5 as expected.

@carstenbauer
Copy link
Owner

@simsurace I've improved the thread pool support in ThreadPinning.jl a lot on the main branch. Among others, threadinfo, pinthreads, and getcpuids all have threadpool keyword arguments which can be set to :default, :interactive, or :all. Would be great if you could try this out, since I plan to tag a new release with this soon.

@simsurace
Copy link
Author

I'll probably try this again quite soon, when JuliaLang/julia#48702 has been released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants