CPU cores and logical count statistics

Source: Internet
Author: User

To view the number of logical CPUs:
Cat/proc/cpuinfo |grep "Processor" |sort-u|wc-l
24

To view the number of physical CPUs:
grep "Physical ID"/proc/cpuinfo|sort-u|wc-l
2

grep "Physical ID"/proc/cpuinfo|sort-u
Physical id:0
Physical Id:1

To view the number of cores per physical CPU:
grep "CPU Cores"/proc/cpuinfo|uniq
CPU Cores:6

Number of logical CPUs on each physical CPU:
grep "siblings"/proc/cpuinfo|uniq
Siblings:12

To determine if a copy of Hyper-threading is turned on:
If the "Physical ID" and "core ID" of multiple logical CPUs are the same, the description turns on Hyper-threading

or in other words
Number of logical CPUs > number of physical CPUs * CPU cores turned on Hyper-threading

Number of logical CPUs = number of physical CPUs * CPU cores No Hyper-threading is turned on



Check all information at once:
#!/bin/bash

Physicalnumber=0
Corenumber=0
Logicalnumber=0
Htnumber=0

logicalnumber=$ (grep "Processor"/proc/cpuinfo|sort-u|wc-l)
physicalnumber=$ (grep "Physical ID"/proc/cpuinfo|sort-u|wc-l)
corenumber=$ (grep "CPU Cores"/proc/cpuinfo|uniq|awk-f ': ' {print $} ' |xargs)
htnumber=$ ((Logicalnumber/(Physicalnumber * corenumber))

echo "****** CPU information ******"
echo "Logical CPU number: ${logicalnumber}"
echo "Physical CPU number: ${physicalnumber}"
echo "CPU Core number: ${corenumber}"
echo "HT number: ${htnumber}"

echo "*****************************"

Execution Result:

./cpuinfo
CPU information ******
Logical CPU number:24
Physical CPU Number:2
CPU Core Number:6
HT Number:2
*****************************

CPU cores and logical count statistics

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.