PAPI  5.3.0.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
case1.c
Go to the documentation of this file.
1 /* From Dave McNamara at PSRV. Thanks! */
2 
3 /* If you try to add an event that doesn't exist, you get the correct error
4 message, yet you get subsequent Seg. Faults when you try to do PAPI_start and
5 PAPI_stop. I would expect some bizarre behavior if I had no events added to the
6 event set and then tried to PAPI_start but if I had successfully added one
7 event, then the 2nd one get an error when I tried to add it, is it possible for
8 PAPI_start to work but just count the first event?
9 */
10 
11 #include "papi_test.h"
12 
13 extern int TESTS_QUIET; /* Declared in test_utils.c */
14 
15 int
16 main( int argc, char **argv )
17 {
18  double c, a = 0.999, b = 1.001;
19  int n = 1000;
20  int EventSet = PAPI_NULL;
21  int retval;
22  int i, j = 0;
23  long long g1[2];
24 
25  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
26 
27  if ( ( retval =
29  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
30 
31 
32  if ( ( retval = PAPI_create_eventset( &EventSet ) ) != PAPI_OK )
33  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
34 
36  j++;
37 
38  if ( j == 1 &&
39  ( retval = PAPI_add_event( EventSet, PAPI_L2_TCM ) ) != PAPI_OK ) {
40  if ( retval != PAPI_ECNFLCT )
41  test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
42  j--; /* The event was not added */
43  }
44 
45  i = j;
47  j++;
48 
49  if ( j == ( i + 1 ) &&
50  ( retval = PAPI_add_event( EventSet, PAPI_L2_DCM ) ) != PAPI_OK ) {
51  if ( retval != PAPI_ECNFLCT )
52  test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
53  j--; /* The event was not added */
54  }
55 
56  if ( j ) {
57  if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
58  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
59  for ( i = 0; i < n; i++ ) {
60  c = a * b;
61  }
62  if (!TESTS_QUIET) fprintf(stdout,"c=%lf\n",c);
63 
64  if ( ( retval = PAPI_stop( EventSet, g1 ) ) != PAPI_OK )
65  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
66  }
67  test_pass( __FILE__, NULL, 0 );
68  exit( 1 );
69 }
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2225
#define PAPI_L2_TCM
Definition: fpapi.h:142
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1597
#define PAPI_NULL
Definition: fpapi.h:13
return PAPI_OK
Definition: linux-nvml.c:458
tests_quiet(argc, argv)
double c
Definition: multiplex.c:22
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
static double a[MATRIX_SIZE][MATRIX_SIZE]
Definition: rapl_basic.c:37
#define PAPI_ECNFLCT
Definition: fpapi.h:113
int TESTS_QUIET
Definition: test_utils.c:11
char ** argv
Definition: iozone.c:1610
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
int PAPI_library_init(int version)
Definition: papi.c:495
int i
Definition: fileop.c:140
#define PAPI_L2_DCM
Definition: fpapi.h:137
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1399
int PAPI_query_event(int EventCode)
Definition: papi.c:695
int EventSet
static double b[MATRIX_SIZE][MATRIX_SIZE]
Definition: rapl_basic.c:38
int PAPI_start(int EventSet)
Definition: papi.c:2019
long j
Definition: iozone.c:19135
ssize_t retval
Definition: libasync.c:338
int main(int argc, char **argv)
List all appio events codes and names.
void exit()
int n
Definition: mendes-alt.c:164