Software Tuning, Performance Optimization & Platform Monitoring
Discussion around monitoring and software tuning methodologies, Performance Monitoring Unit (PMU) of Intel microprocessors, and platform monitoring
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

How to know the exact cache associative on processor

zhangyihere
Beginner
176 Views
Hi, all

How to get the exact associative pattern of each cache level?
For example, the cache associative of Xeon 5650 processor at different cache level. I have tried to find out that information, but I failed.

Thank you in advance!
0 Kudos
2 Replies
SergeyKostrov
Valued Contributor II
176 Views
Quoting zhangyihere
...How to get the exact associative pattern of each cache level?..

Did you try IntelCPUID instruction? Here is an example with intrinsic __cpuid function:
[cpp] ... __cpuid( CPUInfo, 0x80000000 ); // Get the number of valid Extended IDs nExIds = ( RTuint )CPUInfo[0]; CrtMemset( CPUBrandString, 0x0, sizeof( CPUBrandString ) ); for( i = 0x80000000; i <= nExIds; ++i ) // Get the information associated with each extended ID { __cpuid( CPUInfo, i ); CrtPrintf( RTU("Extended Function CPUID Information %xn"), i ); CrtPrintf( RTU("tCPUInfo[0] = 0x%08Xn"), CPUInfo[0] ); CrtPrintf( RTU("tCPUInfo[1] = 0x%08Xn"), CPUInfo[1] ); CrtPrintf( RTU("tCPUInfo[2] = 0x%08Xn"), CPUInfo[2] ); CrtPrintf( RTU("tCPUInfo[3] = 0x%08Xn"), CPUInfo[3] ); // Process CPU brand String and Cache information if( i == 0x80000002 ) CrtMemcpy( CPUBrandString, CPUInfo, sizeof( CPUInfo ) ); else if( i == 0x80000003 ) CrtMemcpy( CPUBrandString + 16, CPUInfo, sizeof( CPUInfo ) ); else if( i == 0x80000004 ) CrtMemcpy( CPUBrandString + 32, CPUInfo, sizeof( CPUInfo ) ); else if( i == 0x80000006 ) { nCacheLineSize = CPUInfo[2] & 0xff; nL2Associativity = ( CPUInfo[2] >> 12 ) & 0xf; nCacheSizeK = ( CPUInfo[2] >> 16 ) & 0xffff; } } ... if( nExIds >= 0x80000006 ) { CrtPrintf( RTU("tCache Line Size = %ldn"), nCacheLineSize ); CrtPrintf( RTU("tL2 Associativity = %ldn"), nL2Associativity ); CrtPrintf( RTU("tCache Size = %ldKn"), nCacheSizeK ); } ... [/cpp]
Output shouldlook like:

...
Cache Line Size = ...
L2 Associativity = ...
Cache Size = ...K
...
Bernard
Black Belt
176 Views
I would also recommend to use Windbg in its kernel mode as primary source of memory and CPU inspection tool. Regarding CPU the most valuable information is contained in PCR and PCRB structures.You can dump these structures with the !pcr command use dt nt!_KPCR [address of PCR] -b -v -r.
Reply