Skip to content

Commit e1af4a9

Browse files
MasonProtterKristofferC
authored and
KristofferC
committed
Try to fix incorrect documentation of nthreads (#53117)
Since #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 ``` (cherry picked from commit 95ae27f)
1 parent ff295ca commit e1af4a9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

base/threadingconstructs.jl

+3-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ maxthreadid() = Int(Core.Intrinsics.atomic_pointerref(cglobal(:jl_n_threads, Cin
4444
"""
4545
Threads.nthreads(:default | :interactive) -> Int
4646
47-
Get the current number of threads within the specified thread pool. The threads in default
48-
have id numbers `1:nthreads(:default)`.
47+
Get the current number of threads within the specified thread pool. The threads in `:interactive`
48+
have id numbers `1:nthreads(:interactive)`, and the threads in `:default` have id numbers in
49+
`nthreads(:interactive) .+ (1:nthreads(:default))`.
4950
5051
See also `BLAS.get_num_threads` and `BLAS.set_num_threads` in the [`LinearAlgebra`](@ref
5152
man-linalg) standard library, and `nprocs()` in the [`Distributed`](@ref man-distributed)

0 commit comments

Comments
 (0)