mem_info.c File Reference

Include dependency graph for mem_info.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)

Variables

int TESTS_QUIET

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 33 of file mem_info.c.

00034 {
00035     const PAPI_hw_info_t *meminfo = NULL;
00036     PAPI_mh_level_t *L;
00037     int i, j, retval;
00038 
00039     tests_quiet( argc, argv );  /* Set TESTS_QUIET variable */
00040     retval = PAPI_library_init( PAPI_VER_CURRENT );
00041     if ( retval != PAPI_VER_CURRENT )
00042         test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
00043 
00044     if ( ( meminfo = PAPI_get_hardware_info(  ) ) == NULL )
00045         test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
00046 
00047     if ( !TESTS_QUIET ) {
00048         printf( "Memory Cache and TLB Hierarchy Information.\n" );
00049         printf
00050             ( "------------------------------------------------------------------------\n" );
00051         /* Extract and report the tlb and cache information */
00052         L = ( PAPI_mh_level_t * ) & ( meminfo->mem_hierarchy.level[0] );
00053         printf
00054             ( "TLB Information.\n  There may be multiple descriptors for each level of TLB\n" );
00055         printf( "  if multiple page sizes are supported.\n\n" );
00056         /* Scan the TLB structures */
00057         for ( i = 0; i < meminfo->mem_hierarchy.levels; i++ ) {
00058             for ( j = 0; j < PAPI_MH_MAX_LEVELS; j++ ) {
00059                 switch ( PAPI_MH_CACHE_TYPE( L[i].tlb[j].type ) ) {
00060                 case PAPI_MH_TYPE_UNIFIED:
00061                     printf( "L%d Unified TLB:\n", i + 1 );
00062                     break;
00063                 case PAPI_MH_TYPE_DATA:
00064                     printf( "L%d Data TLB:\n", i + 1 );
00065                     break;
00066                 case PAPI_MH_TYPE_INST:
00067                     printf( "L%d Instruction TLB:\n", i + 1 );
00068                     break;
00069                 }
00070                 if ( L[i].tlb[j].type ) {
00071                     if ( L[i].tlb[j].page_size )
00072                         printf( "  Page Size:         %6d KB\n",
00073                                 L[i].tlb[j].page_size >> 10 );
00074                     printf( "  Number of Entries: %6d\n",
00075                             L[i].tlb[j].num_entries );
00076                     switch ( L[i].tlb[j].associativity ) {
00077                     case 0: /* undefined */
00078                         break;
00079                     case 1:
00080                         printf( "  Associativity:      Direct Mapped\n\n" );
00081                         break;
00082                     case SHRT_MAX:
00083                         printf( "  Associativity:       Full\n\n" );
00084                         break;
00085                     default:
00086                         printf( "  Associativity:     %6d\n\n",
00087                                 L[i].tlb[j].associativity );
00088                         break;
00089                     }
00090                 }
00091             }
00092         }
00093         /* Scan the Cache structures */
00094         printf( "\nCache Information.\n\n" );
00095         for ( i = 0; i < meminfo->mem_hierarchy.levels; i++ ) {
00096             for ( j = 0; j < 2; j++ ) {
00097                 switch ( PAPI_MH_CACHE_TYPE( L[i].cache[j].type ) ) {
00098                 case PAPI_MH_TYPE_UNIFIED:
00099                     printf( "L%d Unified Cache:\n", i + 1 );
00100                     break;
00101                 case PAPI_MH_TYPE_DATA:
00102                     printf( "L%d Data Cache:\n", i + 1 );
00103                     break;
00104                 case PAPI_MH_TYPE_INST:
00105                     printf( "L%d Instruction Cache:\n", i + 1 );
00106                     break;
00107                 case PAPI_MH_TYPE_TRACE:
00108                     printf( "L%d Trace Buffer:\n", i + 1 );
00109                     break;
00110                 case PAPI_MH_TYPE_VECTOR:
00111                     printf( "L%d Vector Cache:\n", i + 1 );
00112                     break;
00113                 }
00114                 if ( L[i].cache[j].type ) {
00115                     printf
00116                         ( "  Total size:        %6d KB\n  Line size:         %6d B\n  Number of Lines:   %6d\n  Associativity:     %6d\n\n",
00117                           ( L[i].cache[j].size ) >> 10, L[i].cache[j].line_size,
00118                           L[i].cache[j].num_lines,
00119                           L[i].cache[j].associativity );
00120                 }
00121             }
00122         }
00123     }
00124     test_pass( __FILE__, NULL, 0 );
00125     exit( 1 );
00126 }

Here is the call graph for this function:


Variable Documentation

Definition at line 11 of file test_utils.c.


Generated on 26 Jan 2016 for PAPI by  doxygen 1.6.1