PAPI  5.4.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 && !TESTS_QUIET) {
46  printf( "Name: %-23s %s\n", cmpinfo->name ,cmpinfo->description);
47  printf(" \\-> Disabled: %s\n",cmpinfo->disabled_reason);
48  continue;
49  }
50 
51 
52  i = 0 | PAPI_NATIVE_MASK;
53  retval = PAPI_enum_cmp_event( &i, PAPI_ENUM_FIRST, cid );
54  if (retval!=PAPI_OK) continue;
55 
56  do {
57  if (PAPI_get_event_info( i, &info ) != PAPI_OK) {
58  if (!TESTS_QUIET) {
59  printf("Getting information about event: %#x failed\n", i);
60  }
61  continue;
62  }
63  our_cid=PAPI_get_event_component(i);
64 
65  if (our_cid!=cid) {
66  if (!TESTS_QUIET) {
67  printf("%d %d %s\n",cid,our_cid,info.symbol);
68  }
69  test_fail( __FILE__, __LINE__, "component mismatch", 1 );
70  }
71 
72  if (!TESTS_QUIET) {
73  printf("%d %d %s\n",cid,our_cid,info.symbol);
74  }
75 
76 
77  } while ( PAPI_enum_cmp_event( &i, PAPI_ENUM_EVENTS, cid ) == PAPI_OK );
78 
79  }
80 
81  test_pass( __FILE__, NULL, 0 );
82 
83  return 0;
84 }
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:626
#define PAPI_NATIVE_MASK
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
Definition: papi.c:807
int PAPI_num_components(void)
Definition: papi.c:4326
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:963
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:846
int TESTS_QUIET
Definition: test_utils.c:11
char ** argv
Definition: iozone.c:1610
char disabled_reason[PAPI_MAX_STR_LEN]
Definition: papi.h:633
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:497
int i
Definition: fileop.c:140
char description[PAPI_MAX_STR_LEN]
Definition: papi.h:629
int PAPI_enum_cmp_event(int *EventCode, int modifier, int cidx)
Definition: papi.c:1324
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:223
int main(int argc, char **argv)
List all appio events codes and names.
int PAPI_get_event_component(int EventCode)
Definition: papi.c:6509