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的更多相关文章

  1. 【小错误】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 ...

  2. 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 ...

  3. 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 ...

  4. 【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 ...

  5. Linux: Check version info

    一.查看Linux内核版本命令(两种方法): 1.cat /proc/version [root@localhost ~]# cat /proc/version Linux version 2.6.1 ...

  6. linux check

    建议安装chkrootkit.rkhunter.Lynis.ISPProtect这类安全工具,定期做扫描

  7. [转载] 构造linux 系统下免密码ssh登陆  _How to establish password-less login with SSH

    In present (post production) IT infrastructure many different workstations, servers etc. have to be ...

  8. Understanding Linux /proc/cpuinfo

    http://www.richweb.com/cpu_info A hyperthreaded processor has the same number of function units as a ...

  9. 用于软件包管理的21个Linux YUM命令 转载

    http://flycars001.iteye.com/blog/1949085 YUM到底是啥东东? YUM(Yellowdog Updater Modified)是一款开源命令行及图形化软件包管理 ...

随机推荐

  1. NOIP模拟赛15

    NOIP2017金秋冲刺训练营杯联赛模拟大奖赛第一轮Day1 T1 天天去哪儿吃 直接枚举 #include<cstdio> #include<algorithm> using ...

  2. VS调试程序快捷键和系统快捷键

    调试程序快捷键 编译程序:F7 运行程序:ctrl + F5 打断点:F9 运行到断点位置:F5 单步执行:F10 单步进入函数:F11 结束调试:shift+F5 注释代码:ctrl+k,ctrl+ ...

  3. 【leetcode 简单】第四题 罗马数字转整数

    罗马数字包含以下七种字符:I, V, X, L,C,D 和 M. 字符 数值 I 1 V 5 X 10 L 50 C 100 D 500 M 1000 例如, 罗马数字 2 写做 II ,即为两个并列 ...

  4. Vue修改mint-ui默认样式(默认风格)

    加入my-mint.css 我这里用的postcss的变量定义,如果亲们用的是其他预处理器,要改成其他处理器的定义方式 覆盖mint-ui的primary颜色,改为自己UI的主题色 --main-co ...

  5. (2)剑指Offer之二维数组查找和替换空格问题

    一 二维数组查找 题目描述: 在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序.请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数. 问 ...

  6. NoSQL-来自维基百科

    NoSQL有时也称作Not Only SQL的缩写,是对不同于传统的关系型数据库的数据库管理系统的统称. 两者存在许多显著的不同点,其中最重要的是NoSQL不使用SQL作为查询语言.其数据存储可以不需 ...

  7. js弱数据类型的坑

    1.从表单获取的value是字符串,如果需要为数字相加,则需要转换为number类型 <input type="number" id="val1"> ...

  8. python不可以打印.doc文件

    [背景] 需求: 打印word文件 模块: python-docx [问题] 传递xxx.doc文件给python脚本,执行后,控制台没有内容输出 经查询后了解到,大致理由: doc是早一代的word ...

  9. python ORM - sqlalchemy 操作使用

    python操作数据库 使用 ORM - sqlalchemy,pymsql 安装: pip install pymsq pip install sqlalchemy 一. '''连接数据库'''   ...

  10. jq用户评论点击回复简单代码。

    类似这种镶套回复评论: <div> <ul> <!--一条评论 begin--> <li> <div class="user-colum ...