40 int retval,cid,rapl_cid=-1,numcmp;
43 int i,code,enum_retval;
45 long long start_time,write_start_time,write_end_time,read_start_time,read_end_time;
47 union {
long long ll;
double dbl; } event_value_union;
54 fprintf(stderr,
"PAPI_library_init failed\n");
60 for(cid=0; cid<numcmp; cid++) {
62 fprintf(stderr,
"PAPI_get_component_info failed\n");
65 if (strstr(cmpinfo->
name,
"libmsr")) {
67 printf(
"Found libmsr component at cid %d\n", rapl_cid);
69 fprintf(stderr,
"No libmsr events found: %s\n", cmpinfo->
disabled_reason);
78 fprintf(stderr,
"No libmsr component found\n");
85 while ( enum_retval ==
PAPI_OK ) {
88 printf(
"Error translating %#x\n",code);
102 printf(
"Error! No libmsr events found!\n");
107 char fileoutname[]=
"libmsr_write_test_output.txt";
108 fileout=fopen( fileoutname ,
"w" );
109 if ( fileout==NULL) { fprintf( stderr,
"Could not open %s\n",fileoutname );
exit(1); }
114 fprintf(stderr,
"Error creating eventset!\n");
132 fprintf( fileout,
"ACTION TIME-STAMP TIME-FOR-UNIT-WORK TIME-OVERHEAD-RW\t" );
134 fprintf( fileout,
"%s ",
events[
i]+9 );
135 fprintf( fileout,
"\n" );
140 fprintf( fileout,
"INIT %8.3f %8.3f ", ((
double)(
PAPI_get_real_nsec()-start_time))/1.0e9, 0.0 );
141 fprintf( fileout,
"%8.3e ", 0.0);
143 event_value_union.ll =
values[
i];
144 fprintf( fileout,
"%8.3f ", event_value_union.dbl );
146 fprintf( fileout,
"\n" );
154 if ( rpt % 10 == 0 ) {
156 event_value_union.ll =
values[
i];
157 if ( !strcmp(
events[
i],
"libmsr:::PKG_POWER_LIMIT_1:PACKAGE0" )) event_value_union.dbl=limit1base+(rpt/2);
158 else if ( !strcmp(
events[
i],
"libmsr:::PKG_TIME_WINDOW_POWER_LIMIT_1:PACKAGE0" )) event_value_union.dbl=1.0;
159 else if ( !strcmp(
events[
i],
"libmsr:::PKG_POWER_LIMIT_2:PACKAGE0" )) event_value_union.dbl=limit2base+(rpt/2);
160 else if ( !strcmp(
events[
i],
"libmsr:::PKG_TIME_WINDOW_POWER_LIMIT_2:PACKAGE0" )) event_value_union.dbl=1.0;
161 else if ( !strcmp(
events[
i],
"libmsr:::PKG_POWER_LIMIT_1:PACKAGE1" )) event_value_union.dbl=limit1base+(rpt/2);
162 else if ( !strcmp(
events[
i],
"libmsr:::PKG_TIME_WINDOW_POWER_LIMIT_1:PACKAGE1" )) event_value_union.dbl=1.0;
163 else if ( !strcmp(
events[
i],
"libmsr:::PKG_POWER_LIMIT_2:PACKAGE1" )) event_value_union.dbl=limit2base+(rpt/2);
164 else if ( !strcmp(
events[
i],
"libmsr:::PKG_TIME_WINDOW_POWER_LIMIT_2:PACKAGE1" )) event_value_union.dbl=1.0;
166 values[
i]=event_value_union.ll;
174 fprintf( fileout,
"SET %8.3f %8.3f ", ((
double)(
PAPI_get_real_nsec()-start_time))/1.0e9, 0.0 );
175 fprintf( fileout,
"%8.3e ", ((
double)(write_end_time-write_start_time))/1.0e9 );
177 event_value_union.ll =
values[
i];
178 fprintf( fileout,
"%8.3f ", event_value_union.dbl );
180 fprintf( fileout,
"\n" );
195 fprintf( fileout,
"READ %8.3f %8.3f ", ((
double)(
PAPI_get_real_nsec()-start_time))/1.0e9, work_time/1.0e9 );
196 fprintf( fileout,
"%8.3e ", ((
double)(read_end_time-read_start_time))/1.0e9 );
198 event_value_union.ll =
values[
i];
199 fprintf( fileout,
"%8.3f ", event_value_union.dbl );
201 fprintf( fileout,
"\n" );
char event_name[2][PAPI_MAX_STR_LEN]
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)
int PAPI_write(int EventSet, long long *values)
int PAPI_num_components(void)
int PAPI_add_named_event(int EventSet, const char *EventName)
int PAPI_library_init(int version)
char filenames[MAX_EVENTS][BUFSIZ]
char name[PAPI_MAX_STR_LEN]
int PAPI_enum_cmp_event(int *EventCode, int modifier, int cidx)
int ompcpuloadprimes(int limit)
int PAPI_create_eventset(int *EventSet)
int PAPI_event_code_to_name(int EventCode, char *out)
long long PAPI_get_real_nsec(void)
int PAPI_read(int EventSet, long long *values)
int PAPI_start(int EventSet)
static long long values[NUM_EVENTS]
char events[MAX_EVENTS][BUFSIZ]