Skip to content

Commit 73e94b5

Browse files
authored
Merge c965703 into sapling-pr-archive-ktf
2 parents e8c236b + c965703 commit 73e94b5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Utilities/Tools/jobutils2.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,11 @@ getNumberOfPhysicalCPUCores() {
395395
fi
396396
else
397397
# Do something under GNU/Linux platform
398-
CORESPERSOCKET=`lscpu | grep "Core(s) per socket" | awk '{print $4}'`
399-
SOCKETS=`lscpu | grep "Socket(s)" | awk '{print $2}'`
398+
#
399+
# Notice the human readable output of lscpu depends on the version and wether or not you
400+
# are inside a container. The following should be more stable.
401+
CORESPERSOCKET=$(lscpu -p=cpu,socket | grep ,0 | sort | uniq | wc -l)
402+
SOCKETS=$(lscpu -p=socket | grep -e "^[0-9]" | sort | uniq | wc -l)
400403
fi
401404
N=$((${CORESPERSOCKET}*${SOCKETS}))
402405
echo "${N}"

0 commit comments

Comments
 (0)