I'm building a topological tree of sockets, NUMA nodes, caches, cores, and threads for any Intel or AMD system in C.
Building this hierarchy, I want to ensure hardware threads are grouped together appropriately so it's clear who precisely shares what. I've found that I can set a thread's affinity and then use the cpuid
instruction to get a lot of the info I want, but not all.
If a package/socket has multiple NUMA nodes, how do I get an index of the NUMA node for the current hardware thread? If the NUMA node has multiple L3 caches, how do I get the index?
AMD has something for NUMA node ID in Fn8000_001E_ECX
, but I can't find anything comparable for Intel. And nothing re: L3 index for either.