|
Packit |
577717 |
/* This file performs the following test: valid fields in hw_info */
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include <stdio.h>
|
|
Packit |
577717 |
#include <stdlib.h>
|
|
Packit |
577717 |
|
|
Packit |
577717 |
#include "papi.h"
|
|
Packit |
577717 |
#include "papi_test.h"
|
|
Packit |
577717 |
|
|
Packit |
577717 |
int
|
|
Packit |
577717 |
main( int argc, char **argv )
|
|
Packit |
577717 |
{
|
|
Packit |
577717 |
int retval, i, j;
|
|
Packit |
577717 |
const PAPI_hw_info_t *hwinfo = NULL;
|
|
Packit |
577717 |
const PAPI_mh_info_t *mh;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
|
|
Packit |
577717 |
|
|
Packit |
577717 |
retval = PAPI_library_init( PAPI_VER_CURRENT );
|
|
Packit |
577717 |
if ( retval != PAPI_VER_CURRENT )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (!TESTS_QUIET) {
|
|
Packit |
577717 |
printf( "Test case hwinfo.c: "
|
|
Packit |
577717 |
"Check output of PAPI_get_hardware_info.\n");
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
hwinfo=PAPI_get_hardware_info();
|
|
Packit |
577717 |
if ( hwinfo == NULL ) {
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
mh = &hwinfo->mem_hierarchy;
|
|
Packit |
577717 |
|
|
Packit |
577717 |
validate_string( hwinfo->vendor_string, "vendor_string" );
|
|
Packit |
577717 |
validate_string( hwinfo->model_string, "model_string" );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( hwinfo->vendor == PAPI_VENDOR_UNKNOWN )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "Vendor unknown", 0 );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( hwinfo->cpu_max_mhz == 0.0 )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "Mhz unknown", 0 );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( hwinfo->ncpu < 1 )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "ncpu < 1", 0 );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( hwinfo->totalcpus < 1 )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "totalcpus < 1", 0 );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
/* if ( PAPI_get_opt( PAPI_MAX_HWCTRS, NULL ) < 1 )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "get_opt(MAX_HWCTRS) < 1", 0 );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( PAPI_get_opt( PAPI_MAX_MPX_CTRS, NULL ) < 1 )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "get_opt(MAX_MPX_CTRS) < 1", 0 );*/
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if ( mh->levels < 0 )
|
|
Packit |
577717 |
test_fail( __FILE__, __LINE__, "max mh level < 0", 0 );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
if (!TESTS_QUIET) {
|
|
Packit |
577717 |
printf( "Max level of TLB or Cache: %d\n", mh->levels );
|
|
Packit |
577717 |
for ( i = 0; i < mh->levels; i++ ) {
|
|
Packit |
577717 |
for ( j = 0; j < PAPI_MH_MAX_LEVELS; j++ ) {
|
|
Packit |
577717 |
const PAPI_mh_cache_info_t *c = &mh->level[i].cache[j];
|
|
Packit |
577717 |
const PAPI_mh_tlb_info_t *t = &mh->level[i].tlb[j];
|
|
Packit |
577717 |
printf( "Level %d, TLB %d: %d, %d, %d\n", i, j, t->type,
|
|
Packit |
577717 |
t->num_entries, t->associativity );
|
|
Packit |
577717 |
printf( "Level %d, Cache %d: %d, %d, %d, %d, %d\n", i, j, c->type,
|
|
Packit |
577717 |
c->size, c->line_size, c->num_lines, c->associativity );
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
}
|
|
Packit |
577717 |
|
|
Packit |
577717 |
test_pass( __FILE__ );
|
|
Packit |
577717 |
|
|
Packit |
577717 |
return 0;
|
|
Packit |
577717 |
}
|