23#pragma omp parallel for schedule(dynamic) reduction(+ : primes)
24 for (num = 1; num <= limit; num++) {
38int main (
int argc,
char **argv)
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);
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" );
add PAPI preset or native hardware event by name to an EventSet
Create a new empty PAPI 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 real time counter value in nanoseconds.
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.
char event_name[2][PAPI_MAX_STR_LEN]
static long long values[NUM_EVENTS]
char events[MAX_EVENTS][BUFSIZ]
char filenames[MAX_EVENTS][BUFSIZ]
int ompcpuloadprimes(int limit)
Return codes and api definitions.
char name[PAPI_MAX_STR_LEN]
char disabled_reason[PAPI_HUGE_STR_LEN]