Intel® Moderncode for Parallel Architectures
Support for developing parallel programming applications on Intel® Architecture.
1696 Discussions

Newbie? Is there a way to deteremine HTT support and enabled/disabled from a windows API?

Dave_Thompson
Beginner
372 Views
I know how to check CPUID Leaf 1 edx bit 28 for the presence of the HTT, but I want a way with out using the CPUID instruction.

That will give me HTT available.

The bios supplies the setting of HTT.

Is there a way of checking that setting usinga Windows API?

I am perfectly willing to accept registry queries.
0 Kudos
3 Replies
Roman_D_Intel
Employee
372 Views
Hi,

Windows XP SP3 and following versions support GetLogicalProcessorInformation API call. The example in http://msdn.microsoft.com/en-us/library/ms683194(VS.85).aspxcomputes logical and physical core counts using the GetLogicalProcessorInformation function. One way of determining if HT is onon current Intel CPUs is to comparethese two numbers(i.e.if "processorCoreCount
Best regards,
Roman
0 Kudos
Dave_Thompson
Beginner
372 Views
Hi Roman,

Thanks for your reply. I have been working pretty hard at this and have discovered the answer, after a lot of digging. You are correct in your statements, but you have to take it one step further.

int chips = 0;

int cores = 0;

int buses = 0;

int threads = 0;

int total = 0;

int cache[4] = { 0 };

bool threading = false;



/* requires WinXp SP3 or Win2003 SP1 */

PSYSTEM_LOGICAL_PROCESSOR_INFORMATION pInfo = NULL;

int size = 0;

GetLogicalProcessorInformation( pInfo, &size );

pInfo = alloca( size ); /* on the stack */

if ( ! pInfo ) exit( 3 );

memset( pInfo, 0, size );

if ( ! GetLogicalProcessorInformation( pInfo, &size ) ) exit( 4 );

while ( size )

{

switch ( pInfo->Relationship )

{

case RelationNumaNode:

buses++;

break;

case RelationProcessorCore:

cores++;

threads = CountBits( (unsigned int)pInfo->ProcessorMask );

total += threads;

if ( pInfo->ProcessorCore.Flags == 1 )

threading = true;

break;

case RelationProcessorPackage:

chips++;

break;

case RelationCache:

cache[ pInfo->Cache.Level ] = pInfo->Cache.Size;

break;

default:

exit( 5 );

}

size -= sizeof *pInfo;

pInfo++;

}

It has to do with the ProcessorCore.Flags being set to one.
Unfortunately this is also true in the case of a VMware Guest which leads to a whole set of additional issues.

I have also indirectly seen this from a customer using this approach,
total = 2 chips = 1 cores = 1 threads = 2 threading = true
The chip was a "Intel Core2 CPU 6400 @ 2.13GHz".
I am at a complete loss at explaining this.This is the only instance that I have seen or heard of. I have asked the customer to check for a BIOS upgrade. The only other explanation I have, would be some sort of virtualization being present. I am 98% sure it's not VMware.

0 Kudos
Roman_D_Intel
Employee
372 Views
Dave, I should have stated that this method works on Windows Vista+ and not on Windows XP SP3+.The documentation ofSYSTEM_LOGICAL_PROCESSOR_INFORMATION data structrurementions this misbehaviour on Windows XP.

Windows Server 2003 and Windows XP Professional x64 Edition: [...] Therefore, to determine whether the processor supports multiple cores or hyperthreading on systems prior to Windows Vista, use the CPUID instruction.
0 Kudos
Reply