PAPI  5.6.0.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 <stdio.h>
4 #include <stdlib.h>
5 
6 #include "papi.h"
7 #include "papi_test.h"
8 
9 int
10 main( int argc, char **argv )
11 {
12  int retval, i, j;
13  const PAPI_hw_info_t *hwinfo = NULL;
14  const PAPI_mh_info_t *mh;
15 
16  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
17 
19  if ( retval != PAPI_VER_CURRENT )
20  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
21 
22  if (!TESTS_QUIET) {
23  printf( "Test case hwinfo.c: "
24  "Check output of PAPI_get_hardware_info.\n");
25  }
26  hwinfo=PAPI_get_hardware_info();
27  if ( hwinfo == NULL ) {
28  test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
29  }
30 
31  mh = &hwinfo->mem_hierarchy;
32 
33  validate_string( hwinfo->vendor_string, "vendor_string" );
34  validate_string( hwinfo->model_string, "model_string" );
35 
36  if ( hwinfo->vendor == PAPI_VENDOR_UNKNOWN )
37  test_fail( __FILE__, __LINE__, "Vendor unknown", 0 );
38 
39  if ( hwinfo->cpu_max_mhz == 0.0 )
40  test_fail( __FILE__, __LINE__, "Mhz unknown", 0 );
41 
42  if ( hwinfo->ncpu < 1 )
43  test_fail( __FILE__, __LINE__, "ncpu < 1", 0 );
44 
45  if ( hwinfo->totalcpus < 1 )
46  test_fail( __FILE__, __LINE__, "totalcpus < 1", 0 );
47 
48  /* if ( PAPI_get_opt( PAPI_MAX_HWCTRS, NULL ) < 1 )
49  test_fail( __FILE__, __LINE__, "get_opt(MAX_HWCTRS) < 1", 0 );
50 
51  if ( PAPI_get_opt( PAPI_MAX_MPX_CTRS, NULL ) < 1 )
52  test_fail( __FILE__, __LINE__, "get_opt(MAX_MPX_CTRS) < 1", 0 );*/
53 
54  if ( mh->levels < 0 )
55  test_fail( __FILE__, __LINE__, "max mh level < 0", 0 );
56 
57  if (!TESTS_QUIET) {
58  printf( "Max level of TLB or Cache: %d\n", mh->levels );
59  for ( i = 0; i < mh->levels; i++ ) {
60  for ( j = 0; j < PAPI_MH_MAX_LEVELS; j++ ) {
61  const PAPI_mh_cache_info_t *c = &mh->level[i].cache[j];
62  const PAPI_mh_tlb_info_t *t = &mh->level[i].tlb[j];
63  printf( "Level %d, TLB %d: %d, %d, %d\n", i, j, t->type,
64  t->num_entries, t->associativity );
65  printf( "Level %d, Cache %d: %d, %d, %d, %d, %d\n", i, j, c->type,
66  c->size, c->line_size, c->num_lines, c->associativity );
67  }
68  }
69  }
70 
71  test_pass( __FILE__ );
72 
73  return 0;
74 }
int levels
Definition: papi.h:774
void test_pass(const char *filename)
Definition: test_utils.c:432
Hardware info structure.
Definition: papi.h:780
PAPI_mh_info_t mem_hierarchy
Definition: papi.h:799
int associativity
Definition: papi.h:753
void validate_string(const char *name, char *s)
Definition: test_utils.c:23
double c
Definition: multiplex.c:22
int int argc
Definition: iozone.c:1609
Return codes and api definitions.
char ** argv
Definition: iozone.c:1610
t
Definition: iozone.c:23562
#define PAPI_MH_MAX_LEVELS
Definition: papi.h:745
int PAPI_library_init(int version)
Definition: papi.c:500
PAPI_mh_cache_info_t cache[PAPI_MH_MAX_LEVELS]
Definition: papi.h:768
int i
Definition: fileop.c:140
PAPI_mh_level_t level[PAPI_MAX_MEM_HIERARCHY_LEVELS]
Definition: papi.h:775
PAPI_mh_tlb_info_t tlb[PAPI_MH_MAX_LEVELS]
Definition: papi.h:767
mh for mem hierarchy maybe?
Definition: papi.h:773
char vendor_string[PAPI_MAX_STR_LEN]
Definition: papi.h:788
int vendor
Definition: papi.h:787
printf("\tTry: -i 0 -i 1 \n\n")
int TESTS_QUIET
Definition: test_utils.c:18
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
int cpu_max_mhz
Definition: papi.h:796
int totalcpus
Definition: papi.h:786
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:790
long j
Definition: iozone.c:19135
const PAPI_hw_info_t * PAPI_get_hardware_info(void)
Definition: papi.c:6185
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:225
int main(int argc, char **argv)
List all appio events codes and names.
int ncpu
Definition: papi.h:781
#define PAPI_VENDOR_UNKNOWN
Definition: papi.h:347