22 #define MAX_RAPL_EVENTS 64 30 printf(
"Sleeping 1 second...\n");
39 #define MATRIX_SIZE 1024 57 a[
i][j]=(double)
i*(
double)j;
58 b[
i][j]=(double)
i/(
double)(j+5);
79 if (!
quiet) printf(
"Matrix multiply sum: s=%lf\n",
s);
84 int main (
int argc,
char **argv)
87 int retval,cid,rapl_cid=-1,numcmp;
98 long long before_time,after_time;
106 if ( strstr( argv[1],
"-w" ) ) {
123 printf(
"Trying all RAPL events\n");
128 for(cid=0; cid<numcmp; cid++) {
131 test_fail(__FILE__, __LINE__,
"PAPI_get_component_info failed\n", 0);
134 if (strstr(cmpinfo->
name,
"rapl")) {
139 printf(
"Found rapl component at cid %d\n",rapl_cid);
144 printf(
"RAPL component disabled: %s\n",
147 test_skip(__FILE__,__LINE__,
"RAPL component disabled",0);
155 test_skip(__FILE__,__LINE__,
"No rapl component found\n",0);
162 "PAPI_create_eventset()",
retval);
175 printf(
"Error translating %#x\n",code);
177 "PAPI_event_code_to_name",
retval );
183 "Error getting event info\n",
retval);
208 printf(
"\nStarting measurements...\n\n");
228 elapsed_time=((double)(after_time-before_time))/1.0e9;
231 printf(
"\nStopping measurements, took %.3fs, gathering results...\n\n",
234 printf(
"Scaled energy measurements:\n");
237 if (strstr(
units[
i],
"nJ")) {
239 printf(
"%-40s%12.6f J\t(Average Power %.1fW)\n",
242 ((
double)
values[
i]/1.0e9)/elapsed_time);
247 printf(
"Energy measurement counts:\n");
250 if (strstr(event_names[
i],
"ENERGY_CNT")) {
251 printf(
"%-40s%12lld\t%#08llx\n", event_names[
i],
values[
i],
values[
i]);
256 printf(
"Scaled Fixed values:\n");
259 if (!strstr(event_names[
i],
"ENERGY")) {
268 printf(
"%-40s%12.3f %s\n", event_names[
i], result.fp,
units[
i]);
274 printf(
"Fixed value counts:\n");
277 if (!strstr(event_names[
i],
"ENERGY")) {
279 printf(
"%-40s%12lld\t%#08llx\n", event_names[
i],
values[
i],
values[
i]);
288 unsigned long long max_value = 0;
292 if (strstr(event_names[
i],
"ENERGY_CNT")) {
293 if (max_value < (
unsigned)
values[
i]) {
298 max_time = elapsed_time * ( (double)0xffffffff / (
double)max_value );
300 printf (
"Approximate time to energy measurement wraparound: %.3f sec or %.3f min.\n",
301 max_time, max_time/60);
304 printf (
"Beginning wraparound execution.");
313 repeat = (int)(max_time/elapsed_time);
314 for (
i=0;
i< repeat;
i++) {
316 printf(
"."); fflush(stdout);
327 elapsed_time=((double)(after_time-before_time))/1.0e9;
328 printf(
"\nStopping measurements, took %.3fs\n\n", elapsed_time);
330 printf(
"Scaled energy measurements:\n");
333 if (strstr(
units[
i],
"nJ")) {
335 printf(
"%-40s%12.6f J\t(Average Power %.1fW)\n",
338 ((
double)
values[
i]/1.0e9)/elapsed_time);
342 printf(
"Energy measurement counts:\n");
345 if (strstr(event_names[
i],
"ENERGY_CNT")) {
346 printf(
"%-40s%12lld\t%#08llx\n", event_names[
i],
values[
i],
values[
i]);
357 "PAPI_cleanup_eventset()",
retval);
363 "PAPI_destroy_eventset()",
retval);
int PAPI_stop(int EventSet, long long *values)
char disabled_reason[PAPI_MAX_STR_LEN]
const PAPI_component_info_t * PAPI_get_component_info(int cidx)
void test_pass(const char *filename)
int PAPI_add_event(int EventSet, int EventCode)
char units[PAPI_MIN_STR_LEN]
int main(int argc, char **argv)
int PAPI_num_components(void)
char units[MAX_EVENTS][BUFSIZ]
static double a[MATRIX_SIZE][MATRIX_SIZE]
Return codes and api definitions.
int PAPI_get_event_info(int EventCode, PAPI_event_info_t *info)
void test_skip(const char *file, int line, const char *call, int retval)
int PAPI_library_init(int version)
char name[PAPI_MAX_STR_LEN]
int PAPI_enum_cmp_event(int *EventCode, int modifier, int cidx)
#define MAX_RAPL_EVENTS
Tests basic functionality of RAPL component.
int PAPI_cleanup_eventset(int EventSet)
int PAPI_create_eventset(int *EventSet)
int PAPI_event_code_to_name(int EventCode, char *out)
static double b[MATRIX_SIZE][MATRIX_SIZE]
int tests_quiet(int argc, char **argv)
void test_fail(const char *file, int line, const char *call, int retval)
long long PAPI_get_real_nsec(void)
int data_type[MAX_EVENTS]
int PAPI_destroy_eventset(int *EventSet)
int PAPI_start(int EventSet)
static long long values[NUM_EVENTS]
static double c[MATRIX_SIZE][MATRIX_SIZE]