2 #define EIGEN_INTERNAL_DEBUG_CACHE_QUERY 4 #include "../Eigen/Core" 9 #define DUMP_CPUID(CODE) {\ 11 abcd[0] = abcd[1] = abcd[2] = abcd[3] = 0;\ 12 EIGEN_CPUID(abcd, CODE, 0); \ 13 std::cout << "The code " << CODE << " gives " \ 14 << (int*)(abcd[0]) << " " << (int*)(abcd[1]) << " " \ 15 << (int*)(abcd[2]) << " " << (int*)(abcd[3]) << " " << std::endl; \ 24 cout <<
"Eigen's L1, L2, L3 = " << l1 <<
" " << l2 <<
" " << l3 << endl;
30 char* string_char = (
char*)(
string);
33 EIGEN_CPUID(abcd,0
x0,0);
39 cout <<
"vendor id = " << string_char << endl;
41 int max_funcs = abcd[0];
43 internal::queryCacheSizes_intel_codes(l1, l2, l3);
44 cout <<
"Eigen's intel codes L1, L2, L3 = " << l1 <<
" " << l2 <<
" " << l3 << endl;
47 internal::queryCacheSizes_intel_direct(l1, l2, l3);
48 cout <<
"Eigen's intel direct L1, L2, L3 = " << l1 <<
" " << l2 <<
" " << l3 << endl;
50 internal::queryCacheSizes_amd(l1, l2, l3);
51 cout <<
"Eigen's amd L1, L2, L3 = " << l1 <<
" " << l2 <<
" " << l3 << endl;
61 abcd[0] = abcd[1] = abcd[2] = abcd[3] = 0;
62 EIGEN_CPUID(abcd,0
x4,cache_id);
63 cache_type = (abcd[0] & 0x0F) >> 0;
64 int cache_level = (abcd[0] & 0xE0) >> 5;
65 int ways = (abcd[1] & 0xFFC00000) >> 22;
66 int partitions = (abcd[1] & 0x003FF000) >> 12;
67 int line_size = (abcd[1] & 0x00000FFF) >> 0;
69 int cache_size = (ways+1) * (partitions+1) * (line_size+1) * (sets+1);
71 cout <<
"cache[" << cache_id <<
"].type = " << cache_type <<
"\n";
72 cout <<
"cache[" << cache_id <<
"].level = " << cache_level <<
"\n";
73 cout <<
"cache[" << cache_id <<
"].ways = " << ways <<
"\n";
74 cout <<
"cache[" << cache_id <<
"].partitions = " << partitions <<
"\n";
75 cout <<
"cache[" << cache_id <<
"].line_size = " << line_size <<
"\n";
76 cout <<
"cache[" << cache_id <<
"].sets = " << sets <<
"\n";
77 cout <<
"cache[" << cache_id <<
"].size = " << cache_size <<
"\n";
80 }
while(cache_type>0 && cache_id<16);
84 std::cout << endl <<
"Raw dump:" << endl;
85 for(
int i=0;
i<max_funcs; ++
i)
98 cout <<
"EIGEN_CPUID is not defined" << endl;
Namespace containing all symbols from the Eigen library.
void queryCacheSizes(int &l1, int &l2, int &l3)
int queryTopLevelCacheSize()