1

as all know lscpu give the info about number of CORE and number of Thread

lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                48
On-line CPU(s) list:   0-47
Thread(s) per core:    2

I am searching about command that can give the total as

( number of CORE ) X ( number of Thread ) = 96

so output will be as case above = 96 CPU

we can do as

 CORE=` nproc --all `
 THREAD=`  lscpu | grep -i Thread | awk '{print $NF}' `

and

echo "$(( $CORE*$THREAD ))"

but this isn't elegant way

or maybe other elegant approach ?

we try also this ( but not get the total 96 cores's )

num_cpus=$(nproc)
# echo $num_cpus
48
yael
  • 12,598
  • 51
  • 169
  • 303

1 Answers1

0

Both nproc and the CPU(s) row in lscpu are the total number of threads.

So all you need to get the total number of threads is:

num_cpus=$(nproc)
Rafael Kitover
  • 243
  • 1
  • 5