carstenbauer / ThreadPinning.jl

Readily pin Julia threads to CPU-threads
https://carstenbauer.github.io/ThreadPinning.jl/
MIT License
110 stars 7 forks source link

Pinning redesign #46

Closed carstenbauer closed 1 year ago

carstenbauer commented 1 year ago

TODOs

See ?pinthreads for the new interface. Citing it here for clarity:

New pinthreads docstring:

pinthreads(cpuids[; nthreads=Threads.nthreads(), force=true, warn=true])

Pin the first min(length(cpuids), nthreads) Julia threads to an explicit or implicit list of CPU ids. The latter can be specified in three ways:

1) explicitly (e.g. 0:3 or [0,12,4]), 2) by passing one of several predefined symbols (e.g. :cores or :sockets), 3) by providing a logical specification via helper functions (e.g. node and socket).

See below for more information.

If force=false the pinthreads call will only pin threads if this is the first attempt to pin threads with ThreadPinning.jl. Otherwise it will be a no-op. This may be particularly useful for packages that merely want to specify a "default pinning".

The option warn toggles general warnings, such as unwanted interference with BLAS thread settings.

1) Explicit

Simply provide an AbstractVector{<:Integer} of CPU ids. The latter are expected to be the "physical" ids, i.e. as provided by lscpu, and thus start at zero!

2) Predefined Symbols

3) Logical Specification

The functions node, socket, numa, and core can be used to to specify CPU ids of/within a certain domain. Moreover, the functions sockets and numas can be used to express a scatter policy (round-robin) between sockets or NUMA domains, respectively.

Examples (domains):

Different domains can be concatenated by providing them in a vector or as separate arguments to pinthreads.

Examples (concatenation):

Closes #39 Closes #27 Closes #43