Skip to content
Snippets Groups Projects
Commit af331fde authored by lintao@ihep.ac.cn's avatar lintao@ihep.ac.cn
Browse files

Merge branch 'lintao/build/limit-njobs' into 'master'

Allow users to limit number of cores using NJOBS envvar.

See merge request !110
parents 56a5e0b0 404fef12
No related branches found
No related tags found
1 merge request!110Allow users to limit number of cores using NJOBS envvar.
Pipeline #12855 passed with stages
in 13 minutes and 10 seconds
......@@ -83,7 +83,23 @@ function run-cmake() {
}
function run-make() {
local njobs=-j$(nproc)
# User can limit the number of cores by setting NJOBS envvar.
# For example: NJOBS=8 ./build.sh
local njobs=${NJOBS}
if [ -z "$njobs" ]; then
njobs=$(nproc)
fi
# following is IHEP specific hack due to the limitation of nthreads 150.
local nthreads=$(ulimit -u)
local factor=16
nthreads=$((nthreads/factor)) # assume it is safe to divide by scale factor.
# min(njobs, nthreads)
njobs=$((njobs<nthreads ? njobs: nthreads))
njobs=-j${njobs}
echo "njobs: $njobs"
cmake --build . $njobs
}
......
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