PAPI  5.3.2.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 OLD_TEST_DRIVER
 
#define CPP_TEST_FAIL(string, retval)   test_fail(__FILE__, __LINE__, string, retval);
 
#define CPP_TEST_PASS()   { test_pass(__FILE__, NULL, 0); exit(0); }
 
#define CPP_TEST_SKIP()   { test_skip(__FILE__,__LINE__,NULL,0); exit(0); }
 
#define EVENTSLEN   2
 
#define QUIETPRINTF   if (!TESTS_QUIET) printf
 

Functions

int main (int argc, char **argv)
 

Variables

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

Macro Definition Documentation

#define CPP_TEST_FAIL (   string,
  retval 
)    test_fail(__FILE__, __LINE__, string, retval);

Definition at line 8 of file derived.c.

#define CPP_TEST_PASS ( )    { test_pass(__FILE__, NULL, 0); exit(0); }

Definition at line 9 of file derived.c.

#define CPP_TEST_SKIP ( )    { test_skip(__FILE__,__LINE__,NULL,0); exit(0); }

Definition at line 10 of file derived.c.

#define EVENTSLEN   2

Definition at line 17 of file derived.c.

#define OLD_TEST_DRIVER

Definition at line 5 of file derived.c.

#define QUIETPRINTF   if (!TESTS_QUIET) printf

Definition at line 19 of file derived.c.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 25 of file derived.c.

26 {
27  int retval, tmp;
28  int EventSet = PAPI_NULL;
29  int i;
30  PAPI_event_info_t info;
31  long long values;
32  char event_name[PAPI_MAX_STR_LEN], add_event_str[PAPI_MAX_STR_LEN];
33 
34 /*#if !defined(i386) || !defined(linux)
35  CPP_TEST_SKIP();
36 #endif
37 */
38  tests_quiet( argc, argv ); /* Set TESTS_QUIET variable */
39 
41  if ( retval != PAPI_VER_CURRENT )
42  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
43 
44  QUIETPRINTF( "Test case %s: start, stop with a derived counter.\n",
45  __FILE__ );
46  QUIETPRINTF( "------------------------------------------------\n" );
47  tmp = PAPI_get_opt( PAPI_DEFDOM, NULL );
48  QUIETPRINTF( "Default domain is: %d (%s)\n", tmp,
49  stringify_all_domains( tmp ) );
50  tmp = PAPI_get_opt( PAPI_DEFGRN, NULL );
51  QUIETPRINTF( "Default granularity is: %d (%s)\n\n", tmp,
52  stringify_granularity( tmp ) );
53 
54  i = PAPI_PRESET_MASK;
55  do {
56  if ( PAPI_get_event_info( i, &info ) == PAPI_OK ) {
57  if ( info.count > 1 ) {
58  PAPI_events[0] = ( unsigned int ) info.event_code;
59  break;
60  }
61  }
62  } while ( PAPI_enum_event( &i, 0 ) == PAPI_OK );
63 
64  if ( PAPI_events[0] == 0 )
65  CPP_TEST_SKIP( );
66 
67  retval = PAPI_create_eventset( &EventSet );
68  if ( retval != PAPI_OK )
69  CPP_TEST_FAIL( "PAPI_create_eventset", retval );
70 
71  for ( i = 0; i < PAPI_events_len; i++ ) {
72  PAPI_event_code_to_name( ( int ) PAPI_events[i], event_name );
73  if ( !TESTS_QUIET )
74  QUIETPRINTF( "Adding %s\n", event_name );
75  retval = PAPI_add_event( EventSet, ( int ) PAPI_events[i] );
76  if ( retval != PAPI_OK )
77  CPP_TEST_FAIL( "PAPI_add_event", retval );
78  }
79 
80  retval = PAPI_start( EventSet );
81  if ( retval != PAPI_OK )
82  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
83 
84  QUIETPRINTF( "Running do_stuff().\n" );
85 
86  do_stuff( );
87 
88  retval = PAPI_stop( EventSet, &values );
89  if ( retval != PAPI_OK )
90  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
91 
92  sprintf( add_event_str, "%-12s : \t", event_name );
93  QUIETPRINTF( TAB1, add_event_str, values );
94  QUIETPRINTF( "------------------------------------------------\n" );
95 
96  retval = PAPI_cleanup_eventset( EventSet ); /* JT */
97  if ( retval != PAPI_OK )
98  CPP_TEST_FAIL( "PAPI_cleanup_eventset", retval );
99 
100  retval = PAPI_destroy_eventset( &EventSet );
101  if ( retval != PAPI_OK )
102  CPP_TEST_FAIL( "PAPI_cleanup_eventset", retval );
103 
104 #ifndef OLD_TEST_DRIVER
105  PAPI_shutdown( );
106 #endif
107 
108  QUIETPRINTF( "Verification: Does it produce a non-zero value?\n" );
109 
110  if ( values != 0 ) {
111  QUIETPRINTF( "Yes: " );
112  QUIETPRINTF( LLDFMT, values );
113  QUIETPRINTF( "\n" );
114  }
115 
116  CPP_TEST_PASS( );
117 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:23
sprintf(splash[splash_line++],"\tIozone: Performance Test of File I/O\n")
unsigned int count
Definition: papi.h:982
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 CPP_TEST_SKIP()
Definition: derived.c:10
char * stringify_granularity(int granularity)
Definition: test_utils.c:429
void do_stuff(void)
Definition: do_loops.c:249
#define TAB1
Definition: papi_test.h:112
int PAPI_enum_event(int *EventCode, int modifier)
Definition: papi.c:1148
#define QUIETPRINTF
Definition: derived.c:19
return PAPI_OK
Definition: linux-nvml.c:458
tests_quiet(argc, argv)
#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: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
int i
Definition: fileop.c:140
char * stringify_all_domains(int domains)
Definition: test_utils.c:369
void PAPI_shutdown(void)
Definition: papi.c:4357
int PAPI_get_opt(int option, PAPI_option_t *ptr)
Definition: papi.c:4041
#define CPP_TEST_FAIL(string, retval)
Definition: derived.c:8
#define PAPI_DEFDOM
Definition: fpapi.h:49
#define PAPI_VER_CURRENT
Definition: fpapi.h:14
#define PAPI_DEFGRN
Definition: fpapi.h:51
int PAPI_cleanup_eventset(int EventSet)
Definition: papi.c:2805
int PAPI_create_eventset(int *EventSet)
Definition: papi.c:1406
int PAPI_event_code_to_name(int EventCode, char *out)
Definition: papi.c:924
#define LLDFMT
Definition: papi_test.h:118
int EventSet
static const int PAPI_events_len
Definition: derived.c:21
#define CPP_TEST_PASS()
Definition: derived.c:9
int
Definition: iozone.c:18528
unsigned int PAPI_events[EVENTSLEN]
Definition: derived.c:20
int PAPI_destroy_eventset(int *EventSet)
Definition: papi.c:1944
int PAPI_start(int EventSet)
Definition: papi.c:2026
unsigned int event_code
Definition: papi.h:959
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

Here is the call graph for this function:

Variable Documentation

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

Definition at line 20 of file derived.c.

const int PAPI_events_len = 1
static

Definition at line 21 of file derived.c.

int TESTS_QUIET

Definition at line 11 of file test_utils.c.