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

Detecting CPU topology

Ilya_Z_
Beginner
1,054 Views

Hi,
I not sure is this is right place to ask questions like this, but i'll try.
I'm writing a code which enumerate cpu topology. I'm not sure do I fully understood Intel 64 Architecture Processor Topology Enumeration manual.
The x2APIC ID is divide into three bitfields(Package, core, logical procesor IDs). According to this manual to obtain this three sub IDs I must do as follows

SMT_Mask_Width = CPUID.(EAX=11, ECX=0):EAX[4:0] if CPUID.(EAX=11, ECX=0):ECX[15:8] is 1
SMT_Select_Mask = ~((-1) << SMT_Mask_Width )
SMT_ID = x2APIC_ID & SMT_Select_Mask

CorePlus_Mask_Width = CPUID.(EAX=11,ECX=1):EAX[4:0] if CPUID.(EAX=11, ECX=1):ECX[15:8] is 2
CoreOnly_Select_Mask = (~((-1) << CorePlus_Mask_Width ) ) ^ SMT_Select_Mask.
Core_ID = (x2APIC_ID & CoreOnly_Select_Mask) >> SMT_Mask_Width

Pkg_Select_Mask = (-1) << CorePlus_Mask_Width
Pkg_ID = (x2APIC_ID & Pkg_Select_Mask) >> CorePlus_Mask_Width

Could some explain me why to get CoreOnly_Select_Mask I need to (~((-1) << CorePlus_Mask_Width)) raise to the power of SMT_Select_Mask. I'm not sure is it realy reset SMT_Select_Mask. I think to reset SMT_Select_Mask I would only substract this mask form (~((-1) <<CorePlus_Mask_Width))
Or I did not understand something right? If some could give an example of decomposing of x2APIC ID. Showed how it looks like on a test x2APIC.

sorry for my english.

thanks in advance.

0 Kudos
6 Replies
TimP
Honored Contributor III
1,054 Views

http://www.open-mpi.org/projects/hwloc/ is an open source application which gets information from the OS for those OS which provide it, and from cpuid otherwise.  Intel has a similar thing but closed source.  These things tend to break on each new CPU introduction.

0 Kudos
Ilya_Z_
Beginner
1,054 Views

Thanks for reply. I'll look at this source, but could someone give an example of decomposing x2APIC.

0 Kudos
KEERIYAT__P_
Beginner
1,054 Views

I would like to know some details about Intel storage applications such as Intel storage manager or matrix storage manager, Which Prevents .exe loader coming on to stage or The entire DVD ROM content is not loaded. When these storage managers are removed, everything smoothly loads, Why?

0 Kudos
SergeyKostrov
Valued Contributor II
1,054 Views
>>I would like to know some details about Intel storage applications such as Intel storage manager or >>matrix storage manager, Which Prevents .exe loader coming on to stage or The entire DVD ROM content is >>not loaded. When these storage managers are removed, everything smoothly loads, Why? I'm very sorry but your questions need to be asked in a different Intel forum related to Intel software products you've mentioned.
0 Kudos
Bernard
Valued Contributor I
1,054 Views

>>>When these storage managers are removed, everything smoothly loads, Why?>>>

Some issue related to driver stack or maybe to IRPs , but this forum is not suitable for your question as it was mentioned by Sergey.

0 Kudos
SB17
Beginner
1,054 Views

Maybe it's not quite that, but " likwid-topology" does this. It is open source and you can look at the code

0 Kudos
Reply