首先,看看什麼是超線程概念 超線程技術就是利用特殊的硬體指令,把兩個邏輯內核模擬成兩個物理晶元,讓單個處理器都能使用線程級並行計算,進而相容多線程操作系統和軟體,減少了CPU的閑置時間,提高的CPU的運行效率。超線程技術是在一顆CPU同時執行多個程式而共同分享一顆CPU內的資源,理論上要像兩顆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
32
32/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.
參考:
1. http://www.differencebetween.com/difference-between-core-and-vs-processor/
2. http://jingyan.baidu.com/article/63acb44a81001361fcc17e21.html