akaAlso
akaAlso

Reputation: 140

how to get the cpu cache associativity settings on windows

How could I get information about the L1,L2 and L3 associativity settings? I can get the size but not the associativity, any idea?

so far I haven't found anything usefull

Upvotes: 1

Views: 313

Answers (1)

Peter Cordes
Peter Cordes

Reputation: 365737

The x86 CPUID instruction doesn't require any privileges, so you can run it in a program for any OS.

It has cache associativity information in leaf 2 (eax=2). See also the tag wiki for more links to docs.

It only works on x86, though, so if you care about portability to Windows on non-x86, you'll have to find something else for other architectures.

There are libraries to decode this CPUID info, if you don't want to reinvent the wheel by writing a decoding function, and the asm function or inline asm to run CPUID in the first place.

Upvotes: 2

Related Questions