PAPI 7.1.0.0
Loading...
Searching...
No Matches
describe.c File Reference
Include dependency graph for describe.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 25 of file describe.c.

26{
27 int EventSet = PAPI_NULL;
28 int retval;
29 long long g1[2];
30 int eventcode = PAPI_TOT_INS;
31 PAPI_event_info_t info, info1, info2;
32 int quiet;
33
34 /* Set TESTS_QUIET variable */
35 quiet=tests_quiet( argc, argv );
36
37
39 if (retval != PAPI_VER_CURRENT ) {
40 test_fail( __FILE__, __LINE__, "PAPI_library_init", retval );
41 }
42
43 if ( ( retval = PAPI_create_eventset( &EventSet ) ) != PAPI_OK ) {
44 test_fail( __FILE__, __LINE__, "PAPI_create_eventset", retval );
45 }
46
47 if ( ( retval = PAPI_query_event( eventcode ) ) != PAPI_OK ) {
48 if (!quiet) printf("Trouble checking event\n");
49 test_skip( __FILE__, __LINE__, "PAPI_query_event(PAPI_TOT_INS)",
50 retval );
51 }
52
53 if ( ( retval = PAPI_add_event( EventSet, eventcode ) ) != PAPI_OK )
54 test_fail( __FILE__, __LINE__, "PAPI_add_event(PAPI_TOT_INS)", retval );
55
56 if ( ( retval = PAPI_start( EventSet ) ) != PAPI_OK )
57 test_fail( __FILE__, __LINE__, "PAPI_start", retval );
58
59 if ( ( retval = PAPI_stop( EventSet, g1 ) ) != PAPI_OK )
60 test_fail( __FILE__, __LINE__, "PAPI_stop", retval );
61
62 /* Case 0, no info, should fail */
63 eventcode = 0;
64/*
65 if ( ( retval = PAPI_describe_event(eventname,(int *)&eventcode,eventdesc) ) == PAPI_OK)
66 test_fail(__FILE__,__LINE__,"PAPI_describe_event",retval);
67*/
68 if (!quiet) {
69 printf("This test expects a 'PAPI Error' to be returned from this PAPI call.\n");
70 }
71 if ( ( retval = PAPI_get_event_info( eventcode, &info ) ) == PAPI_OK )
72 test_fail( __FILE__, __LINE__, "PAPI_get_event_info", retval );
73
74 /* Case 1, fill in name field. */
75 eventcode = PAPI_TOT_INS;
76/*
77 if ( ( retval = PAPI_describe_event(eventname,(int *)&eventcode,eventdesc) ) != PAPI_OK)
78 test_fail(__FILE__,__LINE__,"PAPI_describe_event",retval);
79*/
80 if ( ( retval = PAPI_get_event_info( eventcode, &info1 ) ) != PAPI_OK )
81 test_fail( __FILE__, __LINE__, "PAPI_get_event_info", retval );
82
83 if ( strcmp( info1.symbol, "PAPI_TOT_INS" ) != 0 )
84 test_fail( __FILE__, __LINE__,
85 "PAPI_get_event_info symbol value is bogus", retval );
86 if ( strlen( info1.long_descr ) == 0 )
87 test_fail( __FILE__, __LINE__,
88 "PAPI_get_event_info long_descr value is bogus", retval );
89
90 eventcode = 0;
91
92 /* Case 2, fill in code field. */
93/*
94 if ( ( retval = PAPI_describe_event(eventname,(int *)&eventcode,eventdesc) ) != PAPI_OK)
95 test_fail(__FILE__,__LINE__,"PAPI_describe_event",retval);
96*/
97 if ( ( retval = PAPI_event_name_to_code( info1.symbol, ( int * ) &eventcode ) ) != PAPI_OK ) {
98 test_fail( __FILE__, __LINE__, "PAPI_event_name_to_code", retval );
99 }
100
101 if ( eventcode != PAPI_TOT_INS )
102 test_fail( __FILE__, __LINE__,
103 "PAPI_event_name_to_code code value is bogus", retval );
104
105 if ( ( retval = PAPI_get_event_info( eventcode, &info2 ) ) != PAPI_OK )
106 test_fail( __FILE__, __LINE__, "PAPI_get_event_info", retval );
107
108 if ( strcmp( info2.symbol, "PAPI_TOT_INS" ) != 0 )
109 test_fail( __FILE__, __LINE__,
110 "PAPI_get_event_info symbol value is bogus", retval );
111 if ( strlen( info2.long_descr ) == 0 )
112 test_fail( __FILE__, __LINE__,
113 "PAPI_get_event_info long_descr value is bogus", retval );
114
115 test_pass( __FILE__ );
116
117 return 0;
118}
add PAPI preset or native hardware event to an event set
Create a new empty PAPI EventSet.
Convert a name to a numeric hardware event code.
Get the event's name and description info.
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.
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_NULL
Definition: f90papi.h:78
#define PAPI_TOT_INS
Definition: f90papi.h:317
static int EventSet
Definition: init_fini.c:8
int tests_quiet(int argc, char **argv)
Definition: test_utils.c:376
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
char symbol[PAPI_HUGE_STR_LEN]
Definition: papi.h:960
char long_descr[PAPI_HUGE_STR_LEN]
Definition: papi.h:963
int retval
Definition: zero_fork.c:53
Here is the call graph for this function: