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

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 10 of file johnmay2.c.

11 {
12  int FPEventSet = PAPI_NULL;
13  long long values;
14  int PAPI_event, retval;
16  int quiet;
17 
18  /* Set TESTS_QUIET variable */
19  quiet=tests_quiet( argc, argv );
20 
21  /* init PAPI */
23  if (retval != PAPI_VER_CURRENT ) {
24  test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
25  }
26 
27  /* Use PAPI_FP_INS if available, otherwise use PAPI_TOT_INS */
29  PAPI_event = PAPI_FP_INS;
30  else
31  PAPI_event = PAPI_TOT_INS;
32 
33  retval = PAPI_query_event( PAPI_event );
34  if (retval != PAPI_OK ) {
35  if (!quiet) printf("Trouble querying event\n");
36  test_skip( __FILE__, __LINE__, "PAPI_query_event", retval );
37  }
38 
39  /* Create the eventset */
40  if ( ( retval = PAPI_create_eventset( &FPEventSet ) ) != PAPI_OK )
41  test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
42 
43  /* Add event to the eventset */
44  if ( ( retval = PAPI_add_event( FPEventSet, PAPI_event ) ) != PAPI_OK )
45  test_fail( __FILE__, __LINE__, "PAPI_add_event", retval );
46 
47  /* Start counting */
48  if ( ( retval = PAPI_start( FPEventSet ) ) != PAPI_OK )
49  test_fail( __FILE__, __LINE__, "PAPI_start", retval );
50 
51  /* Try to cleanup while running */
52  /* Fail test if this isn't refused */
53  if ( ( retval = PAPI_cleanup_eventset( FPEventSet ) ) != PAPI_EISRUN )
54  test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval );
55 
56  /* Try to destroy eventset while running */
57  /* Fail test if this isn't refused */
58  if ( ( retval = PAPI_destroy_eventset( &FPEventSet ) ) != PAPI_EISRUN )
59  test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
60 
61  /* do some work */
62  do_flops( 1000000 );
63 
64  /* stop counting */
65  if ( ( retval = PAPI_stop( FPEventSet, &values ) ) != PAPI_OK )
66  test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
67 
68  /* Try to destroy eventset without cleaning first */
69  /* Fail test if this isn't refused */
70  if ( ( retval = PAPI_destroy_eventset( &FPEventSet ) ) != PAPI_EINVAL )
71  test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
72 
73  /* Try to cleanup eventset. */
74  /* This should pass. */
75  if ( ( retval = PAPI_cleanup_eventset( FPEventSet ) ) != PAPI_OK )
76  test_fail( __FILE__, __LINE__, "PAPI_cleanup_eventset", retval );
77 
78  /* Try to destroy eventset. */
79  /* This should pass. */
80  if ( ( retval = PAPI_destroy_eventset( &FPEventSet ) ) != PAPI_OK )
81  test_fail( __FILE__, __LINE__, "PAPI_destroy_eventset", retval );
82 
83  /* Make sure eventset was set to PAPI_NULL */
84  if ( FPEventSet != PAPI_NULL )
85  test_fail( __FILE__, __LINE__, "FPEventSet != PAPI_NULL", retval );
86 
87  if ( !quiet ) {
88  if ( ( retval =
89  PAPI_event_code_to_name( PAPI_event, event_name ) ) != PAPI_OK )
90  test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval );
91 
92  printf( "Test case John May 2: cleanup / destroy eventset.\n" );
93  printf( "-------------------------------------------------\n" );
94  printf( "Test run : \t1\n" );
95  printf( "%s : \t", event_name );
96  printf( LLDFMT, values );
97  printf( "\n" );
98  printf( "-------------------------------------------------\n" );
99  printf( "The following messages will appear if PAPI is compiled with debug enabled:\n" );
100  printf
101  ( "\tPAPI Error Code -10: PAPI_EISRUN: EventSet is currently counting\n" );
102  printf
103  ( "\tPAPI Error Code -10: PAPI_EISRUN: EventSet is currently counting\n" );
104  printf( "\tPAPI Error Code -1: PAPI_EINVAL: Invalid argument\n" );
105  }
106  test_pass( __FILE__ );
107 
108  return 0;
109 }
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
int PAPI_stop(int EventSet, long long *values)
Definition: papi.c:2314
int PAPI_event[2]
Definition: data_range.c:30
void test_pass(const char *filename)
Definition: test_utils.c:432
int PAPI_add_event(int EventSet, int EventCode)
Definition: papi.c:1663
#define PAPI_NULL
Definition: papi.h:292
#define PAPI_TOT_INS
return PAPI_OK
Definition: linux-nvml.c:497
return PAPI_EINVAL
Definition: linux-nvml.c:436
int int argc
Definition: iozone.c:1609
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 quiet
Definition: rapl_overflow.c:18
#define PAPI_EISRUN
Definition: papi.h:263
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
void do_flops(int n)
Definition: multiplex.c:23
int PAPI_query_event(int EventCode)
Definition: papi.c:684
#define LLDFMT
Definition: papi_test.h:94
printf("\tTry: -i 0 -i 1 \n\n")
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 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
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
ssize_t retval
Definition: libasync.c:338
#define PAPI_VER_CURRENT
Definition: papi.h:225
#define PAPI_FP_INS

Here is the call graph for this function: