PAPI  5.3.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
get_event_component.c
Go to the documentation of this file.
1 /*
2  * File: get_event_component.c
3  * Author: Vince Weaver
4  * vweaver1@eecs.utk.edu
5  */
6 
7 /*
8  This test makes sure PAPI_get_event_component() works
9 */
10 
11 #include "papi_test.h"
12 
13 int
14 main( int argc, char **argv )
15 {
16 
17  int i;
18  int retval;
19  PAPI_event_info_t info;
20  int numcmp, cid, our_cid;
21  const PAPI_component_info_t* cmpinfo;
22 
23  /* Set TESTS_QUIET variable */
24  tests_quiet( argc, argv );
25 
26  /* Init PAPI library */
28  if ( retval != PAPI_VER_CURRENT ) {
29  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
30  }
31 
32  numcmp = PAPI_num_components( );
33 
34 
35  /* Loop through all components */
36  for( cid = 0; cid < numcmp; cid++ )
37  {
38  cmpinfo = PAPI_get_component_info( cid );
39 
40  if (cmpinfo == NULL)
41  {
42  test_fail( __FILE__, __LINE__, "PAPI_get_component_info", 2 );
43  }
44 
45  if (cmpinfo->disabled)
46  {
47  printf( "Name: %-23s %s\n", cmpinfo->name ,cmpinfo->description);
48  printf(" \\-> Disabled: %s\n",cmpinfo->disabled_reason);
49  continue;
50  }
51 
52 
53  i = 0 | PAPI_NATIVE_MASK;
54  retval = PAPI_enum_cmp_event( &i, PAPI_ENUM_FIRST, cid );
55  if (retval!=PAPI_OK) continue;
56 
57  do {
58  retval = PAPI_get_event_info( i, &info );
59  our_cid=PAPI_get_event_component(i);
60 
61  if (our_cid!=cid) {
62  if (!TESTS_QUIET) {
63  printf("%d %d %s\n",cid,our_cid,info.symbol);
64  }
65  test_fail( __FILE__, __LINE__, "component mismatch", 1 );
66  }
67 
68  if (!TESTS_QUIET) {
69  printf("%d %d %s\n",cid,our_cid,info.symbol);
70  }
71 
72 
73  } while ( PAPI_enum_cmp_event( &i, PAPI_ENUM_EVENTS, cid ) == PAPI_OK );
74 
75  }
76 
77  test_pass( __FILE__, NULL, 0 );
78 
79  return 0;
80 }
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:625
#define PAPI_NATIVE_MASK
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
Definition: papi.c:803
int PAPI_num_components(void)
Definition: papi.c:4272
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:961
return PAPI_OK
Definition: linux-nvml.c:458
tests_quiet(argc, argv)
#define printf
Definition: papi_test.h:125
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:841
int TESTS_QUIET
Definition: test_utils.c:11
char ** argv
Definition: iozone.c:1610
char disabled_reason[PAPI_MAX_STR_LEN]
Definition: papi.h:632
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:495
int i
Definition: fileop.c:140
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
char description[PAPI_MAX_STR_LEN]
Definition: papi.h:628
int PAPI_enum_cmp_event(int *EventCode, int modifier, int cidx)
Definition: papi.c:1305
ssize_t retval
Definition: libasync.c:338
int main(int argc, char **argv)
List all appio events codes and names.
int PAPI_get_event_component(int EventCode)
Definition: papi.c:6443