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)是一款开源命令行及图形化软件包管理 ...
随机推荐
- 莫队 Codeforces Round #340 (Div. 2) E
题目大意:给你一个长度为n的序列,有m个询问,每次询问一个区间[L,R],表示这个区间内,有多少的a[i]^a[i+1].....^a[j]=k. 思路:莫队去搞就好了 我们定义pre[i]=a[1] ...
- HDU 4778 状压DP
一看就是状压,由于是类似博弈的游戏.游戏里的两人都是绝对聪明,那么先手的选择是能够确定最终局面的. 实际上是枚举最终局面情况,0代表是被Bob拿走的,1为Alice拿走的,当时Alice拿走且满足变换 ...
- CF821 C. Okabe and Boxes 栈模拟
Link 题意:给出操作,如果当前出栈操作使得出栈序列非顺序,可以在此之前自由排序栈中所有数,问最少排几次. 思路:已经出栈到第x个元素时,每次需要排序的操作后,能够保证前x元素出栈有序,否则说明该操 ...
- NOJ1659 求值 log10取对+floor
问题描述 给你三个数a,b,c,求a的b次的前c位数(不够c位输出全部即可) 输入 输入数据有多组,每组占一行,有三个整数,之间有空格.(0<a,b<2147483648,0<c ...
- [Luogu 1967] NOIP2013 货车运输
[Luogu 1967] NOIP2013 货车运输 一年多前令我十分头大的老题终于可以随手切掉了- 然而我这码风又变毒瘤了,我也很绝望. 看着一年前不带类不加空格不空行的清纯码风啊,时光也好像回去了 ...
- 《JavaScript 实战》:实现图片幻滑动展示效果
滑动展示效果主要用在图片或信息的滑动展示,也可以设置一下做成简单的口风琴(Accordion)效果.这个其实就是以前写的图片滑动展示效果的改进版,那是我第一篇比较受关注的文章,是时候整理一下了. 有如 ...
- 【洛谷 P3199】 [HNOI2009]最小圈(分数规划,Spfa)
题目链接 一开始不理解为什么不能直接用\(Tarjan\)跑出换直接求出最小值,然后想到了"简单环",恍然大悟. 二分答案,把所有边都减去\(mid\),判是否存在负环,存在就\( ...
- A .Gaby And Addition (Gym - 101466A + 字典树)
题目链接:http://codeforces.com/gym/101466/problem/A 题目: 题意: 给你n个数,重定义两个数之间的加法不进位,求这些数中两个数相加的最大值和最小值. 思路: ...
- git push multiple repo
git remote add xxx https://git.github.com
- 对RSA的认识
#没有经过专业老师的指导,所以您在阅读本文时建议参考即可. 学习视屏:https://www.youtube.com/watch?v=TqX0AHHwRYQ https://www.youtub ...