- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 5.7k
 
Closed
Description
Since the number of threads can't be changed without restarting julia, I find this behavior quite surprising:
julia> @code_llvm Threads.nthreads()
;  @ threadingconstructs.jl:19 within `nthreads'
define i64 @julia_nthreads_20335() {
top:
; ┌ @ pointer.jl:105 within `unsafe_load' @ pointer.jl:105
   %0 = load i32, i32* inttoptr (i64 140333758273848 to i32*), align 8
; └
; ┌ @ boot.jl:707 within `Int64'
; │┌ @ boot.jl:626 within `toInt64'
    %1 = sext i32 %0 to i64
; └└
  ret i64 %1
}In general, I think it would be useful to do something like
const NUM_THREADS = Int(unsafe_load(cglobal(:jl_n_threads, Cint)))
nthreads() = NUM_THREADSso that branches / dispatches which depend on the number of threads can be eliminated.
DilumAluthge
Metadata
Metadata
Assignees
Labels
No labels