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. 为什么需要 Stream

    Stream 作为 Java 8 的一大亮点,它与 java.io 包里的 InputStream 和 OutputStream 是完全不同的概念.它也不同于 StAX 对 XML 解析的 Strea ...

  2. 商城项目(ssm+dubbo+nginx+mysql统合项目)总结(4)

    我不会在这里贴代码和详细步骤什么的,我觉得就算我把它贴出来,你们照着步骤做还是会出很多问题,我推荐你们去看一下黑马的这个视频,我个人感觉很不错,一步一步走下来可以学到很多东西.另外,视频和相关文档的话 ...

  3. python进阶之py文件内置属性

    前言 对于任何一个python文件来说,当python解释器运行一个py文件,会自动将一些内容加载到内置的属性中:一个模块我们可以看做是一个比类更大的对象. 查看模块的内置属性 我们先创建一个典型的p ...

  4. flask插件系列之flask_cors跨域请求

    前后端分离在开发调试阶段本地的flask测试服务器需要允许跨域访问,简单解决办法有二: 使用flask_cors包 安装 pip install flask_cors 初始化的时候加载配置,这样就可以 ...

  5. 【BubbleCup X】F:Product transformation

    按照题解的规律,首先能看出前面每个数幂次的性质. 然后发掘约数的性质 #include<bits/stdc++.h> ; typedef long long ll; using names ...

  6. MySQL JDBC驱动下载

    下载地址:https://pan.baidu.com/s/1VLNaV_rz2P1jMtYrjJydiQ

  7. java基础3 循环语句:While 循环语句、do while 循环语句、 for 循环语句 和 break、continue关键字

    一.While循环语句 1.格式 while(条件表达式){ 执行语句: } 2.要点 1,先判断后执行 2,循环次数不定 3,避免死循环 3.举例 题目1:输出0-100之间的所有数 class D ...

  8. /proc文件夹介绍

    Linux系统上的/proc目录是一种文件系统,即proc文件系统.与其它常见的文件系统不同的是,/proc是一种伪文件系统(也即虚拟文件系统),存储的是当前内核运行状态的一系列特殊文件,用户可以通过 ...

  9. LeetCode862. Shortest Subarray with Sum at Least K

    Return the length of the shortest, non-empty, contiguous subarray of A with sum at least K. If there ...

  10. 对于JAVA多线程卖票小程序的理解

    昨天把多线程重新看了一遍,发现自己还是有许多需要理解的地方,现在写一篇总结. 一:利用继承Thread类会出现的问题: public class SellTicketsThread extends T ...