19{
20 (void) argv;
21 (void) argc;
22 int retval,cid,powercap_cid=-1,numcmp;
27 int code;
30
32
33
37
38 if ( !
TESTS_QUIET ) printf(
"Trying all powercap events\n" );
39
41
42 for( cid=0; cid<numcmp; cid++ ) {
43
45 test_fail( __FILE__, __LINE__,
"PAPI_get_component_info()\n", 0 );
46
47 if ( strstr( cmpinfo->
name,
"powercap" ) ) {
48 powercap_cid=cid;
49 if ( !
TESTS_QUIET ) printf(
"Found powercap component at cid %d\n",powercap_cid );
52 printf( "powercap component disabled: %s\n",
54 }
55 test_skip( __FILE__,__LINE__,
"powercap component disabled",0 );
56 }
57 break;
58 }
59 }
60
61
62 if ( cid==numcmp )
63 test_skip( __FILE__,__LINE__,
"No powercap component found\n",0 );
64
65
67 test_skip( __FILE__,__LINE__,
"No counters in the powercap component\n",0 );
68
69
73
74
77
78
79
84
87 break;
88
90
92 num_limits++;
93 }
96 }
97
98
99
103
104
108
109
110 printf("\nCURRENT LIMITS\n");
111 for(
i=0;
i<num_limits;
i++ ) {
112 printf(
"EVENT: %s\tLIMIT: %0.2lf Watts\n",
event_names[limit_map[
i]], ((
double)
values[limit_map[
i]]*1e-6));
114 }
115 usleep(10000);
116
117 printf("\nSETTING LIMITS 10 WATTS BELOW CURRENT LIMITS\n");
121
122 usleep(10000);
123
124 printf("\nREADING LIMITS TO MAKE SURE THEY ARE SET\n");
128 usleep(10000);
129
130 printf("\nNEW LIMITS\n");
131 for(
i=0;
i<num_limits;
i++ ) {
132 printf(
"EVENT: %s\tLIMIT: %0.2lf Watts\n",
event_names[limit_map[
i]], ((
double)
values[limit_map[
i]]*1e-6));
134 }
135
136 printf("\nRESET LIMITS BEFORE EXITING...");
140 usleep(10000);
141
142 printf("\nREADING RESET LIMITS TO MAKE SURE THEY ARE SET\n");
146 usleep(10000);
147
148 printf("\nRESET LIMITS\n");
149 for(
i=0;
i<num_limits;
i++ ) {
150 printf(
"EVENT: %s\tLIMIT: %0.2lf Watts\n",
event_names[limit_map[
i]], ((
double)
values[limit_map[
i]]*1e-6));
151 }
152
153 printf("done\n");
154
158
159
163
167
169
170 return 0;
171}
static const char * event_names[2]
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.
Read hardware counters from an event set.
Start counting hardware events in an event set.
Stop counting hardware events in an event set.
Write counter values into counters.
static long long values[NUM_EVENTS]
void PAPI_NORETURN test_fail(const char *file, int line, const char *call, int retval)
void PAPI_NORETURN test_pass(const char *filename)
void PAPI_NORETURN test_skip(const char *file, int line, const char *call, int retval)
char name[PAPI_MAX_STR_LEN]
char disabled_reason[PAPI_HUGE_STR_LEN]
#define MAX_powercap_EVENTS
Tests basic functionality of powercap component.