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

Go to the source code of this file.

Macros

#define EVENTSLEN   2
 

Functions

int main (int argc, char **argv)
 

Variables

unsigned int PAPI_events [EVENTSLEN] = { 0, 0 }
 
static const int PAPI_events_len = 1
 

Macro Definition Documentation

#define EVENTSLEN   2

Definition at line 11 of file derived.c.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 17 of file derived.c.

18 {
19  int retval, tmp;
20  int EventSet = PAPI_NULL;
21  int i;
22  PAPI_event_info_t info;
23  long long values;
24  char event_name[PAPI_MAX_STR_LEN], add_event_str[PAPI_MAX_STR_LEN];
25  int quiet=0;
26 
27  /* Set TESTS_QUIET variable */
28  quiet=tests_quiet( argc, argv );
29 
31  if ( retval != PAPI_VER_CURRENT ) {
32  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
33  }
34 
35  if (!quiet) {
36  printf( "Test case %s: start, stop with a derived counter.\n",
37  __FILE__ );
38  printf( "------------------------------------------------\n" );
39  tmp = PAPI_get_opt( PAPI_DEFDOM, NULL );
40  printf( "Default domain is: %d (%s)\n", tmp,
41  stringify_all_domains( tmp ) );
42  tmp = PAPI_get_opt( PAPI_DEFGRN, NULL );
43  printf( "Default granularity is: %d (%s)\n\n", tmp,
44  stringify_granularity( tmp ) );
45  }
46 
47  i = PAPI_PRESET_MASK;
48  do {
49  if ( PAPI_get_event_info( i, &info ) == PAPI_OK ) {
50  if ( info.count > 1 ) {
51  PAPI_events[0] = ( unsigned int ) info.event_code;
52  break;
53  }
54  }
55  } while ( PAPI_enum_event( &i, 0 ) == PAPI_OK );
56 
57  if ( PAPI_events[0] == 0 ) {
58  test_skip(__FILE__, __LINE__, "No events found", 0);
59  }
60 
61  retval = PAPI_create_eventset( &EventSet );
62  if ( retval != PAPI_OK ) {
63  test_fail(__FILE__, __LINE__, "PAPI_create_eventset", retval );
64  }
65 
66  for ( i = 0; i < PAPI_events_len; i++ ) {
67  PAPI_event_code_to_name( ( int ) PAPI_events[i], event_name );
68  if ( !quiet ) {
69  printf( "Adding %s\n", event_name );
70  }
71  retval = PAPI_add_event( EventSet, ( int ) PAPI_events[i] );
72  if ( retval != PAPI_OK ) {
73  test_fail(__FILE__, __LINE__, "PAPI_add_event", retval );
74  }
75  }
76 
77  retval = PAPI_start( EventSet );
78  if ( retval != PAPI_OK ) {
79  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
80  }
81 
82  if (!quiet) printf( "Running do_stuff().\n" );
83 
84  do_stuff( );
85 
86  retval = PAPI_stop( EventSet, &values );
87  if ( retval != PAPI_OK ) {
88  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
89  }
90 
91  if (!quiet) {
92 
93  sprintf( add_event_str, "%-12s : \t", event_name );
94  printf( TAB1, add_event_str, values );
95  printf( "------------------------------------------------\n" );
96  }
97 
98  retval = PAPI_cleanup_eventset( EventSet ); /* JT */
99  if ( retval != PAPI_OK ) {
100  test_fail(__FILE__,__LINE__, "PAPI_cleanup_eventset", retval );
101  }
102 
103  retval = PAPI_destroy_eventset( &EventSet );
104  if ( retval != PAPI_OK ) {
105  test_fail(__FILE__,__LINE__, "PAPI_cleanup_eventset", retval );
106  }
107 
108  if (!quiet) printf( "Verification: Does it produce a non-zero value?\n" );
109 
110  if ( values != 0 ) {
111  if (!quiet) {
112  printf( "Yes: " );
113  printf( LLDFMT, values );
114  printf( "\n" );
115  }
116  }
117  else {
118  test_fail(__FILE__,__LINE__, "Validation", 1 );
119  }
120 
121  test_pass(__FILE__);
122 
123  return 0;
124 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
unsigned int count
Definition: papi.h:987
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2314
void test_pass(const char *filename)
Definition: test_utils.c:432
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1663
char * stringify_granularity(int granularity)
Definition: test_utils.c:353
#define PAPI_NULL
Definition: papi.h:292
void do_stuff(void)
Definition: do_loops.c:256
#define TAB1
Definition: papi_test.h:88
int PAPI_enum_event(int *EventCode, int modifier)
Definition: papi.c:1152
int EventSet
return PAPI_OK
Definition: linux-nvml.c:497
#define PAPI_PRESET_MASK
int int argc
Definition: iozone.c:1609
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
Definition: papi.c:835
void test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:559
char ** argv
Definition: iozone.c:1610
int PAPI_library_init(int version)
Definition: papi.c:500
int i
Definition: fileop.c:140
char * stringify_all_domains(int domains)
Definition: test_utils.c:293
int quiet
Definition: rapl_overflow.c:18
int PAPI_get_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:4143
#define PAPI_DEFGRN
Definition: papi.h:434
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2890
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1464
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:915
#define LLDFMT
Definition: papi_test.h:94
printf("\tTry: -i 0 -i 1 \n\n")
static const int PAPI_events_len
Definition: derived.c:14
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
void test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:468
int
Definition: iozone.c:18528
#define PAPI_DEFDOM
Definition: papi.h:432
unsigned int PAPI_events[EVENTSLEN]
Definition: derived.c:13
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:2014
#define PAPI_MAX_STR_LEN
Definition: papi.h:465
int PAPI_start(int EventSet)
Definition: papi.c:2096
unsigned int event_code
Definition: papi.h:964
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
long long tmp
Definition: iozone.c:12031
#define PAPI_VER_CURRENT
Definition: papi.h:225

Here is the call graph for this function:

Variable Documentation

unsigned int PAPI_events[EVENTSLEN] = { 0, 0 }

Definition at line 13 of file derived.c.

const int PAPI_events_len = 1
static

Definition at line 14 of file derived.c.