Skip to content

Commit

Permalink
Support passing auto as the value to the JULIA_NUM_THREADS enviro…
Browse files Browse the repository at this point in the history
…nment variable
  • Loading branch information
DilumAluthge authored and vtjnash committed Dec 21, 2020
1 parent 5cd07f8 commit 684d5fc
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/threading.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,18 @@ void jl_init_threading(void)

// how many threads available, usable
jl_n_threads = JULIA_NUM_THREADS;
if (jl_options.nthreads < 0) // --threads=auto
if (jl_options.nthreads < 0) { // --threads=auto
jl_n_threads = jl_cpu_threads();
else if (jl_options.nthreads > 0) // --threads=N
}
else if (jl_options.nthreads > 0) { // --threads=N
jl_n_threads = jl_options.nthreads;
else if ((cp = getenv(NUM_THREADS_NAME)))
jl_n_threads = (uint64_t)strtol(cp, NULL, 10);
}
else if ((cp = getenv(NUM_THREADS_NAME))) {
if (strcmp(cp, "auto"))
jl_n_threads = (uint64_t)strtol(cp, NULL, 10); // ENV[NUM_THREADS_NAME] == "N"
else
jl_n_threads = jl_cpu_threads(); // ENV[NUM_THREADS_NAME] == "auto"
}
if (jl_n_threads <= 0)
jl_n_threads = 1;
#ifndef __clang_analyzer__
Expand Down

0 comments on commit 684d5fc

Please sign in to comment.