@@ -623,8 +623,13 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
623
623
break ;
624
624
case 't' : // threads
625
625
errno = 0 ;
626
- jl_options .nthreadpools = 1 ;
627
- long nthreads = -1 , nthreadsi = 0 ;
626
+ jl_options .nthreadpools = 2 ;
627
+ // By default:
628
+ // default threads = -1 (== "auto")
629
+ long nthreads = -1 ;
630
+ // interactive threads = 1, or 0 if generating output
631
+ long nthreadsi = jl_generating_output () ? 0 : 1 ;
632
+
628
633
if (!strncmp (optarg , "auto" , 4 )) {
629
634
jl_options .nthreads = -1 ;
630
635
if (optarg [4 ] == ',' ) {
@@ -633,10 +638,9 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
633
638
else {
634
639
errno = 0 ;
635
640
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 " );
641
+ if (errno != 0 || endptr == & optarg [5 ] || * endptr != 0 || nthreadsi < 0 || nthreadsi >= INT16_MAX )
642
+ jl_errorf ("julia: -t,--threads=auto,<m>; m must be an integer >= 0 " );
638
643
}
639
- jl_options .nthreadpools ++ ;
640
644
}
641
645
}
642
646
else {
@@ -650,17 +654,18 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp)
650
654
errno = 0 ;
651
655
char * endptri ;
652
656
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" );
657
+ // Allow 0 for interactive
658
+ if (errno != 0 || endptri == & endptr [1 ] || * endptri != 0 || nthreadsi < 0 || nthreadsi >= INT16_MAX )
659
+ jl_errorf ("julia: -t,--threads=<n>,<m>; m must be an integer ≥ 0" );
660
+ if (nthreadsi == 0 )
661
+ jl_options .nthreadpools = 1 ;
655
662
}
656
- jl_options .nthreadpools ++ ;
657
663
}
658
664
jl_options .nthreads = nthreads + nthreadsi ;
659
665
}
660
666
int16_t * ntpp = (int16_t * )malloc_s (jl_options .nthreadpools * sizeof (int16_t ));
661
667
ntpp [0 ] = (int16_t )nthreads ;
662
- if (jl_options .nthreadpools == 2 )
663
- ntpp [1 ] = (int16_t )nthreadsi ;
668
+ ntpp [1 ] = (int16_t )nthreadsi ;
664
669
jl_options .nthreads_per_pool = ntpp ;
665
670
break ;
666
671
case 'p' : // procs
0 commit comments