38{
42
43 (void)argc;
44 (void)argv;
45
48 fprintf(
stderr,
"Error! PAPI_library_init\n");
50 }
51
53 if (meminfo == NULL ) {
54 fprintf(
stderr,
"Error! PAPI_get_hardware_info");
55 return 2;
56 }
57
58 printf( "Memory Cache and TLB Hierarchy Information.\n" );
59 printf( "------------------------------------------------------------------------\n" );
60
61
63 printf( "TLB Information.\n There may be multiple descriptors for each level of TLB\n" );
64 printf( " if multiple page sizes are supported.\n\n" );
65
70 printf(
"L%d Unified TLB:\n",
i + 1 );
71 break;
73 printf(
"L%d Data TLB:\n",
i + 1 );
74 break;
76 printf(
"L%d Instruction TLB:\n",
i + 1 );
77 break;
78 }
79 if ( L[
i].tlb[j].
type ) {
80 if ( L[
i].tlb[j].page_size )
81 printf( " Page Size: %6d KB\n",
82 L[
i].tlb[j].page_size >> 10 );
83 printf( " Number of Entries: %6d\n",
84 L[
i].tlb[j].num_entries );
85 switch ( L[
i].tlb[j].associativity ) {
86 case 0:
87 break;
88 case 1:
89 printf( " Associativity: Direct Mapped\n\n" );
90 break;
91 case SHRT_MAX:
92 printf( " Associativity: Full\n\n" );
93 break;
94 default:
95 printf( " Associativity: %6d\n\n",
96 L[
i].tlb[j].associativity );
97 break;
98 }
99 }
100 }
101 }
102
103
104 printf( "\nCache Information.\n\n" );
106 for ( j = 0; j < 2; j++ ) {
109 printf(
"L%d Unified Cache:\n",
i + 1 );
110 break;
112 printf(
"L%d Data Cache:\n",
i + 1 );
113 break;
115 printf(
"L%d Instruction Cache:\n",
i + 1 );
116 break;
118 printf(
"L%d Trace Buffer:\n",
i + 1 );
119 break;
121 printf(
"L%d Vector Cache:\n",
i + 1 );
122 break;
123 }
124 if ( L[
i].cache[j].
type ) {
125 printf( " Total size: %6d KB\n Line size: %6d B\n Number of Lines: %6d\n Associativity: %6d\n\n",
126 ( L[
i].cache[j].size ) >> 10, L[
i].cache[j].line_size,
127 L[
i].cache[j].num_lines,
128 L[
i].cache[j].associativity );
129 }
130 }
131 }
132
133 return 0;
134}
get information about the system hardware
initialize the PAPI library.
#define PAPI_MH_TYPE_DATA
#define PAPI_MH_MAX_LEVELS
#define PAPI_MH_CACHE_TYPE(a)
#define PAPI_MH_TYPE_INST
#define PAPI_MH_TYPE_VECTOR
#define PAPI_MH_TYPE_TRACE
#define PAPI_MH_TYPE_UNIFIED
PAPI_mh_info_t mem_hierarchy
PAPI_mh_level_t level[PAPI_MAX_MEM_HIERARCHY_LEVELS]