Skip to content

Commit 6f174d1

Browse files
default to 1 interactive thread
1 parent fa9478b commit 6f174d1

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/jloptions.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -623,8 +623,10 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
623623
break;
624624
case 't': // threads
625625
errno = 0;
626-
jl_options.nthreadpools = 1;
627-
long nthreads = -1, nthreadsi = 0;
626+
jl_options.nthreadpools = 2;
627+
// By default, main threads = -1 (== "auto"), interactive = 1
628+
long nthreads = -1, nthreadsi = 1;
629+
628630
if (!strncmp(optarg, "auto", 4)) {
629631
jl_options.nthreads = -1;
630632
if (optarg[4] == ',') {
@@ -633,10 +635,9 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
633635
else {
634636
errno = 0;
635637
nthreadsi = strtol(&optarg[5], &endptr, 10);
636-
if (errno != 0 || endptr == &optarg[5] || *endptr != 0 || nthreadsi < 1 || nthreadsi >= INT16_MAX)
637-
jl_errorf("julia: -t,--threads=auto,<m>; m must be an integer >= 1");
638+
if (errno != 0 || endptr == &optarg[5] || *endptr != 0 || nthreadsi < 0 || nthreadsi >= INT16_MAX)
639+
jl_errorf("julia: -t,--threads=auto,<m>; m must be an integer >= 0");
638640
}
639-
jl_options.nthreadpools++;
640641
}
641642
}
642643
else {
@@ -650,17 +651,16 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
650651
errno = 0;
651652
char *endptri;
652653
nthreadsi = strtol(&endptr[1], &endptri, 10);
653-
if (errno != 0 || endptri == &endptr[1] || *endptri != 0 || nthreadsi < 1 || nthreadsi >= INT16_MAX)
654-
jl_errorf("julia: -t,--threads=<n>,<m>; n and m must be integers >= 1");
654+
// Allow 0 for interactive
655+
if (errno != 0 || endptri == &endptr[1] || *endptri != 0 || nthreadsi < 0 || nthreadsi >= INT16_MAX)
656+
jl_errorf("julia: -t,--threads=<n>,<m>; m must be an integer ≥ 0");
655657
}
656-
jl_options.nthreadpools++;
657658
}
658659
jl_options.nthreads = nthreads + nthreadsi;
659660
}
660661
int16_t *ntpp = (int16_t *)malloc_s(jl_options.nthreadpools * sizeof(int16_t));
661662
ntpp[0] = (int16_t)nthreads;
662-
if (jl_options.nthreadpools == 2)
663-
ntpp[1] = (int16_t)nthreadsi;
663+
ntpp[1] = (int16_t)nthreadsi;
664664
jl_options.nthreads_per_pool = ntpp;
665665
break;
666666
case 'p': // procs

src/threading.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ void jl_init_threading(void)
698698
// and `jl_n_threads_per_pool`.
699699
jl_n_threadpools = 2;
700700
int16_t nthreads = JULIA_NUM_THREADS;
701-
int16_t nthreadsi = 0;
701+
int16_t nthreadsi = 1;
702702
char *endptr, *endptri;
703703

704704
if (jl_options.nthreads != 0) { // --threads specified

0 commit comments

Comments
 (0)