From c96570322205e1d9dfcfcb680ba61162d7ad3c64 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Tue, 9 Dec 2025 14:26:21 +0100 Subject: [PATCH 1/5] 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. --- Utilities/Tools/jobutils2.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Utilities/Tools/jobutils2.sh b/Utilities/Tools/jobutils2.sh index ba96b97da090b..ee492b76fc60c 100644 --- a/Utilities/Tools/jobutils2.sh +++ b/Utilities/Tools/jobutils2.sh @@ -395,10 +395,13 @@ getNumberOfPhysicalCPUCores() { fi else # Do something under GNU/Linux platform - CORESPERSOCKET=`lscpu | grep "Core(s) per socket" | awk '{print $4}'` - SOCKETS=`lscpu | grep "Socket(s)" | awk '{print $2}'` + # + # Notice the human readable output of lscpu depends on the version and wether or not you + # are inside a container. The following should be more stable. + CORESPERSOCKET=$(lscpu -p=cpu,socket | grep ,0 | sort | uniq | wc -l) + SOCKETS=$(lscpu -p=socket | grep -e "^[0-9]" | sort | uniq | wc -l) fi - N=`bc <<< "${CORESPERSOCKET}*${SOCKETS}"` + N=$((${CORESPERSOCKET}*${SOCKETS})) echo "${N}" } From 126b4fedebac19d1f00775f700434f0a3683d458 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Fri, 12 Dec 2025 14:14:52 +0100 Subject: [PATCH 2/5] Apply suggestion from @ktf --- Utilities/Tools/jobutils2.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/Tools/jobutils2.sh b/Utilities/Tools/jobutils2.sh index ee492b76fc60c..37c9043ec2fbe 100644 --- a/Utilities/Tools/jobutils2.sh +++ b/Utilities/Tools/jobutils2.sh @@ -398,7 +398,7 @@ getNumberOfPhysicalCPUCores() { # # Notice the human readable output of lscpu depends on the version and wether or not you # are inside a container. The following should be more stable. - CORESPERSOCKET=$(lscpu -p=cpu,socket | grep ,0 | sort | uniq | wc -l) + CORESPERSOCKET=$(lscpu -p=cpu,socket | grep "^[0-9]\+,0" | sort | uniq | wc -l) SOCKETS=$(lscpu -p=socket | grep -e "^[0-9]" | sort | uniq | wc -l) fi N=$((${CORESPERSOCKET}*${SOCKETS})) From 5d6e2b79d355eaf1c30aff0ea626939ba11f7beb Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Fri, 12 Dec 2025 14:20:06 +0100 Subject: [PATCH 3/5] Apply suggestion from @ktf --- Utilities/Tools/jobutils2.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Utilities/Tools/jobutils2.sh b/Utilities/Tools/jobutils2.sh index 37c9043ec2fbe..ba5e838478d59 100644 --- a/Utilities/Tools/jobutils2.sh +++ b/Utilities/Tools/jobutils2.sh @@ -396,8 +396,8 @@ getNumberOfPhysicalCPUCores() { else # Do something under GNU/Linux platform # - # Notice the human readable output of lscpu depends on the version and wether or not you - # are inside a container. The following should be more stable. +# Gets the cores per socket by counting unique cores on socket 0. +# Gets sockets by counting unique socket ids. The grepping is done in any case to avoid matching comments. CORESPERSOCKET=$(lscpu -p=cpu,socket | grep "^[0-9]\+,0" | sort | uniq | wc -l) SOCKETS=$(lscpu -p=socket | grep -e "^[0-9]" | sort | uniq | wc -l) fi From 0749e796eee77cde9650574058536cfc44db1054 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Fri, 12 Dec 2025 14:21:21 +0100 Subject: [PATCH 4/5] Apply suggestion from @ktf --- Utilities/Tools/jobutils2.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Utilities/Tools/jobutils2.sh b/Utilities/Tools/jobutils2.sh index ba5e838478d59..9d2a8ff30bd60 100644 --- a/Utilities/Tools/jobutils2.sh +++ b/Utilities/Tools/jobutils2.sh @@ -396,8 +396,8 @@ getNumberOfPhysicalCPUCores() { else # Do something under GNU/Linux platform # -# Gets the cores per socket by counting unique cores on socket 0. -# Gets sockets by counting unique socket ids. The grepping is done in any case to avoid matching comments. + # Gets the cores per socket by counting unique cores on socket 0. + # Gets sockets by counting unique socket ids. The grepping is done in any case to avoid matching comments. CORESPERSOCKET=$(lscpu -p=cpu,socket | grep "^[0-9]\+,0" | sort | uniq | wc -l) SOCKETS=$(lscpu -p=socket | grep -e "^[0-9]" | sort | uniq | wc -l) fi From a7a8e61bc254a189f6aeb05be05ec25e441cdcd2 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Fri, 12 Dec 2025 14:22:22 +0100 Subject: [PATCH 5/5] Apply suggestion from @ktf --- Utilities/Tools/jobutils2.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utilities/Tools/jobutils2.sh b/Utilities/Tools/jobutils2.sh index 9d2a8ff30bd60..b7c8466f54313 100644 --- a/Utilities/Tools/jobutils2.sh +++ b/Utilities/Tools/jobutils2.sh @@ -397,7 +397,7 @@ getNumberOfPhysicalCPUCores() { # Do something under GNU/Linux platform # # Gets the cores per socket by counting unique cores on socket 0. - # Gets sockets by counting unique socket ids. The grepping is done in any case to avoid matching comments. + # Gets sockets by counting unique socket ids. The grepping is done in any case to avoid matching comments. CORESPERSOCKET=$(lscpu -p=cpu,socket | grep "^[0-9]\+,0" | sort | uniq | wc -l) SOCKETS=$(lscpu -p=socket | grep -e "^[0-9]" | sort | uniq | wc -l) fi