PAPI  5.3.2.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)
 

Variables

int TESTS_QUIET
 

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 5 of file johnmay2.c.

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

Here is the call graph for this function:

Variable Documentation

int TESTS_QUIET

Definition at line 11 of file test_utils.c.