PAPI 7.1.0.0
Loading...
Searching...
No Matches
hwinfo.c File Reference
Include dependency graph for hwinfo.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 10 of file hwinfo.c.

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 }
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,
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 i
get information about the system hardware
initialize the PAPI library.
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_VENDOR_UNKNOWN
Definition: f90papi.h:104
static double c[MATRIX_SIZE][MATRIX_SIZE]
Definition: libmsr_basic.c:40
int TESTS_QUIET
Definition: test_utils.c:18
#define PAPI_MH_MAX_LEVELS
Definition: papi.h:739
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void validate_string(const char *name, char *s)
Definition: test_utils.c:23
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:491
void PAPI_NORETURN test_pass(const char *filename)
Definition: test_utils.c:432
Hardware info structure.
Definition: papi.h:774
char vendor_string[PAPI_MAX_STR_LEN]
Definition: papi.h:782
int totalcpus
Definition: papi.h:780
PAPI_mh_info_t mem_hierarchy
Definition: papi.h:793
int vendor
Definition: papi.h:781
int ncpu
Definition: papi.h:775
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:784
int cpu_max_mhz
Definition: papi.h:790
mh for mem hierarchy maybe?
Definition: papi.h:767
int levels
Definition: papi.h:768
PAPI_mh_level_t level[PAPI_MAX_MEM_HIERARCHY_LEVELS]
Definition: papi.h:769
PAPI_mh_tlb_info_t tlb[PAPI_MH_MAX_LEVELS]
Definition: papi.h:761
PAPI_mh_cache_info_t cache[PAPI_MH_MAX_LEVELS]
Definition: papi.h:762
int associativity
Definition: papi.h:747
int retval
Definition: zero_fork.c:53
Here is the call graph for this function: