Linux check whether hyperthreading is enabled or not
There parameters need to be obained: no. of physical CPU; no. of cores on each CPU; no. of all threads.
In my case, the CPU name: Intel(R) Xeon(R) CPU E5-2630 v4 @ 2.20GHz
(1) Check the number of physical CPU
# cat /proc/cpuinfo | grep "physical id" | sort | uniq
physical id : 0
physical id : 1
//// Here we can see the number of physical CPU is 2. Each physical CPU has its own fan.
(2) Check the number of logical cores on each CPU
# cat /proc/cpuinfo | grep "cores" | uniq
cpu cores : 10
//// Here each physical CPU has 10 cores.
(3) Check the number of all threads
# cat /proc/cpuinfo | grep "processor" | wc -l
40
//// After obtaining above three parameters, now we can judge whether the hyperthreading is enabled or not.
In the case withou hyperthreading, number of all threads= no. of physical CPU * no. of cores on each CPU * 1, then there is only one thread on each core.
When hyperthreading is enabled, for example, N threads are available on each core. Then the following relationship can be achived:
number of all threads= no. of physical CPU * no. of cores on each CPU * N.
NOTE: OpenMP
The OpenMP parallel language can also be used to check the number of threads per core.
#include "stdio.h"
#include "omp.h" int main()
{
int num_thread, myid; #pragma omp parallel
{
num_threads= omp_get_num_threads(); // get the total number of threads on one core
myid= omp_get_thread_num(); // get the ID of the current thread
printf("\nHello world from the thread %d out of %d threads!");
}
return ;
}
Use the following command to compile the C file "hello.c":
$ gcc -fopenmp -o run.o hello.c
$ ./run.o
Linux check whether hyperthreading is enabled or not的更多相关文章
- 【小错误】SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled
1.今天在scott用户下执行语句跟踪时报了如下错误: SCOTT@ORA11GR2>set autotrace on SP2: Cannot find the Session Identifi ...
- Oracle set autotrace 时提示:Cannot find the Session Identifier. Check PLUSTRACE role is enabled
SQL> set autotrace Usage: SET AUTOT[RACE] {OFF | ON | TRACE[ONLY]} [EXP[LAIN]] [STAT[ISTICS]] SQL ...
- SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled
SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled 今天是2013-09-17,在今天学习sql ...
- 【ORACLE错误】SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled
执行set autotrace traceonly的时候,报错 SQL> set autotrace traceonly SP2-0618: Cannot find the Session Id ...
- Linux: Check version info
一.查看Linux内核版本命令(两种方法): 1.cat /proc/version [root@localhost ~]# cat /proc/version Linux version 2.6.1 ...
- linux check
建议安装chkrootkit.rkhunter.Lynis.ISPProtect这类安全工具,定期做扫描
- [转载] 构造linux 系统下免密码ssh登陆 _How to establish password-less login with SSH
In present (post production) IT infrastructure many different workstations, servers etc. have to be ...
- Understanding Linux /proc/cpuinfo
http://www.richweb.com/cpu_info A hyperthreaded processor has the same number of function units as a ...
- 用于软件包管理的21个Linux YUM命令 转载
http://flycars001.iteye.com/blog/1949085 YUM到底是啥东东? YUM(Yellowdog Updater Modified)是一款开源命令行及图形化软件包管理 ...
随机推荐
- Scrapy的安装--------Windows、linux、mac等操作平台
Scrapy安装 Scrapy的安装有多种方式,它支持Python2.7版本及以上或者是Python3.3版本及以上.下面来说py3环境下,scrapy的安装过程. Scrapy依赖的库比较多,至少需 ...
- protoc
平台安装: 在window 平台使用的工具protoc.zip linux平台的安装方式. 执行在windos平台上执行生成java代码命令: protoc --java_out=./ Keyword ...
- python学习笔记(十)之格式化字符串
格式化字符串,可以使用format方法.format方法有两种形式参数,一种是位置参数,一种是关键字参数. >>> '{0} {1}'.format('Hello', 'Python ...
- 商城项目(ssm+dubbo+nginx+mysql统合项目)总结(1)
我不会在这里贴代码和详细步骤什么的,我觉得就算我把它贴出来,你们照着步骤做还是会出很多问题,我推荐你们去看一下黑马的这个视频,我个人感觉很不错,一步一步走下来可以学到很多东西.另外,视频和相关文档的话 ...
- [002] delete_duplication_of_linked_list
[Description] Given a unsort linked list, delete all the duplication from them, no temporary space p ...
- Python Random模块生成伪随机数字
This module implements pseudo-random number generators for various distributions. 对于整数,有一个范围的均匀选择: 对 ...
- c/c++中static用法总结
static的作用主要有两种: 第一个作用是限定作用域:第二个作用是保持变量内容持久化: c语言中static的用法: 1.全局静态变量: 用法:在全局变量前加上关键字static,全局变量就定义成一 ...
- linux nginx php-fpm被攻击
1.nginx错误日志:报错 2018/05/30 16:30:55 [error] 8765#0: *1485 connect() to unix:/tmp/php-70-cgi.sock fail ...
- IT行业经典面试技巧及方法思路。
问题1:为什么从上家公司离职?”能说说原因吗? 首先,作为一个从事招聘的HR,并不认为追问面试者为什么从上一家公司离职是个明智的做法起码不应该在面试一开始就抛出这个问题,一个较为明显的原因是因为这会引 ...
- /boot/grub/grub.conf 内容诠释
linux的启动配置文件GRUB启动时会在 /boot/grub 中寻找一个名字为grub.conf的配置文件,如果找不到此配置文件则不进入菜单模式而直接进入命令行模式. grub.conf是一个纯文 ...