Skip to content

Commit c965703

Browse files
committed
Cleanup jobutils2 to work on ARM
* Avoid dependency on bc for a multiplication * Make sure the CPU detection does not depend on the lscpu human readable output, which is apparently dependent on version / presence of a container.
1 parent 1cd002b commit c965703

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Utilities/Tools/jobutils2.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,13 @@ 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
401-
N=`bc <<< "${CORESPERSOCKET}*${SOCKETS}"`
404+
N=$((${CORESPERSOCKET}*${SOCKETS}))
402405
echo "${N}"
403406
}
404407

0 commit comments

Comments
 (0)