PAPI  5.3.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
perf_event_offcore_response.c
Go to the documentation of this file.
1 /*
2  * This tests the use of offcore_response events
3  */
4 
5 #include "papi_test.h"
6 
7 #include "event_name_lib.h"
8 
9 int main( int argc, char **argv ) {
10 
11 
12  char *offcore_event=NULL;
13  char event_name[BUFSIZ];
14 
15  int retval;
16  int EventSet1 = PAPI_NULL;
17 
18  long long total_values[1];
19 
20  /* Set TESTS_QUIET variable */
21  tests_quiet( argc, argv );
22 
23  /* Init the PAPI library */
25  if ( retval != PAPI_VER_CURRENT ) {
26  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
27  }
28 
29  retval = PAPI_create_eventset(&EventSet1);
30  if (retval != PAPI_OK) {
31  test_fail(__FILE__, __LINE__, "PAPI_create_eventset",retval);
32  }
33 
34  /* Get a relevant event name */
35  offcore_event=get_offcore_event(event_name, BUFSIZ);
36  if (offcore_event==NULL) {
37  test_skip( __FILE__, __LINE__,
38  "PAPI does not support offcore on this processor", PAPI_ENOSUPP );
39  }
40 
41  retval = PAPI_add_named_event(EventSet1, offcore_event);
42  if (retval != PAPI_OK) {
43  if ( !TESTS_QUIET ) {
44  fprintf(stderr,"Error trying to add %s\n",offcore_event);
45  }
46  test_fail(__FILE__, __LINE__, "adding offcore event ",retval);
47  }
48 
49  retval = PAPI_start( EventSet1 );
50  if ( retval != PAPI_OK ) {
51  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
52  }
53 
55 
56  retval = PAPI_stop( EventSet1, total_values );
57  if ( retval != PAPI_OK ) {
58  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
59  }
60 
61  if ( !TESTS_QUIET ) {
62  printf("\t%s count = %lld\n",offcore_event,total_values[0]);
63  }
64 
65  test_pass( __FILE__, NULL, 0 );
66 
67  return 0;
68 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:23
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2225
#define NUM_FLOPS
#define PAPI_NULL
Definition: fpapi.h:13
int PAPI_add_named_event(int EventSet, char *EventName)
Definition: papi.c:1809
void test_skip(char *file, int line, char *call, int retval)
Definition: test_utils.c:614
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 TESTS_QUIET
Definition: test_utils.c:11
char ** argv
Definition: iozone.c:1610
char * get_offcore_event(char *event, int size)
Definition: event_name_lib.c:7
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:495
#define PAPI_ENOSUPP
Definition: fpapi.h:123
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1399
void do_flops(int n)
Definition: multiplex.c:23
int PAPI_start(int EventSet)
Definition: papi.c:2019
ssize_t retval
Definition: libasync.c:338
int main(int argc, char **argv)
List all appio events codes and names.
int EventSet1
Definition: zero_fork.c:40