PAPI  5.6.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
get_event_component.c File Reference
Include dependency graph for get_event_component.c:

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 17 of file get_event_component.c.

18 {
19 
20  int i;
21  int retval;
22  PAPI_event_info_t info;
23  int numcmp, cid, our_cid;
24  const PAPI_component_info_t* cmpinfo;
25 
26  /* Set TESTS_QUIET variable */
27  tests_quiet( argc, argv );
28 
29  /* Init PAPI library */
31  if ( retval != PAPI_VER_CURRENT ) {
32  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
33  }
34 
35  numcmp = PAPI_num_components( );
36 
37 
38  /* Loop through all components */
39  for( cid = 0; cid < numcmp; cid++ )
40  {
41  cmpinfo = PAPI_get_component_info( cid );
42 
43  if (cmpinfo == NULL)
44  {
45  test_fail( __FILE__, __LINE__, "PAPI_get_component_info", 2 );
46  }
47 
48  if (cmpinfo->disabled && !TESTS_QUIET) {
49  printf( "Name: %-23s %s\n", cmpinfo->name ,cmpinfo->description);
50  printf(" \\-> Disabled: %s\n",cmpinfo->disabled_reason);
51  continue;
52  }
53 
54 
55  i = 0 | PAPI_NATIVE_MASK;
56  retval = PAPI_enum_cmp_event( &i, PAPI_ENUM_FIRST, cid );
57  if (retval!=PAPI_OK) continue;
58 
59  do {
60  if (PAPI_get_event_info( i, &info ) != PAPI_OK) {
61  if (!TESTS_QUIET) {
62  printf("Getting information about event: %#x failed\n", i);
63  }
64  continue;
65  }
66  our_cid=PAPI_get_event_component(i);
67 
68  if (our_cid!=cid) {
69  if (!TESTS_QUIET) {
70  printf("%d %d %s\n",cid,our_cid,info.symbol);
71  }
72  test_fail( __FILE__, __LINE__, "component mismatch", 1 );
73  }
74 
75  if (!TESTS_QUIET) {
76  printf("%d %d %s\n",cid,our_cid,info.symbol);
77  }
78 
79 
80  } while ( PAPI_enum_cmp_event( &i, PAPI_ENUM_EVENTS, cid ) == PAPI_OK );
81 
82  }
83 
84  test_pass( __FILE__ );
85 
86  return 0;
87 }
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:629
#define PAPI_NATIVE_MASK
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
Definition: papi.c:796
void test_pass(const char *filename)
Definition: test_utils.c:432
int PAPI_num_components(void)
Definition: papi.c:4387
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:966
return PAPI_OK
Definition: linux-nvml.c:497
int int argc
Definition: iozone.c:1609
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:835
char ** argv
Definition: iozone.c:1610
char disabled_reason[PAPI_MAX_STR_LEN]
Definition: papi.h:636
int PAPI_library_init(int version)
Definition: papi.c:500
int i
Definition: fileop.c:140
char description[PAPI_MAX_STR_LEN]
Definition: papi.h:632
int PAPI_enum_cmp_event(int *EventCode, int modifier, int cidx)
Definition: papi.c:1357
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
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:225
int PAPI_get_event_component(int EventCode)
Definition: papi.c:6583

Here is the call graph for this function: