PAPI  5.3.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 main (int argc, char **argv)
 

Variables

int TESTS_QUIET
 
unsigned char PENTIUM4
 

Function Documentation

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

Definition at line 21 of file all_native_events.c.

22 {
23  int retval;
24  long long values;
25  int EventSet = PAPI_NULL;
26 
27  /* Is there an issue with older machines? */
28  /* Disable for now, add back once we can reproduce */
29 // if ( PENTIUM4 ) {
30 // if ( strcmp( name, "REPLAY_EVENT:BR_MSP" ) == 0 ) {
31 // return 1;
32 // }
33 // }
34 
35  retval = PAPI_create_eventset( &EventSet );
36  if ( retval != PAPI_OK )
37  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
38 
39  retval = PAPI_add_event( EventSet, event_code );
40  if ( retval != PAPI_OK ) {
41  printf( "Error adding %s %d\n", name, retval );
42  return 0;
43  } else {
44  // printf( "Added %s successfully ", name );
45  }
46 
47  retval = PAPI_start( EventSet );
48  if ( retval != PAPI_OK ) {
49  PAPI_perror( "PAPI_start" );
50  } else {
51  retval = PAPI_stop( EventSet, &values );
52  if ( retval != PAPI_OK ) {
53  PAPI_perror( "PAPI_stop" );
54  return 0;
55  } else {
56  printf( "Added and Stopped %s successfully.\n", name );
57  }
58  }
59 
60 
61  retval=PAPI_cleanup_eventset( EventSet );
62  if (retval != PAPI_OK ) {
63  test_warn( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval);
64  }
65  retval=PAPI_destroy_eventset( &EventSet );
66  if (retval != PAPI_OK ) {
67  test_warn( __FILE__, __LINE__, "PAPI_destroy_eventset", retval);
68  }
69  return ( 1 );
70 }
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2225
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1597
void PAPI_perror(char *msg)
Definition: papi.c:4520
#define PAPI_NULL
Definition: fpapi.h:13
return PAPI_OK
Definition: linux-nvml.c:458
#define printf
Definition: papi_test.h:125
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
void test_warn(char *file, int line, char *call, int retval)
Definition: test_utils.c:578
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2795
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1399
int EventSet
char * name
Definition: iozone.c:23648
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1937
int PAPI_start(int EventSet)
Definition: papi.c:2019
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 73 of file all_native_events.c.

74 {
75 
76  int i, k, add_count = 0, err_count = 0, unc_count = 0, offcore_count = 0;
77  int retval;
78  PAPI_event_info_t info, info1;
79  const PAPI_hw_info_t *hwinfo = NULL;
80  const PAPI_component_info_t* cmpinfo;
81  char *Intel_i7;
82  int event_code;
83  int numcmp, cid;
84 
85  /* Set TESTS_QUIET variable */
86  tests_quiet( argc, argv );
87 
88  /* Init PAPI library */
90  if ( retval != PAPI_VER_CURRENT ) {
91  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
92  }
93 
94  retval = papi_print_header( "Test case ALL_NATIVE_EVENTS: Available "
95  "native events and hardware "
96  "information.\n",
97  &hwinfo );
98  if ( retval != PAPI_OK ) {
99  test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
100  }
101 
102  numcmp = PAPI_num_components( );
103 
104  /* we need a little exception processing if it's a Core i7 */
105  /* Unfortunately, this test never succeeds... */
106  Intel_i7 = strstr( hwinfo->model_string, "Intel Core i7" );
107 
108  /* Loop through all components */
109  for( cid = 0; cid < numcmp; cid++ ) {
110 
111 
112  cmpinfo = PAPI_get_component_info( cid );
113 
114  if (cmpinfo == NULL)
115  {
116  test_fail( __FILE__, __LINE__, "PAPI_get_component_info", 2 );
117  }
118 
119  if (cmpinfo->disabled)
120  {
121  printf( "Name: %-23s %s\n", cmpinfo->name ,cmpinfo->description);
122  printf(" \\-> Disabled: %s\n",cmpinfo->disabled_reason);
123  continue;
124  }
125 
126 
127 
128  /* For platform independence, always ASK FOR the first event */
129  /* Don't just assume it'll be the first numeric value */
130  i = 0 | PAPI_NATIVE_MASK;
131  retval = PAPI_enum_cmp_event( &i, PAPI_ENUM_FIRST, cid );
132 
133  do {
134  retval = PAPI_get_event_info( i, &info );
135 
136  /* Skip OFFCORE and UNCORE events */
137  /* Adding them will fail currently */
138  if ( Intel_i7 || ( hwinfo->vendor == PAPI_VENDOR_INTEL ) ) {
139  if ( !strncmp( info.symbol, "UNC_", 4 ) ) {
140  unc_count++;
141  continue;
142  }
143  if ( !strncmp( info.symbol, "OFFCORE_RESPONSE_0", 18 ) ) {
144  offcore_count++;
145  continue;
146  }
147  }
148 
149  /* Enumerate all umasks */
150  k = i;
152  do {
153  retval = PAPI_get_event_info( k, &info1 );
154  event_code = ( int ) info1.event_code;
155  if ( check_event( event_code, info1.symbol ) ) {
156  add_count++;
157  }
158  else {
159  err_count++;
160  }
161  } while ( PAPI_enum_cmp_event( &k, PAPI_NTV_ENUM_UMASKS, cid ) == PAPI_OK );
162  } else {
163  /* Event didn't have any umasks */
164  event_code = ( int ) info.event_code;
165  if ( check_event( event_code, info.symbol ) ) {
166  add_count++;
167  }
168  else {
169  err_count++;
170  }
171  }
172 
173  } while ( PAPI_enum_cmp_event( &i, PAPI_ENUM_EVENTS, cid ) == PAPI_OK );
174 
175  }
176  printf( "\n\nSuccessfully found and added %d events "
177  "(in %d eventsets).\n",
178  add_count , add_count);
179 
180  if ( err_count ) {
181  printf( "Failed to add %d events.\n", err_count );
182  }
183 
184  if (( unc_count ) || (offcore_count)) {
185  char warning[BUFSIZ];
186  sprintf(warning,"%d Uncore and %d Offcore events were ignored",
187  unc_count,offcore_count);
188  test_warn( __FILE__, __LINE__, warning, 1 );
189  }
190 
191  if ( add_count > 0 ) {
192  test_pass( __FILE__, NULL, 0 );
193  }
194  else {
195  test_fail( __FILE__, __LINE__, "No events added", 1 );
196  }
197 
198  exit( 1 );
199 }
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:625
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
#define PAPI_NATIVE_MASK
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
Definition: papi.c:803
Hardware info structure.
Definition: papi.h:775
int papi_print_header(char *prompt, const PAPI_hw_info_t **hwinfo)
Definition: test_utils.c:21
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
static int check_event(int event_code, char *name)
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:841
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
void test_warn(char *file, int line, char *call, int retval)
Definition: test_utils.c:578
int k
Definition: iozone.c:19136
#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
#define PAPI_VENDOR_INTEL
Definition: papi.h:346
int vendor
Definition: papi.h:782
int
Definition: iozone.c:18528
char model_string[PAPI_MAX_STR_LEN]
Definition: papi.h:785
unsigned int event_code
Definition: papi.h:959
ssize_t retval
Definition: libasync.c:338
void exit()
if(gettimeofday(&tp,(struct timezone *) NULL)==-1) perror("gettimeofday")

Here is the call graph for this function:

Variable Documentation

unsigned char PENTIUM4
int TESTS_QUIET

Definition at line 11 of file test_utils.c.