博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Linux上如何查看物理CPU个数,核数,线程数
阅读量:5349 次
发布时间:2019-06-15

本文共 2219 字,大约阅读时间需要 7 分钟。

首先,看看什么是超线程概念

超线程技术就是利用特殊的硬件指令,把两个逻辑内核模拟成两个物理芯片,让单个处理器都能使用线程级并行计算,进而兼容多线程操作系统和软件,减少了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    : 0physical 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.10GHzIntel(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.

2.

转载于:https://www.cnblogs.com/ivictor/p/6208573.html

你可能感兴趣的文章
5.6.3.7 localeCompare() 方法
查看>>
Linux下好用的简单实用命令
查看>>
常用web字体的使用指南
查看>>
描绘应用程序级的信息
查看>>
poj2406-Power Strings
查看>>
2018/12/18 JS会像Linux一样改变编程
查看>>
php环境搭建脚本
查看>>
FTP主动模式与被动模式说明
查看>>
php 编译常见错误
查看>>
MES架构
查看>>
【Python3 爬虫】15_Fiddler抓包分析
查看>>
高性能JavaScript-JS脚本加载与执行对性能的影响
查看>>
关于标签之间因为换行等问题造成的空白间距问题处理
查看>>
hdu 2767(tarjan)
查看>>
sklearn之分类模型混淆矩阵和分类报告
查看>>
MySQL各存储引擎
查看>>
项目--简单导出CSV文件
查看>>
Oracle session相关数据字典(一)
查看>>
织梦文章内容提取第一张或者多张图片输出
查看>>
C#用正则表达式 获取网页源代码标签的属性或值
查看>>