Linux上如何查看物理CPU个数,核数,线程数
首先,看看什么是超線程概念
超線程技術就是利用特殊的硬件指令,把兩個邏輯內核模擬成兩個物理芯片,讓單個處理器都能使用線程級并行計算,進而兼容多線程操作系統和軟件,減少了CPU的閑置時間,提高的CPU的運行效率。
超線程技術是在一顆CPU同時執行多個程序而共同分享一顆CPU內的資源,理論上要像兩顆CPU一樣在同一時間執行兩個線程,雖然采用超線程技術能同時執行兩個線程,但它并不象兩個真正的CPU那樣,每個CPU都具有獨立的資源。當兩個線程都同時需要某一個資源時,其中一個要暫時停止,并讓出資源,直到這些資源閑置后才能繼續。因此超線程的性能并不等于兩顆CPU的性能。
?
其次,看看物理CPU個數,核數以及線程數的關系
總核數 = 物理CPU個數 * 每顆物理CPU的核數
總邏輯CPU數 = 物理CPU個數 * 每顆物理CPU的核數 * 超線程數
上述公式中,邏輯CPU數即線程數
?
如何查看CPU物理個數
# grep 'physical id' /proc/cpuinfo | sort -u
physical id : 0 physical id : 1?
如何查看每個物理CPU的核數
# grep 'core id' /proc/cpuinfo | sort -u | wc -l
8?
如何查看總的邏輯CPU個數
# grep 'processor' /proc/cpuinfo | sort -u | wc -l
3232/8/2=2,可見該CPU支持并已打開超線程。
?
如何查看CPU的型號
# dmidecode -s processor-version
Intel(R) Xeon(R) CPU E5-2658 @ 2.10GHz Intel(R) Xeon(R) CPU E5-2658 @ 2.10GHz?
關于物理CPU,核數以及超線程的區別
A core is the most basic computational unit of a processor. A processor is made up of one or more cores. Tradition processors had only one core while modern processors have multiple cores.
A core consists of an ALU, CU, and a set of registers.
A core consists of two levels of caches called L1 and L2 which is there in each core.
A processor consists of a cache that is shared by call cores called L3 cache. It is common to all cores.
A processor depending on the architecture can consist of a memory controller and an input/output controller.
Certain processor packages consist of Graphics Processing Units (GPU) as well.
A core that does not have hyper-threading can execute only one instruction at a time while a multicore processor made up of several cores can execute several instructions parallel. If a processor is made up of 4 cores that do not support hyper threading then that processor can execute 4 instructions at the same time.
A core having hyper-threading technology has redundant functional units so that they can execute multiple instructions at a time. For example, a core with 2 threads can execute 2 instructions at the same time hence a processor with 4 such cores can execute 2×4 instructions parallel. These threads are usually called logical cores and the task manager of Windows generally show the number of logical cores but not the physical cores.
轉載于:https://www.cnblogs.com/xiaojianblogs/p/6209382.html
總結
以上是生活随笔為你收集整理的Linux上如何查看物理CPU个数,核数,线程数的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: XML_Qt_资料
- 下一篇: linux 其他常用命令