ThreadPinning.jl: Readily pin Julia threads to CPU processors

Pinning Julia Threads to CPU-Cores with ThreadPinning.jl

ThreadPinning.jl, a Julia package that makes controlling the affinity of your Julia threads simple (and fun!). 


Dual-socket system where each CPU has 40 hardware threads (20 CPU-cores with 2-way SMT).

Check out the documentation to learn how to use ThreadPinning.jl.


Note: Only Linux is supported!

The package is registered. Hence, you can simply use

] add ThreadPinning

to add the package to your Julia environment.


To gather information about the hardware topology of the system (e.g. sockets and memory domains), ThreadPinning.jl uses lscpu. The latter must therefore be available (i.e. be on PATH), which should automatically be the case on virtually all linux systems.

In the unlikely case that lscpu isn't already installed on your system, here are a few ways to get it

  • install util-linux via your system's package manager or manually from here
  • download the same as a Julia artifact: util_linux_jll.jl

Autoupdate setting

By default, ThreadPinning.jl queries the system topology using lscpu on startup (i.e. at runtime). This is quite costly but is unfortunately necessary since you might have precompiled the package on one machine and use it from another (think e.g. login and compute nodes of a HPC cluster). However, you can tell ThreadPinning.jl to permanently skip this autoupdate at runtime and to always use the system topology that was present at compile time (i.e. when precompiling the package). This is perfectly save if you don't use the same Julia depot on different machines, in particular if you're a "standard user" that uses Julia on a desktop computer or laptop, and can reduce the package load time significantly. To do so, simply call ThreadPinning.Prefs.set_autoupdate(false).

Why pin Julia threads?



For more information, please find the documentation here.


CI infrastructure is provided by the Paderborn Center for Parallel Computing (PC²)



ThreadPinning.jl: Readily pin Julia threads to CPU processors
1.00 GEEK