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

Go to the source code of this file.

Functions

static void test_continue (char *call, int retval)
 
int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 12 of file code2name.c.

13 {
14  int retval;
15  int code = PAPI_TOT_CYC, last;
17  const PAPI_hw_info_t *hwinfo = NULL;
18  const PAPI_component_info_t *cmp_info;
19 
20  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
21 
23  if ( retval != PAPI_VER_CURRENT )
24  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
25 
26  retval =
28  ( "Test case code2name.c: Check limits and indexing of event tables.\n",
29  &hwinfo );
30  if ( retval != PAPI_OK )
31  test_fail( __FILE__, __LINE__, "PAPI_get_hardware_info", 2 );
32 
33  printf( "Looking for PAPI_TOT_CYC...\n" );
34  retval = PAPI_event_code_to_name( code, event_name );
35  if ( retval != PAPI_OK )
36  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
37  printf( "Found |%s|\n", event_name );
38 
39  code = PAPI_FP_OPS;
40  printf( "Looking for highest defined preset event (PAPI_FP_OPS): %#x...\n",
41  code );
42  retval = PAPI_event_code_to_name( code, event_name );
43  if ( retval != PAPI_OK )
44  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
45  printf( "Found |%s|\n", event_name );
46 
48  printf( "Looking for highest allocated preset event: %#x...\n", code );
49  retval = PAPI_event_code_to_name( code, event_name );
50  if ( retval != PAPI_OK )
51  test_continue( "PAPI_event_code_to_name", retval );
52  else
53  printf( "Found |%s|\n", event_name );
54 
56  printf( "Looking for highest possible preset event: %#x...\n", code );
57  retval = PAPI_event_code_to_name( code, event_name );
58  if ( retval != PAPI_OK )
59  test_continue( "PAPI_event_code_to_name", retval );
60  else
61  printf( "Found |%s|\n", event_name );
62 
63  /* Find the first defined native event */
64  /* For platform independence, always ASK FOR the first event */
65  /* Don't just assume it'll be the first numeric value */
66  code = PAPI_NATIVE_MASK;
68 
69  printf( "Looking for first native event: %#x...\n", code );
70  retval = PAPI_event_code_to_name( code, event_name );
71  if ( retval != PAPI_OK ) {
72  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
73  }
74  else {
75  printf( "Found |%s|\n", event_name );
76  }
77 
78  /* Find the last defined native event */
79 
80  /* FIXME: hardcoded cmp 0 */
81  cmp_info = PAPI_get_component_info( 0 );
82  if ( cmp_info == NULL ) {
83  test_fail( __FILE__, __LINE__,
84  "PAPI_get_component_info", PAPI_ECMP );
85  }
86 
87  code = PAPI_NATIVE_MASK;
89 
90  while ( PAPI_enum_event( &code, PAPI_ENUM_EVENTS ) == PAPI_OK ) {
91  last=code;
92  }
93 
94  code = last;
95  printf( "Looking for last native event: %#x...\n", code );
96  retval = PAPI_event_code_to_name( code, event_name );
97  if ( retval != PAPI_OK ) {
98  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
99  }
100  else {
101  printf( "Found |%s|\n", event_name );
102  }
103 
104  /* Highly doubtful we have this many natives */
105  /* Turn on all bits *except* PRESET bit and COMPONENT bits */
106  code = PAPI_PRESET_AND_MASK;
107  printf( "Looking for highest definable native event: %#x...\n", code );
108  retval = PAPI_event_code_to_name( code, event_name );
109  if ( retval != PAPI_OK )
110  test_continue( "PAPI_event_code_to_name", retval );
111  else
112  printf( "Found |%s|\n", event_name );
113  if ( ( retval == PAPI_ENOCMP) || ( retval == PAPI_ENOEVNT ) || ( retval == PAPI_OK ) )
114  test_pass( __FILE__, 0, 0 );
115 
116  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", PAPI_EBUG );
117 
118  exit( 1 );
119 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:23
#define PAPI_NATIVE_MASK
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
Definition: papi.c:805
Hardware info structure.
Definition: papi.h:775
#define PAPI_MAX_STR_LEN
Definition: fpapi.h:43
int papi_print_header(char *prompt, const PAPI_hw_info_t **hwinfo)
Definition: test_utils.c:21
#define PAPI_ENOEVNT
Definition: fpapi.h:112
int PAPI_enum_event(int *EventCode, int modifier)
Definition: papi.c:1148
return PAPI_OK
Definition: linux-nvml.c:458
#define PAPI_FP_OPS
Definition: fpapi.h:237
#define PAPI_ENOCMP
Definition: fpapi.h:122
tests_quiet(argc, argv)
#define PAPI_PRESET_MASK
#define printf
Definition: papi_test.h:125
test_pass(__FILE__, NULL, 0)
int int argc
Definition: iozone.c:1609
char ** argv
Definition: iozone.c:1610
test_fail(__FILE__, __LINE__,"PAPI_library_init", retval)
static void test_continue(char *call, int retval)
Definition: code2name.c:6
int PAPI_library_init(int version)
Definition: papi.c:495
#define PAPI_TOT_CYC
Definition: fpapi.h:194
#define PAPI_ECMP
Definition: fpapi.h:109
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
static struct temp_event * last
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:924
#define PAPI_MAX_PRESET_EVENTS
Definition: fpapi.h:16
#define PAPI_EBUG
Definition: fpapi.h:111
int
Definition: iozone.c:18528
#define PAPI_NATIVE_AND_MASK
#define PAPI_PRESET_AND_MASK
ssize_t retval
Definition: libasync.c:338
void exit()

Here is the call graph for this function:

static void test_continue ( char *  call,
int  retval 
)
static

Definition at line 6 of file code2name.c.

7 {
8  printf( "Expected error in %s: %s\n", call, PAPI_strerror(retval) );
9 }
#define printf
Definition: papi_test.h:125
char * PAPI_strerror(int errorCode)
Definition: papi.c:4483
ssize_t retval
Definition: libasync.c:338

Here is the call graph for this function:

Here is the caller graph for this function: