Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support passing auto as the value to the JULIA_NUM_THREADS environment variable #38952

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/threading.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,12 +392,17 @@ 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