17 vsprintf(buf, fmt, args);
19 fprintf(stderr,
"[ %s ]\n", buf);
29 #define CPU_CLOCK 1700 39 if ((fp = fopen(
"/proc/cpuinfo",
"r")) ==
NULL) {
40 fprintf(stderr,
"Can't open /proc/cpuinfo\n");
44 if (strncmp(buf,
"cpu MHz", 7) )
47 if (buf[i] ==
':')
break;
54 fprintf(stderr,
"CPU CLOCK is %d\n",
cpu_clock);
61 unsigned long long val;
69 __asm__ __volatile__("rdtsc"\ 70 : "=a" (tsc.reg.eax), "=d" (tsc.reg.edx)\ 90 if(gettimeofday( &t, 0 ) == -1)
92 return (t.tv_sec * 1000000 + t.tv_usec);
106 static int Events[2] = { PAPI_L2_TCH, PAPI_L2_TCA};
108 static long_long
values[2];
110 static void handle_error(
int code) {
111 fprintf(stderr,
"PAPI: an error occurred.\n");
117 num_hwcntrs = PAPI_num_counters();
120 if (num_hwcntrs < 0 )
124 if (num_hwcntrs == 0)
125 fprintf(stderr,
"Info: This machine does not provide hardware counters." );
131 if (PAPI_start_counters(Events, num_hwcntrs) != PAPI_OK)
135 void papi_print_counters(){
136 PAPI_read_counters(
values, 2);
138 fprintf(stderr,
"PAPI: %lf, %lf\n", (
double)
values[0], (
double)values[1]);
static char buf[CHAR_SIZE]
static void reset_utime()
static time_stamp_t start
unsigned current_utime(void)
int debug_printf(char *fmt,...)