Shell implementation to identify the number of physical CPUs, core number _linux shell

Source: Internet
Author: User

How to identify the number of physical CPUs, a few cores, is hyper-threading or multi-core

Judge the basis:

1. CPUs with the same core ID are the same core hyper-threading.
2. CPUs with the same physical ID are the same CPU-encapsulated threads or cores.

English version:

1.Physical ID and core ID are not necessarily consecutive but they unique. Any CPUs with the same core ID are hyperthreads in the same core.
2.Any CPU with the same physical ID are threads or cores in the same socket.

Instance:

CPU Information for Lunarpages:

Copy Code code as follows:

processor:0
Vendor_id:genuineintel
CPU Family:15
Model:4
Model Name:intel (R) Xeon (TM) CPU 3.00GHz
Stepping:3
CPU mhz:3000.881
Cache size:2048 KB
Physical id:0
Siblings:2
Core id:0
CPU Cores:1
Fdiv_bug:no
Hlt_bug:no
F00f_bug:no
Coma_bug:no
Fpu:yes
Fpu_exception:yes
CPUID Level:5
Wp:yes
FLAGS:FPU VME de PSE TSC MSR PAE MCE cx8 APIC MTRR PGE MCA cmov Pat PSE36 clflush DTS ACPI MMX FXSR SSE s SE2 SS HT TM PBE LM CONSTANT_TSC PNI monitor ds_cpl CID XTPR
bogomips:6006.73
Processor:1
Vendor_id:genuineintel
CPU Family:15
Model:4
Model Name:intel (R) Xeon (TM) CPU 3.00GHz
Stepping:3
CPU mhz:3000.881
Cache size:2048 KB
Physical id:0
Siblings:2
Core id:0
CPU Cores:1
Fdiv_bug:no
Hlt_bug:no
F00f_bug:no
Coma_bug:no
Fpu:yes
Fpu_exception:yes
CPUID Level:5
Wp:yes
FLAGS:FPU VME de PSE TSC MSR PAE MCE cx8 APIC MTRR PGE MCA cmov Pat PSE36 clflush DTS ACPI MMX FXSR SSE s SE2 SS HT TM PBE LM CONSTANT_TSC PNI monitor ds_cpl CID XTPR
bogomips:5999.40
Processor:2
Vendor_id:genuineintel
CPU Family:15
Model:4
Model Name:intel (R) Xeon (TM) CPU 3.00GHz
Stepping:3
CPU mhz:3000.881
Cache size:2048 KB
Physical Id:3
Siblings:2
Core Id:3
CPU Cores:1
Fdiv_bug:no
Hlt_bug:no
F00f_bug:no
Coma_bug:no
Fpu:yes
Fpu_exception:yes
CPUID Level:5
Wp:yes
FLAGS:FPU VME de PSE TSC MSR PAE MCE cx8 APIC MTRR PGE MCA cmov Pat PSE36 clflush DTS ACPI MMX FXSR SSE s SE2 SS HT TM PBE LM CONSTANT_TSC PNI monitor ds_cpl CID XTPR
bogomips:5999.08
Processor:3
Vendor_id:genuineintel
CPU Family:15
Model:4
Model Name:intel (R) Xeon (TM) CPU 3.00GHz
Stepping:3
CPU mhz:3000.881
Cache size:2048 KB
Physical Id:3
Siblings:2
Core Id:3
CPU Cores:1
Fdiv_bug:no
Hlt_bug:no
F00f_bug:no
Coma_bug:no
Fpu:yes
Fpu_exception:yes
CPUID Level:5
Wp:yes
FLAGS:FPU VME de PSE TSC MSR PAE MCE cx8 APIC MTRR PGE MCA cmov Pat PSE36 clflush DTS ACPI MMX FXSR SSE s SE2 SS HT TM PBE LM CONSTANT_TSC PNI monitor ds_cpl CID XTPR
bogomips:5999.55

Displays 4 logical CPUs, the same as the previous two logical CPUs through the physical ID, followed by two, so there are two physical CPUs. The previous two core IDs are the same, followed by the same two core IDs, indicating that all two CPUs are single cores. That is to say, two single core CPUs enabled Hyper-Threading technology.

The Intel CPU parameters can be initially judged using two Xeon Pentium 4CPU, a bit poor ....

How to obtain the CPU details:

Linux command: Cat/proc/cpuinfo

Using commands to determine several physical CPUs, several cores, etc.:
Number of logical CPUs:

Copy Code code as follows:

# Cat/proc/cpuinfo | grep "Processor" | Wc-l

Number of physical CPUs:
Copy Code code as follows:

# Cat/proc/cpuinfo | grep "Physical ID" | Sort | Uniq | Wc-l

Number of core in each physical CPU:
Copy Code code as follows:

# Cat/proc/cpuinfo | grep "CPU Cores" | Wc-l

Is it a hyper-threading?

If there are two logical CPUs with the same "core ID", then the Hyper-threading is turned on.
The number of logical CPUs (possibly core, threads, or both) per physical CPU:

Copy Code code as follows:

# Cat/proc/cpuinfo | grep "Siblings"

Other Features:

At present, Intel's new multi-core CPUs will display specific model numbers later, such as:

Copy Code code as follows:

Model Name:intel (R) Xeon (r) CPU X3230 @ 2.66GHz

Description is the CPU of the Xeon 3230, and does not show the specific number of models, most of them are Pentium CPU
Many host dealers cheat, with the Pentium CPU, but said to be the core of the CPU.

Probe to see the data:

Type: Intel (R) Xeon (TM) CPU 2.80GHz cache: 1024 KB
Type: Intel (R) Xeon (TM) CPU 2.80GHz cache: 1024 KB
Type: Intel (R) Xeon (TM) CPU 2.80GHz cache: 1024 KB
Type: Intel (R) Xeon (TM) CPU 2.80GHz cache: 1024 KB

No specific models, cache 1M, are generally Pentium series of CPUs, or Intel fake dual-core CPU, specifically according to the above to judge. The new multi-core CPU can see the specific model.

Other Xeon CPU, the general frequency is not high, reached 2.8 and 3.0 of only a few high-end CPU models, the general host will not use such a good

Related Article

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.