JuliaLang / julia

The Julia Programming Language
https://julialang.org/
MIT License
45.47k stars 5.46k forks source link

JULIA_EXCLUSIVE with auto threads errors on 1.10, mac/arm64 #50702

Open daviehh opened 1 year ago

daviehh commented 1 year ago

Running

JULIA_EXCLUSIVE=1 julia --threads=auto 

with v1.10 now errors with

ERROR: Too many threads requested for JULIA_EXCLUSIVE option

on macos, versioninfo is

Julia Version 1.10.0-beta1
Commit 6616549950e (2023-07-25 17:43 UTC)
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 10 × Apple M1 Pro
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
  Threads: 1 on 8 virtual cores
daviehh commented 1 year ago

Maybe related to the new gcthreads?

JULIA_EXCLUSIVE=1 julia --threads=auto --gcthreads=1

runs ok, and --gcthreads=2 results in

ERROR: Too many threads requested for JULIA_EXCLUSIVE option

DatName commented 6 months ago

For me, on Linux pc 6.5.0-21-generic #21~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Feb 9 13:32:52 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

and julia 1.10.0 (and 1.10.1)

pc:~ $ julia
julia> versioninfo()
Julia Version 1.10.0
Commit 3120989f39b (2023-12-25 18:01 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 20 × 12th Gen Intel(R) Core(TM) i9-12900H
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, alderlake)
  Threads: 1 on 20 virtual cores
Environment:
  JULIA_EXCLUSIVE = 1
  JULIA_PKG_USE_CLI_GIT = true

I get ERROR: Too many threads requested for JULIA_EXCLUSIVE option. for threads above 15:

pc:~/julia/julia-1.10.0/bin $ ./julia --banner=no --threads=auto
ERROR: Too many threads requested for JULIA_EXCLUSIVE option.
pc:~/julia/julia-1.10.0/bin $ ./julia --banner=no --threads=20
ERROR: Too many threads requested for JULIA_EXCLUSIVE option.
pc:~/julia/julia-1.10.0/bin $ ./julia --banner=no --threads=15
ERROR: Too many threads requested for JULIA_EXCLUSIVE option.
pc:~/julia/julia-1.10.0/bin $ ./julia --banner=no --threads=14
julia> 

Since error comes from

if (exclusive) {
        if (nthreads > jl_cpu_threads()) {
            jl_printf(JL_STDERR, "ERROR: Too many threads requested for %s option.\n", MACHINE_EXCLUSIVE_NAME);
            exit(1);
        }
...

I checked that jl_cpu_threads() == 20:

julia> ccall(:jl_cpu_threads, Int32, ())
20