|
PAPI
5.0.1.0
|
00001 /* This file performs the following test: valid fields in hw_info */ 00002 00003 #include "papi_test.h" 00004 00005 int 00006 main( int argc, char **argv ) 00007 { 00008 int retval, i, j; 00009 const PAPI_hw_info_t *hwinfo = NULL; 00010 const PAPI_mh_info_t *mh; 00011 00012 tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */ 00013 00014 retval = PAPI_library_init( PAPI_VER_CURRENT ); 00015 if ( retval != PAPI_VER_CURRENT ) 00016 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval ); 00017 00018 retval = 00019 papi_print_header 00020 ( "Test case hwinfo.c: Check output of PAPI_get_hardware_info.\n", 00021 &hwinfo ); 00022 if ( retval != PAPI_OK ) 00023 test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 ); 00024 00025 mh = &hwinfo->mem_hierarchy; 00026 00027 validate_string( ( char * ) hwinfo->vendor_string, "vendor_string" ); 00028 validate_string( ( char * ) hwinfo->model_string, "model_string" ); 00029 00030 if ( hwinfo->vendor == PAPI_VENDOR_UNKNOWN ) 00031 test_fail( __FILE__, __LINE__, "Vendor unknown", 0 ); 00032 00033 if ( hwinfo->cpu_max_mhz == 0.0 ) 00034 test_fail( __FILE__, __LINE__, "Mhz unknown", 0 ); 00035 00036 if ( hwinfo->ncpu < 1 ) 00037 test_fail( __FILE__, __LINE__, "ncpu < 1", 0 ); 00038 00039 if ( hwinfo->totalcpus < 1 ) 00040 test_fail( __FILE__, __LINE__, "totalcpus < 1", 0 ); 00041 00042 /* if ( PAPI_get_opt( PAPI_MAX_HWCTRS, NULL ) < 1 ) 00043 test_fail( __FILE__, __LINE__, "get_opt(MAX_HWCTRS) < 1", 0 ); 00044 00045 if ( PAPI_get_opt( PAPI_MAX_MPX_CTRS, NULL ) < 1 ) 00046 test_fail( __FILE__, __LINE__, "get_opt(MAX_MPX_CTRS) < 1", 0 );*/ 00047 00048 if ( mh->levels < 0 ) 00049 test_fail( __FILE__, __LINE__, "max mh level < 0", 0 ); 00050 00051 printf( "Max level of TLB or Cache: %d\n", mh->levels ); 00052 for ( i = 0; i < mh->levels; i++ ) { 00053 for ( j = 0; j < PAPI_MH_MAX_LEVELS; j++ ) { 00054 const PAPI_mh_cache_info_t *c = &mh->level[i].cache[j]; 00055 const PAPI_mh_tlb_info_t *t = &mh->level[i].tlb[j]; 00056 printf( "Level %d, TLB %d: %d, %d, %d\n", i, j, t->type, 00057 t->num_entries, t->associativity ); 00058 printf( "Level %d, Cache %d: %d, %d, %d, %d, %d\n", i, j, c->type, 00059 c->size, c->line_size, c->num_lines, c->associativity ); 00060 } 00061 } 00062 00063 test_pass( __FILE__, 0, 0 ); 00064 00065 exit( 1 ); 00066 }