PAPI  5.3.2.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
describe.c
Go to the documentation of this file.
1 /* From Paul Drongowski at HP. Thanks. */
2 
3 /* I have not been able to call PAPI_describe_event without
4  incurring a segv, including the sample code on the man page.
5  I noticed that PAPI_describe_event is not exercised by the
6  PAPI test programs, so I haven't been able to check the
7  function call using known good code. (Or steal your code
8  for that matter. :-)
9 */
10 
11 /* PAPI_describe_event has been deprecated in PAPI 3, since
12  its functionality exists in other API calls. Below shows
13  several ways that this call was used, with replacement
14  code compatible with PAPI 3.
15 */
16 
17 #include "papi_test.h"
18 
19 extern int TESTS_QUIET; /* Declared in test_utils.c */
20 
21 int
22 main( int argc, char **argv )
23 {
24  int EventSet = PAPI_NULL;
25  int retval;
26  long long g1[2];
27  int eventcode = PAPI_TOT_INS;
28  char eventname[PAPI_MAX_STR_LEN];
29  PAPI_event_info_t info, info1, info2;
30 
31  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
32 
33  if ( ( retval =
35  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
36 
37 
38  if ( ( retval = PAPI_create_eventset( &EventSet ) ) != PAPI_OK )
39  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
40 
41  if ( ( retval = PAPI_query_event( eventcode ) ) != PAPI_OK )
42  test_fail( __FILE__, __LINE__, "PAPI_query_event(PAPI_TOT_INS)",
43  retval );
44 
45  if ( ( retval = PAPI_add_event( EventSet, eventcode ) ) != PAPI_OK )
46  test_fail( __FILE__, __LINE__, "PAPI_add_event(PAPI_TOT_INS)", retval );
47 
48  if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
49  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
50 
51  if ( ( retval = PAPI_stop( EventSet, g1 ) ) != PAPI_OK )
52  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
53 
54  /* Case 0, no info, should fail */
55  eventname[0] = '\0';
56  eventcode = 0;
57 /*
58  if ( ( retval = PAPI_describe_event(eventname,(int *)&eventcode,eventdesc) ) == PAPI_OK)
59  test_fail(__FILE__,__LINE__,"PAPI_describe_event",retval);
60 */
61  if ( ( retval = PAPI_get_event_info( eventcode, &info ) ) == PAPI_OK )
62  test_fail( __FILE__, __LINE__, "PAPI_get_event_info", retval );
63 
64  /* Case 1, fill in name field. */
65  eventcode = PAPI_TOT_INS;
66  eventname[0] = '\0';
67 /*
68  if ( ( retval = PAPI_describe_event(eventname,(int *)&eventcode,eventdesc) ) != PAPI_OK)
69  test_fail(__FILE__,__LINE__,"PAPI_describe_event",retval);
70 */
71  if ( ( retval = PAPI_get_event_info( eventcode, &info1 ) ) != PAPI_OK )
72  test_fail( __FILE__, __LINE__, "PAPI_get_event_info", retval );
73 
74  if ( strcmp( info1.symbol, "PAPI_TOT_INS" ) != 0 )
75  test_fail( __FILE__, __LINE__,
76  "PAPI_get_event_info symbol value is bogus", retval );
77  if ( strlen( info1.long_descr ) == 0 )
78  test_fail( __FILE__, __LINE__,
79  "PAPI_get_event_info long_descr value is bogus", retval );
80 
81  eventcode = 0;
82 
83  /* Case 2, fill in code field. */
84 /*
85  if ( ( retval = PAPI_describe_event(eventname,(int *)&eventcode,eventdesc) ) != PAPI_OK)
86  test_fail(__FILE__,__LINE__,"PAPI_describe_event",retval);
87 */
88  strcpy( eventname, info1.symbol );
89  if ( ( retval =
90  PAPI_event_name_to_code( eventname,
91  ( int * ) &eventcode ) ) != PAPI_OK )
92  test_fail( __FILE__, __LINE__, "PAPI_event_name_to_code", retval );
93 
94  if ( eventcode != PAPI_TOT_INS )
95  test_fail( __FILE__, __LINE__,
96  "PAPI_event_name_to_code code value is bogus", retval );
97 
98  if ( ( retval = PAPI_get_event_info( eventcode, &info2 ) ) != PAPI_OK )
99  test_fail( __FILE__, __LINE__, "PAPI_get_event_info", retval );
100 
101  if ( strcmp( info2.symbol, "PAPI_TOT_INS" ) != 0 )
102  test_fail( __FILE__, __LINE__,
103  "PAPI_get_event_info symbol value is bogus", retval );
104  if ( strlen( info2.long_descr ) == 0 )
105  test_fail( __FILE__, __LINE__,
106  "PAPI_get_event_info long_descr value is bogus", retval );
107 
108  test_pass( __FILE__, NULL, 0 );
109  exit( 1 );
110 }
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2232
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1604
#define PAPI_NULL
Definition: fpapi.h:13
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
#define PAPI_TOT_INS
Definition: fpapi.h:185
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:964
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:961
return PAPI_OK
Definition: linux-nvml.c:458
tests_quiet(argc, argv)
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:844
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
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1406
strcpy(filename, default_filename)
int PAPI_event_name_to_code(char *in, int *out)
Definition: papi.c:1008
int PAPI_query_event(int EventCode)
Definition: papi.c:696
int EventSet
int PAPI_start(int EventSet)
Definition: papi.c:2026
ssize_t retval
Definition: libasync.c:338
int main(int argc, char **argv)
List all appio events codes and names.
void exit()