PAPI 7.1.0.0
Loading...
Searching...
No Matches
stealtime_basic.c
Go to the documentation of this file.
1
11#include <stdio.h>
12#include <stdlib.h>
13#include <string.h>
14
15#include "papi.h"
16#include "papi_test.h"
17
18#define NUM_EVENTS 1
19
20int main (int argc, char **argv)
21{
22
23 int retval,cid,numcmp;
24 int EventSet = PAPI_NULL;
25 long long values[NUM_EVENTS];
26 int code;
28 int total_events=0;
29 int r;
30 const PAPI_component_info_t *cmpinfo = NULL;
31 int quiet=0;
32
33 /* Set TESTS_QUIET variable */
34 quiet=tests_quiet( argc, argv );
35
36 /* PAPI Initialization */
38 if ( retval != PAPI_VER_CURRENT ) {
39 test_fail(__FILE__, __LINE__,"PAPI_library_init failed\n",retval);
40 }
41
42 if (!quiet) {
43 printf("Trying all stealtime events\n");
44 }
45
46 numcmp = PAPI_num_components();
47
48 for(cid=0; cid<numcmp; cid++) {
49
50 if ( (cmpinfo = PAPI_get_component_info(cid)) == NULL) {
51 test_fail(__FILE__, __LINE__,"PAPI_get_component_info failed\n", 0);
52 }
53
54 if (strstr(cmpinfo->name,"stealtime")) {
55 if (!quiet) printf("\tFound stealtime component %d - %s\n", cid, cmpinfo->name);
56 }
57 else {
58 continue;
59 }
60
61 code = PAPI_NATIVE_MASK;
62
63 r = PAPI_enum_cmp_event( &code, PAPI_ENUM_FIRST, cid );
64
65 while ( r == PAPI_OK ) {
67 if ( retval != PAPI_OK ) {
68 printf("Error translating %#x\n",code);
69 test_fail( __FILE__, __LINE__,
70 "PAPI_event_code_to_name", retval );
71 }
72
73 if (!quiet) printf(" %s ",event_name);
74
76
78 if (retval != PAPI_OK) {
79 test_fail(__FILE__, __LINE__,
80 "PAPI_create_eventset()",retval);
81 }
82
84 if (retval != PAPI_OK) {
85 test_fail(__FILE__, __LINE__,
86 "PAPI_add_event()",retval);
87 }
88
90 if (retval != PAPI_OK) {
91 test_fail(__FILE__, __LINE__, "PAPI_start()",retval);
92 }
93
95 if (retval != PAPI_OK) {
96 test_fail(__FILE__, __LINE__, "PAPI_start()",retval);
97 }
98
99 if (!quiet) printf(" value: %lld\n",values[0]);
100
102 if (retval != PAPI_OK) {
103 test_fail(__FILE__, __LINE__,
104 "PAPI_cleanup_eventset()",retval);
105 }
106
108 if (retval != PAPI_OK) {
109 test_fail(__FILE__, __LINE__,
110 "PAPI_destroy_eventset()",retval);
111 }
112
113 total_events++;
114
115 r = PAPI_enum_cmp_event( &code, PAPI_ENUM_EVENTS, cid );
116 }
117 }
118
119 if (total_events==0) {
120 test_skip(__FILE__,__LINE__,"No stealtime events found",0);
121 }
122
123 if (!quiet) {
124 printf("Note: for this test the values are expected to all be 0\n\t unless run inside a VM on a busy system.\n");
125 }
126
127 test_pass( __FILE__ );
128
129 return 0;
130}
131
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.
Enumerate PAPI preset or native events for a given component.
Convert a numeric hardware event code to a name.
get information about a specific software component
initialize the PAPI library.
Get the number of components available on the system.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
char event_name[2][PAPI_MAX_STR_LEN]
Definition: data_range.c:29
#define PAPI_VER_CURRENT
Definition: f90papi.h:54
#define PAPI_ENUM_EVENTS
Definition: f90papi.h:224
#define PAPI_OK
Definition: f90papi.h:73
#define PAPI_ENUM_FIRST
Definition: f90papi.h:85
#define PAPI_NULL
Definition: f90papi.h:78
#define PAPI_MAX_STR_LEN
Definition: f90papi.h:77
static int EventSet
Definition: init_fini.c:8
static long long values[NUM_EVENTS]
Definition: init_fini.c:10
#define PAPI_NATIVE_MASK
Return codes and api definitions.
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 main()
Definition: pernode.c:20
int quiet
Definition: rapl_overflow.c:19
#define NUM_EVENTS
Tests basic stealtime functionality.
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:627
int retval
Definition: zero_fork.c:53