Skip to content

Commit

Permalink
Try to fix incorrect documentation of nthreads (JuliaLang#53117)
Browse files Browse the repository at this point in the history
Since JuliaLang#49094, the docstring of
`nthreads` has been incorrect. It currently states that

> The threads in default have id numbers `1:nthreads(:default)`.

whereas that is no longer true:
```julia
julia> filter(i -> Threads.threadpool(i) == :interactive, 1:Threads.maxthreadid())
3-element Vector{Int64}:
 1
 2
 3

julia> filter(i -> Threads.threadpool(i) == :default, 1:Threads.maxthreadid())
6-element Vector{Int64}:
 4
 5
 6
 7
 8
 9
```
  • Loading branch information
MasonProtter authored Jan 31, 2024
1 parent 8304111 commit 95ae27f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions base/threadingconstructs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ maxthreadid() = Int(Core.Intrinsics.atomic_pointerref(cglobal(:jl_n_threads, Cin
"""
Threads.nthreads(:default | :interactive) -> Int
Get the current number of threads within the specified thread pool. The threads in default
have id numbers `1:nthreads(:default)`.
Get the current number of threads within the specified thread pool. The threads in `:interactive`
have id numbers `1:nthreads(:interactive)`, and the threads in `:default` have id numbers in
`nthreads(:interactive) .+ (1:nthreads(:default))`.
See also `BLAS.get_num_threads` and `BLAS.set_num_threads` in the [`LinearAlgebra`](@ref
man-linalg) standard library, and `nprocs()` in the [`Distributed`](@ref man-distributed)
Expand Down

0 comments on commit 95ae27f

Please sign in to comment.