mirror of
https://github.com/SOCI/soci.git
synced 2026-01-05 20:50:30 -06:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user