MCPcopy Create free account
hub / github.com/PX4/eigen / main

Function main

bench/check_cache_queries.cpp:18–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16 }
17
18int main()
19{
20 cout << "Eigen's L1 = " << internal::queryL1CacheSize() << endl;
21 cout << "Eigen's L2/L3 = " << internal::queryTopLevelCacheSize() << endl;
22 int l1, l2, l3;
23 internal::queryCacheSizes(l1, l2, l3);
24 cout << "Eigen's L1, L2, L3 = " << l1 << " " << l2 << " " << l3 << endl;
25
26 #ifdef EIGEN_CPUID
27
28 int abcd[4];
29 int string[8];
30 char* string_char = (char*)(string);
31
32 // vendor ID
33 EIGEN_CPUID(abcd,0x0,0);
34 string[0] = abcd[1];
35 string[1] = abcd[3];
36 string[2] = abcd[2];
37 string[3] = 0;
38 cout << endl;
39 cout << "vendor id = " << string_char << endl;
40 cout << endl;
41 int max_funcs = abcd[0];
42
43 internal::queryCacheSizes_intel_codes(l1, l2, l3);
44 cout << "Eigen's intel codes L1, L2, L3 = " << l1 << " " << l2 << " " << l3 << endl;
45 if(max_funcs>=4)
46 {
47 internal::queryCacheSizes_intel_direct(l1, l2, l3);
48 cout << "Eigen's intel direct L1, L2, L3 = " << l1 << " " << l2 << " " << l3 << endl;
49 }
50 internal::queryCacheSizes_amd(l1, l2, l3);
51 cout << "Eigen's amd L1, L2, L3 = " << l1 << " " << l2 << " " << l3 << endl;
52 cout << endl;
53
54 // dump Intel direct method
55 if(max_funcs>=4)
56 {
57 l1 = l2 = l3 = 0;
58 int cache_id = 0;
59 int cache_type = 0;
60 do {
61 abcd[0] = abcd[1] = abcd[2] = abcd[3] = 0;
62 EIGEN_CPUID(abcd,0x4,cache_id);
63 cache_type = (abcd[0] & 0x0F) >> 0;
64 int cache_level = (abcd[0] & 0xE0) >> 5; // A[7:5]
65 int ways = (abcd[1] & 0xFFC00000) >> 22; // B[31:22]
66 int partitions = (abcd[1] & 0x003FF000) >> 12; // B[21:12]
67 int line_size = (abcd[1] & 0x00000FFF) >> 0; // B[11:0]
68 int sets = (abcd[2]); // C[31:0]
69 int cache_size = (ways+1) * (partitions+1) * (line_size+1) * (sets+1);
70
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";

Callers

nothing calls this directly

Calls 6

queryL1CacheSizeFunction · 0.85
queryTopLevelCacheSizeFunction · 0.85
queryCacheSizesFunction · 0.85
queryCacheSizes_amdFunction · 0.85

Tested by

no test coverage detected