I\'m putting together a small patch for the cachegrind/callgrind tool in valgrind which will auto-detect, using completely generic code, CPU instruction and cache configuration
For x86 platform you can use cpuid
:
See http://www.intel.com/content/www/us/en/processors/processor-identification-cpuid-instruction-note.html for details.
You need something like:
long _eax,_ebx,_ecx,_edx;
long op = func;
asm ("cpuid"
: "=a" (_eax),
"=b" (_ebx),
"=c" (_ecx),
"=d" (_edx)
: "a" (op)
);
Then use the info according to the doc in the link mentioned above.