Skip to content
Snippets Groups Projects
Commit edd5efb5 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Improved build script to count physical cores on all NUMA nodes

parent a4ff26e4
No related branches found
No related tags found
No related merge requests found
...@@ -206,18 +206,22 @@ if [[ ${CMAKE_ONLY} == "yes" ]]; then ...@@ -206,18 +206,22 @@ if [[ ${CMAKE_ONLY} == "yes" ]]; then
exit 0 exit 0
fi fi
# get the number of physical cores present on the system, even with multiple NUMA nodes
# see https://unix.stackexchange.com/a/279354
SYSTEM_CORES=$(lscpu --all --parse=CORE,SOCKET | grep -Ev "^#" | sort -u | wc -l)
if [[ "$make" == "make" ]]; then if [[ "$make" == "make" ]]; then
if [[ -n ${BUILD_JOBS} ]]; then if [[ -n ${BUILD_JOBS} ]]; then
# override $MAKEFLAGS from parent environment # override $MAKEFLAGS from parent environment
export MAKEFLAGS=-j${BUILD_JOBS} export MAKEFLAGS=-j${BUILD_JOBS}
elif [[ -z ${MAKEFLAGS} ]]; then elif [[ -z ${MAKEFLAGS} ]]; then
# $BUILD_JOBS and $MAKEFLAGS are not set => set default value # $BUILD_JOBS and $MAKEFLAGS are not set => set default value
BUILD_JOBS=$(grep "core id" /proc/cpuinfo | sort -u | wc -l) BUILD_JOBS=$SYSTEM_CORES
export MAKEFLAGS=-j${BUILD_JOBS} export MAKEFLAGS=-j${BUILD_JOBS}
fi fi
else else
if [[ -z ${BUILD_JOBS} ]]; then if [[ -z ${BUILD_JOBS} ]]; then
BUILD_JOBS=$(grep "core id" /proc/cpuinfo | sort -u | wc -l) BUILD_JOBS=$SYSTEM_CORES
fi fi
make="$make -j$BUILD_JOBS" make="$make -j$BUILD_JOBS"
fi fi
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment