PAPI 7.1.0.0
Loading...
Searching...
No Matches
vmware_basic.c File Reference
Include dependency graph for vmware_basic.c:

Go to the source code of this file.

Macros

#define NUM_EVENTS   1
 Tests basic vmware functionality.
 

Functions

int main (int argc, char **argv)
 

Macro Definition Documentation

◆ NUM_EVENTS

#define NUM_EVENTS   1
Author
Vince Weaver

test case for vmware component

Definition at line 18 of file vmware_basic.c.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 20 of file vmware_basic.c.

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
32 /* Set TESTS_QUIET variable */
33 tests_quiet( argc, argv );
34
35 /* PAPI Initialization */
37 if ( retval != PAPI_VER_CURRENT ) {
38 test_fail(__FILE__, __LINE__,"PAPI_library_init failed\n",retval);
39 }
40
41 if (!TESTS_QUIET) {
42 printf("Trying all vmware events\n");
43 }
44
45 /* Find our Component */
46
47 numcmp = PAPI_num_components();
48
49 for(cid=0; cid<numcmp; cid++) {
50
51 if ( (cmpinfo = PAPI_get_component_info(cid)) == NULL) {
52 test_fail(__FILE__, __LINE__,"PAPI_get_component_info failed\n", 0);
53 }
54
55 if (strstr(cmpinfo->name,"vmware")) {
56 if (!TESTS_QUIET) printf("\tFound vmware component %d - %s\n", cid, cmpinfo->name);
57 }
58 else {
59 continue;
60 }
61
63
64 /* Try all events one by one */
65
66 code = PAPI_NATIVE_MASK;
67
68 r = PAPI_enum_cmp_event( &code, PAPI_ENUM_FIRST, cid );
69
70 while ( r == PAPI_OK ) {
71
72 retval=PAPI_get_event_info(code,&info);
73 if (retval!=PAPI_OK) {
74 printf("Error getting event info\n");
75 test_fail( __FILE__, __LINE__,
76 "PAPI_get_event_info", retval );
77 }
78
80 if ( retval != PAPI_OK ) {
81 printf("Error translating %#x\n",code);
82 test_fail( __FILE__, __LINE__,
83 "PAPI_event_code_to_name", retval );
84 }
85
86 if (!TESTS_QUIET) printf(" %s ",event_name);
87
89
91 if (retval != PAPI_OK) {
92 test_fail(__FILE__, __LINE__,
93 "PAPI_create_eventset()",retval);
94 }
95
97 if (retval != PAPI_OK) {
98 test_fail(__FILE__, __LINE__,
99 "PAPI_add_event()",retval);
100 }
101
102 /* start */
104 if (retval != PAPI_OK) {
105 test_fail(__FILE__, __LINE__, "PAPI_start()",retval);
106 }
107
108 /* do something */
109 usleep(100);
110
111 /* stop */
113 if (retval != PAPI_OK) {
114 test_fail(__FILE__, __LINE__, "PAPI_start()",retval);
115 }
116
117 if (!TESTS_QUIET) printf(" value: %lld %s\n",values[0],
118 info.units);
119
121 if (retval != PAPI_OK) {
122 test_fail(__FILE__, __LINE__,
123 "PAPI_cleanup_eventset()",retval);
124 }
125
127 if (retval != PAPI_OK) {
128 test_fail(__FILE__, __LINE__,
129 "PAPI_destroy_eventset()",retval);
130 }
131
132 total_events++;
133
134 r = PAPI_enum_cmp_event( &code, PAPI_ENUM_EVENTS, cid );
135 }
136 }
137
138 if (total_events==0) {
139 test_skip(__FILE__,__LINE__,"No vmware events found",0);
140 }
141
142 if (!TESTS_QUIET) {
143 printf("\n");
144 }
145
146 test_pass( __FILE__ );
147
148 return 0;
149}
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
Get the event's name and description info.
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
int TESTS_QUIET
Definition: test_utils.c:18
#define PAPI_NATIVE_MASK
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
char name[PAPI_MAX_STR_LEN]
Definition: papi.h:627
char units[PAPI_MIN_STR_LEN]
Definition: papi.h:969
#define NUM_EVENTS
Tests basic vmware functionality.
Definition: vmware_basic.c:18
int retval
Definition: zero_fork.c:53
Here is the call graph for this function: