PAPI 7.1.0.0
Loading...
Searching...
No Matches
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

◆ main()

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 */
30 else
32
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 =
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}
add PAPI preset or native hardware event to an event set
Empty and destroy an EventSet.
Create a new empty PAPI EventSet.
Empty and destroy an EventSet.
Convert a numeric hardware event code to a name.
initialize the PAPI library.
Query if PAPI event exists.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
int PAPI_event[2]
Definition: data_range.c:30
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_NULL
Definition: f90papi.h:78
#define PAPI_EINVAL
Definition: f90papi.h:115
#define PAPI_FP_INS
Definition: f90papi.h:366
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
#define PAPI_EISRUN
Definition: f90papi.h:277
#define PAPI_TOT_INS
Definition: f90papi.h:317
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
void do_flops(int n)
Definition: multiplex.c:23
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
#define LLDFMT
Definition: papi_test.h:104
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:491
void PAPI_NORETURN test_pass(const char *filename)
Definition: test_utils.c:432
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
Definition: test_utils.c:584
int quiet
Definition: rapl_overflow.c:19
int retval
Definition: zero_fork.c:53
Here is the call graph for this function: