Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - How to check hyperthreading status using CPUID: (4 Items)
   
How to check hyperthreading status using CPUID  
I found this instruction from one of the intel documentation on how to check hyperthreading(HTT) support.
"To determine if Hyper-Threading Technology is supported, check the value returned in EBX[23:16] after executing
CPUID with EAX=1. If EBX[23:16] contains a value >1, then the processor supports Hyper-Threading Technology"

I am using below code to check the same: 

void cpu_ID(unsigned int Info, unsigned int ui[4]) {
    __asm__ __volatile__("cpuid" : "=a" (ui[0]), "=b" (ui[1]), "=c" (ui[2]), "=d" (ui[3]) : "a" (ui), "c" (0));

}


int main()
{

    cpuID(1, Info);
    logicalCores = (ui[1] >> 16) & 0xff; // EBX[23:16]
    printf("logicl core %d \n",logicalCores);

}


I always get logical cores greater than 1. 
If i search the featurs of my processer online it is mentioned that Hyper threading is NOT SUPPORTED.

Is there any mistake the way am using CPUID and calculation.
Also please let me know if there is a better alternative for 
checking if system has HTT support and weather it is enabled or disabled.

Thank you for the support
Re: How to check hyperthreading status using CPUID  
> I found this instruction from one of the intel documentation on how to check 
> hyperthreading(HTT) support.
> "To determine if Hyper-Threading Technology is supported, check the value 
> returned in EBX[23:16] after executing
> CPUID with EAX=1. If EBX[23:16] contains a value >1, then the processor 
> supports Hyper-Threading Technology"
> 
> I am using below code to check the same: 
> 
> void cpu_ID(unsigned int Info, unsigned int ui[4]) {
>     __asm__ __volatile__("cpuid" : "=a" (ui[0]), "=b" (ui[1]), "=c" (ui[2]), "
> =d" (ui[3]) : "a" (ui), "c" (0));
> 
> }
> 
> 
> int main()
> {
> 
>     cpuID(1, Info);
>     logicalCores = (ui[1] >> 16) & 0xff; // EBX[23:16]
>     printf("logicl core %d \n",logicalCores);
> 
> }
> 
> 
> I always get logical cores greater than 1. 
> If i search the featurs of my processer online it is mentioned that Hyper 
> threading is NOT SUPPORTED.
> 
> Is there any mistake the way am using CPUID and calculation.
> Also please let me know if there is a better alternative for 
> checking if system has HTT support and weather it is enabled or disabled.
> 
> Thank you for the support

I was not able to edit the above code i posted so i am posting the code in reply ::

void cpu_ID(unsigned int Info, unsigned int ui[4]) {
    __asm__ __volatile__("cpuid" : "=a" (ui[0]), "=b" (ui[1]), "=c" (ui[2]), "=d" (ui[3]) : "a" (info), "c" (0));

}


int main()
{
    unsigned int ui[4];
    cpuID(1, ui);
    logicalCores = (ui[1] >> 16) & 0xff; // EBX[23:16]
    printf("logicl core %d \n",logicalCores);

}


RE: How to check hyperthreading status using CPUID  
Your question has nothing to do with QNX and is better asked on Intel forums.
From a cursory glance around the internet it seems that bit 28 is used to indicate both HT and multi-core. In order to 
find whether HT is used you need to enumerate all cores and then compare logical with physical ones. See
https://software.intel.com/en-us/articles/intel-64-architecture-processor-topology-enumeration/

--Elad
________________________________________
From: Surya kumar(deleted) [community-noreply@qnx.com]
Sent: November-27-18 2:14 AM
To: ostech-core_os
Subject: Re: How to check hyperthreading status using CPUID

> I found this instruction from one of the intel documentation on how to check
> hyperthreading(HTT) support.
> "To determine if Hyper-Threading Technology is supported, check the value
> returned in EBX[23:16] after executing
> CPUID with EAX=1. If EBX[23:16] contains a value >1, then the processor
> supports Hyper-Threading Technology"
>
> I am using below code to check the same:
>
> void cpu_ID(unsigned int Info, unsigned int ui[4]) {
>     __asm__ __volatile__("cpuid" : "=a" (ui[0]), "=b" (ui[1]), "=c" (ui[2]), "
> =d" (ui[3]) : "a" (ui), "c" (0));
>
> }
>
>
> int main()
> {
>
>     cpuID(1, Info);
>     logicalCores = (ui[1] >> 16) & 0xff; // EBX[23:16]
>     printf("logicl core %d \n",logicalCores);
>
> }
>
>
> I always get logical cores greater than 1.
> If i search the featurs of my processer online it is mentioned that Hyper
> threading is NOT SUPPORTED.
>
> Is there any mistake the way am using CPUID and calculation.
> Also please let me know if there is a better alternative for
> checking if system has HTT support and weather it is enabled or disabled.
>
> Thank you for the support

I was not able to edit the above code i posted so i am posting the code in reply ::

void cpu_ID(unsigned int Info, unsigned int ui[4]) {
    __asm__ __volatile__("cpuid" : "=a" (ui[0]), "=b" (ui[1]), "=c" (ui[2]), "=d" (ui[3]) : "a" (info), "c" (0));

}


int main()
{
    unsigned int ui[4];
    cpuID(1, ui);
    logicalCores = (ui[1] >> 16) & 0xff; // EBX[23:16]
    printf("logicl core %d \n",logicalCores);

}






_______________________________________________

OSTech
http://community.qnx.com/sf/go/post119308
To cancel your subscription to this discussion, please e-mail ostech-core_os-unsubscribe@community.qnx.com
Re: RE: How to check hyperthreading status using CPUID  
Thanks Elad .