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);
84int main (
int argc,
char **argv)
87 int retval,cid,rapl_cid=-1,numcmp;
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");
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");
256 printf(
"Scaled Fixed values:\n");
274 printf(
"Fixed value counts:\n");
288 unsigned long long max_value = 0;
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);
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");
357 "PAPI_cleanup_eventset()",
retval);
363 "PAPI_destroy_eventset()",
retval);
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
Get the event's name and description info.
Get real time counter value in nanoseconds.
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.
#define PAPI_DATATYPE_FP64
#define PAPI_DATATYPE_UINT64
static long long values[NUM_EVENTS]
Return codes and api definitions.
int tests_quiet(int argc, char **argv)
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)
int data_type[MAX_EVENTS]
char units[MAX_EVENTS][BUFSIZ]
static double a[MATRIX_SIZE][MATRIX_SIZE]
static double b[MATRIX_SIZE][MATRIX_SIZE]
#define MAX_RAPL_EVENTS
Tests basic functionality of RAPL component.
static double c[MATRIX_SIZE][MATRIX_SIZE]
static long long after_time
static long long before_time
char name[PAPI_MAX_STR_LEN]
char disabled_reason[PAPI_HUGE_STR_LEN]
char units[PAPI_MIN_STR_LEN]