Use platform-appropriate way of getting CPUs number

This is simpler than parsing /sys/devices/system/cpu/online ourselves
and also works under macOS.

Reduce the number of jobs, 1.5*CPU number is too much, so use more
conservative +1 instead.

Also rename TCI_NUMTHREADS (which was another reference to Travis CI) to
just num_cpus.
This commit is contained in:
Vadim Zeitlin
2021-07-10 11:16:28 +02:00
parent 0d7341ca73
commit 4c8a7e752b

View File

@@ -16,10 +16,21 @@ fi
#
# Environment
#
TCI_NUMTHREADS=2
if [[ -f /sys/devices/system/cpu/online ]]; then
# Calculates 1.5 times physical threads
TCI_NUMTHREADS=$(( ( $(cut -f 2 -d '-' /sys/devices/system/cpu/online) + 1 ) * 15 / 10 ))
case `uname` in
Linux)
num_cpus=`nproc`
;;
Darwin)
num_cpus=`sysctl -n hw.ncpu`
;;
*)
num_cpus=1
esac
if [[ ${num_cpus} != 1 ]]; then
((num_cpus++))
fi
# Directory where the build happens.
@@ -60,7 +71,7 @@ tmstamp()
run_make()
{
[ $TCI_NUMTHREADS -gt 0 ] && make -j $TCI_NUMTHREADS || make
make -j $num_cpus
}
run_test()