PAPI  5.3.2.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
hwinfo.c
Go to the documentation of this file.
1 /* This file performs the following test: valid fields in hw_info */
2 
3 #include "papi_test.h"
4 
5 int
6 main( int argc, char **argv )
7 {
8  int retval, i, j;
9  const PAPI_hw_info_t *hwinfo = NULL;
10  const PAPI_mh_info_t *mh;
11 
12  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
13 
15  if ( retval != PAPI_VER_CURRENT )
16  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
17 
18  retval =
20  ( "Test case hwinfo.c: Check output of PAPI_get_hardware_info.\n",
21  &hwinfo );
22  if ( retval != PAPI_OK )
23  test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
24 
25  mh = &hwinfo->mem_hierarchy;
26 
27  validate_string( ( char * ) hwinfo->vendor_string, "vendor_string" );
28  validate_string( ( char * ) hwinfo->model_string, "model_string" );
29 
30  if ( hwinfo->vendor == PAPI_VENDOR_UNKNOWN )
31  test_fail( __FILE__, __LINE__, "Vendor unknown", 0 );
32 
33  if ( hwinfo->cpu_max_mhz == 0.0 )
34  test_fail( __FILE__, __LINE__, "Mhz unknown", 0 );
35 
36  if ( hwinfo->ncpu < 1 )
37  test_fail( __FILE__, __LINE__, "ncpu < 1", 0 );
38 
39  if ( hwinfo->totalcpus < 1 )
40  test_fail( __FILE__, __LINE__, "totalcpus < 1", 0 );
41 
42  /* if ( PAPI_get_opt( PAPI_MAX_HWCTRS, NULL ) < 1 )
43  test_fail( __FILE__, __LINE__, "get_opt(MAX_HWCTRS) < 1", 0 );
44 
45  if ( PAPI_get_opt( PAPI_MAX_MPX_CTRS, NULL ) < 1 )
46  test_fail( __FILE__, __LINE__, "get_opt(MAX_MPX_CTRS) < 1", 0 );*/
47 
48  if ( mh->levels < 0 )
49  test_fail( __FILE__, __LINE__, "max mh level < 0", 0 );
50 
51  printf( "Max level of TLB or Cache: %d\n", mh->levels );
52  for ( i = 0; i < mh->levels; i++ ) {
53  for ( j = 0; j < PAPI_MH_MAX_LEVELS; j++ ) {
54  const PAPI_mh_cache_info_t *c = &mh->level[i].cache[j];
55  const PAPI_mh_tlb_info_t *t = &mh->level[i].tlb[j];
56  printf( "Level %d, TLB %d: %d, %d, %d\n", i, j, t->type,
57  t->num_entries, t->associativity );
58  printf( "Level %d, Cache %d: %d, %d, %d, %d, %d\n", i, j, c->type,
59  c->size, c->line_size, c->num_lines, c->associativity );
60  }
61  }
62 
63  test_pass( __FILE__, 0, 0 );
64 
65  exit( 1 );
66 }
int levels
Definition: papi.h:769
Hardware info structure.
Definition: papi.h:775
PAPI_mh_info_t mem_hierarchy
Definition: papi.h:794
int papi_print_header(char *prompt, const PAPI_hw_info_t **hwinfo)
Definition: test_utils.c:21
int associativity
Definition: papi.h:748
return PAPI_OK
Definition: linux-nvml.c:458
tests_quiet(argc, argv)
#define printf
Definition: papi_test.h:125
double c
Definition: multiplex.c:22
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
char ** argv
Definition: iozone.c:1610
t
Definition: iozone.c:23562
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:495
PAPI_mh_cache_info_t cache[PAPI_MH_MAX_LEVELS]
Definition: papi.h:763
int i
Definition: fileop.c:140
PAPI_mh_level_t level[PAPI_MAX_MEM_HIERARCHY_LEVELS]
Definition: papi.h:770
PAPI_mh_tlb_info_t tlb[PAPI_MH_MAX_LEVELS]
Definition: papi.h:762
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
mh for mem hierarchy maybe?
Definition: papi.h:768
char vendor_string[PAPI_MAX_STR_LEN]
Definition: papi.h:783
int vendor
Definition: papi.h:782
void validate_string(char *name, char *s)
Definition: test_utils.c:84
int cpu_max_mhz
Definition: papi.h:791
int totalcpus
Definition: papi.h:781
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:785
long j
Definition: iozone.c:19135
ssize_t retval
Definition: libasync.c:338
int main(int argc, char **argv)
List all appio events codes and names.
void exit()
#define PAPI_MH_MAX_LEVELS
Definition: fpapi.h:87
int ncpu
Definition: papi.h:776
#define PAPI_VENDOR_UNKNOWN
Definition: papi.h:345