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

Go to the source code of this file.

Functions

static int check_event (int event_code, char *name, int quiet)
 
int main (int argc, char **argv)
 

Function Documentation

static int check_event ( int  event_code,
char *  name,
int  quiet 
)
static

Definition at line 23 of file all_native_events.c.

24 {
25  int retval;
26  long long values;
27  int EventSet = PAPI_NULL;
28 
29  /* Possibly there was an older issue with the */
30  /* REPLAY_EVENT:BR_MSP on Pentium4 ??? */
31 
32  /* Create an eventset */
33  retval = PAPI_create_eventset( &EventSet );
34  if ( retval != PAPI_OK ) {
35  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
36  }
37 
38  /* Add the event */
39  retval = PAPI_add_event( EventSet, event_code );
40  if ( retval != PAPI_OK ) {
41  if (!quiet) printf( "Error adding %s %d\n", name, retval );
42  return retval;
43  }
44 
45  /* Start the event */
46  retval = PAPI_start( EventSet );
47  if ( retval != PAPI_OK ) {
48  PAPI_perror( "PAPI_start" );
49  } else {
50  retval = PAPI_stop( EventSet, &values );
51  if ( retval != PAPI_OK ) {
52  PAPI_perror( "PAPI_stop" );
53  return retval;
54  } else {
55  if (!quiet) printf( "Added and Stopped %s successfully.\n", name );
56  }
57  }
58 
59  /* Cleanup the eventset */
60  retval=PAPI_cleanup_eventset( EventSet );
61  if (retval != PAPI_OK ) {
62  test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval);
63  }
64 
65  /* Destroy the eventset */
66  retval=PAPI_destroy_eventset( &EventSet );
67  if (retval != PAPI_OK ) {
68  test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval);
69  }
70 
71  return PAPI_OK;
72 }
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2314
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1663
#define PAPI_NULL
Definition: papi.h:292
int EventSet
return PAPI_OK
Definition: linux-nvml.c:497
int quiet
Definition: rapl_overflow.c:18
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2890
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1464
printf("\tTry: -i 0 -i 1 \n\n")
char * name
Definition: iozone.c:23648
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:2014
int PAPI_start(int EventSet)
Definition: papi.c:2096
void PAPI_perror(const char *msg)
Definition: papi.c:4653
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char **  argv 
)

Definition at line 75 of file all_native_events.c.

76 {
77 
78  int i, k, add_count = 0, err_count = 0;
79  int retval;
80  PAPI_event_info_t info, info1;
81  const PAPI_hw_info_t *hwinfo = NULL;
82  const PAPI_component_info_t* cmpinfo;
83  int event_code;
84  int numcmp, cid;
85  int quiet;
86 
87  /* Set quiet variable */
88  quiet=tests_quiet( argc, argv );
89 
90  /* Init PAPI library */
92  if ( retval != PAPI_VER_CURRENT ) {
93  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
94  }
95 
96  if (!quiet) {
97  printf("Test case ALL_NATIVE_EVENTS: Available "
98  "native events and hardware "
99  "information.\n");
100  }
101 
102  hwinfo=PAPI_get_hardware_info();
103  if ( hwinfo == NULL ) {
104  test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
105  }
106 
107  numcmp = PAPI_num_components( );
108 
109  /* Loop through all components */
110  for( cid = 0; cid < numcmp; cid++ ) {
111 
112 
113  cmpinfo = PAPI_get_component_info( cid );
114  if (cmpinfo == NULL) {
115  test_fail( __FILE__, __LINE__, "PAPI_get_component_info", 2 );
116  }
117 
118  /* Skip disabled components */
119  if (cmpinfo->disabled) {
120  if (!quiet) {
121  printf( "Name: %-23s %s\n",
122  cmpinfo->name ,cmpinfo->description);
123  printf(" \\-> Disabled: %s\n",
124  cmpinfo->disabled_reason);
125  }
126  continue;
127  }
128 
129  /* For platform independence, always ASK FOR the first event */
130  /* Don't just assume it'll be the first numeric value */
131  i = 0 | PAPI_NATIVE_MASK;
132  retval = PAPI_enum_cmp_event( &i, PAPI_ENUM_FIRST, cid );
133 
134  do {
135  retval = PAPI_get_event_info( i, &info );
136 
137  /* We used to skip OFFCORE and UNCORE events */
138  /* Why? */
139 
140  /* Enumerate all umasks */
141  k = i;
143  do {
144  retval = PAPI_get_event_info( k, &info1 );
145  event_code = ( int ) info1.event_code;
146  if ( check_event( event_code, info1.symbol, quiet ) == PAPI_OK ) {
147  add_count++;
148  }
149  else {
150  err_count++;
151  }
152  } while ( PAPI_enum_cmp_event( &k, PAPI_NTV_ENUM_UMASKS, cid ) == PAPI_OK );
153  } else {
154  /* Event didn't have any umasks */
155  event_code = ( int ) info.event_code;
156  if ( check_event( event_code, info.symbol, quiet ) == PAPI_OK) {
157  add_count++;
158  }
159  else {
160  err_count++;
161  }
162  }
163 
164  } while ( PAPI_enum_cmp_event( &i, PAPI_ENUM_EVENTS, cid ) == PAPI_OK );
165 
166  }
167 
168  if (!quiet) {
169  printf( "\n\nSuccessfully found and added %d events "
170  "(in %d eventsets).\n",
171  add_count , add_count);
172  }
173 
174  if ( err_count ) {
175  if (!quiet) printf( "Failed to add %d events.\n", err_count );
176  }
177 
178  if ( add_count <= 0 ) {
179  test_fail( __FILE__, __LINE__, "No events added", 1 );
180  }
181 
182  test_pass( __FILE__ );
183 
184  return 0;
185 }
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
Hardware info structure.
Definition: papi.h:780
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
int quiet
Definition: rapl_overflow.c:18
int k
Definition: iozone.c:19136
static int check_event(int event_code, char *name, int quiet)
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(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
Definition: iozone.c:18528
unsigned int event_code
Definition: papi.h:964
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
if(gettimeofday(&tp,(struct timezone *) NULL)==-1) perror("gettimeofday")

Here is the call graph for this function: