Readily pin Julia threads of multithreaded and distributed Julia applications to CPU-threads
Documentation | Build Status | Quality |
---|---|---|
Most notably, ThreadPinning.jl allows you
- to pin Julia threads to specific CPU-threads ("hardware threads") with
pinthreads
and - to obtain a visual overview of the system topology with
threadinfo
.
There is dedicated support for pinning Julia threads in distributed Julia applications that use MPI.jl or Distributed.jl.
Check out my lightning talk that I gave as part of JuliaCon 2023 at MIT.
julia> using ThreadPinning
julia> pinthreads(:cores)
julia> threadinfo(; color=false)
Hostname: PerlmutterComputeNode
CPU(s): 2 x AMD EPYC 7763 64-Core Processor
CPU target: znver3
Cores: 128 (256 CPU-threads due to 2-way SMT)
NUMA domains: 8 (16 cores each)
Julia threads: 16
CPU socket 1
0,_, 1,_, 2,_, 3,_, 4,_, 5,_, 6,_, 7,_,
8,_, 9,_, 10,_, 11,_, 12,_, 13,_, 14,_, 15,_,
_,_, _,_, _,_, _,_, _,_, _,_, _,_, _,_,
_,_, _,_, _,_, _,_, _,_, _,_, _,_, _,_,
_,_, _,_, _,_, _,_, _,_, _,_, _,_, _,_,
_,_, _,_, _,_, _,_, _,_, _,_, _,_, _,_,
_,_, _,_, _,_, _,_, _,_, _,_, _,_, _,_,
_,_, _,_, _,_, _,_, _,_, _,_, _,_, _,_
CPU socket 2
_,_, _,_, _,_, _,_, _,_, _,_, _,_, _,_,
_,_, _,_, _,_, _,_, _,_, _,_, _,_, _,_,
_,_, _,_, _,_, _,_, _,_, _,_, _,_, _,_,
_,_, _,_, _,_, _,_, _,_, _,_, _,_, _,_,
_,_, _,_, _,_, _,_, _,_, _,_, _,_, _,_,
_,_, _,_, _,_, _,_, _,_, _,_, _,_, _,_,
_,_, _,_, _,_, _,_, _,_, _,_, _,_, _,_,
_,_, _,_, _,_, _,_, _,_, _,_, _,_, _,_
# = Julia thread, # = Julia thread on HT, # = >1 Julia thread
(Mapping: 1 => 0, 2 => 1, 3 => 2, 4 => 3, 5 => 4, ...)
The package is registered. Hence, you can simply use
] add ThreadPinning
to add the package to your Julia environment.
Note that only Linux is fully supported. On other operating systems, all pinning calls (e.g. pinthreads
) will turn into no-ops but things like threadinfo()
should work (with limitations).
For more information, please find the documentation here.