Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit 850f97c

Browse files
author
Matthias Koeppe
committed
src/bin/sage-env: If SAGE_NUM_THREADS, SAGE_NUM_THREADS_PARALLEL are set already, do not call sage-num-threads.py to set them
1 parent 1e797a1 commit 850f97c

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

src/bin/sage-env

+19-10
Original file line numberDiff line numberDiff line change
@@ -596,17 +596,26 @@ fi
596596
# See trac 7186 -- this is needed if ecl is moved
597597
ECLDIR="$SAGE_LOCAL/lib/ecl/" && export ECLDIR
598598

599+
599600
# Handle parallel building/testing/...
600-
# See Trac Ticket #12016
601-
# First, figure out the right values for SAGE_NUM_THREADS (default
602-
# number of threads) and SAGE_NUM_THREADS_PARALLEL (default number of
603-
# threads when parallel execution is asked explicitly).
604-
sage_num_threads_array=$(sage-num-threads.py 2>/dev/null || echo 1 2 1)
605-
sage_num_threads_array="${sage_num_threads_array% *}" # strip third item
606-
SAGE_NUM_THREADS="${sage_num_threads_array% *}" # keep first item
607-
SAGE_NUM_THREADS_PARALLEL="${sage_num_threads_array#* }" # keep second item
608-
export SAGE_NUM_THREADS
609-
export SAGE_NUM_THREADS_PARALLEL
601+
case "$SAGE_NUM_THREADS,$SAGE_NUM_THREADS_PARALLEL" in
602+
[1-9][0-9]*,[1-9][0-9]*)
603+
# Variables are set to positive values already,
604+
# sage-num-threads.py would just recompute them
605+
;;
606+
*)
607+
# See Trac Ticket #12016
608+
# First, figure out the right values for SAGE_NUM_THREADS (default
609+
# number of threads) and SAGE_NUM_THREADS_PARALLEL (default number of
610+
# threads when parallel execution is asked explicitly).
611+
sage_num_threads_array=$(sage-num-threads.py 2>/dev/null || echo 1 2 1)
612+
sage_num_threads_array="${sage_num_threads_array% *}" # strip third item
613+
SAGE_NUM_THREADS="${sage_num_threads_array% *}" # keep first item
614+
SAGE_NUM_THREADS_PARALLEL="${sage_num_threads_array#* }" # keep second item
615+
export SAGE_NUM_THREADS
616+
export SAGE_NUM_THREADS_PARALLEL
617+
;;
618+
esac
610619

611620
# Multithreading in OpenBLAS does not seem to play well with Sage's attempts to
612621
# spawn new processes, see #26118. Apparently, OpenBLAS sets the thread

0 commit comments

Comments
 (0)