| 102 | {{{ |
| 103 | #include <stdio.h> |
| 104 | #include <stdlib.h> |
| 105 | #include <sys/time.h> |
| 106 | |
| 107 | /*@ global @*/ |
| 108 | |
| 109 | double rtclock() |
| 110 | { |
| 111 | struct timezone tzp; |
| 112 | struct timeval tp; |
| 113 | int stat; |
| 114 | gettimeofday(&tp, &tzp); |
| 115 | return (tp.tv_sec + tp.tv_usec*1.0e-6); |
| 116 | } |
| 117 | |
| 118 | int main() |
| 119 | { |
| 120 | /*@ prologue @*/ |
| 121 | |
| 122 | double orio_t_start=0, orio_t_end=0, orio_t_total=0; |
| 123 | int orio_i; |
| 124 | |
| 125 | for (orio_i=0; orio_i<REPS; orio_i++) |
| 126 | { |
| 127 | orio_t_start = rtclock(); |
| 128 | |
| 129 | /*@ tested code @*/ |
| 130 | |
| 131 | orio_t_end = rtclock(); |
| 132 | orio_t_total += orio_t_end - orio_t_start; |
| 133 | } |
| 134 | |
| 135 | orio_t_total = orio_t_total / REPS; |
| 136 | printf("%f\n", orio_t_total); |
| 137 | |
| 138 | /*@ epilogue @*/ |
| 139 | |
| 140 | return 0; |
| 141 | } |
| 142 | }}} |
| 143 | |
| 144 | Four important tags exist in the skeleton code, each with its own special purpose. The '`/*@ global @*/`' tag is used by the driver to place global declarations such as input variable declarations and the initialization function of the input arrays. The ‘`/*@ prologue @*/`’ tag is the spot where to dynamically allocate memory space for input arrays and to call the function that initializes all input variables. The ‘`/*@ tested code @*/`’ tag designates the location of the code tested for its performance. And the last tag ‘`/*@ epilogue @*/`’ remains unused until now, but it is kept for potential development in the future. |
| 145 | |
| 146 | From the skeleton code, it can also be observed that Orio simply uses elapsed time as its performance metric through the standard C’s `gettimeofday` function. As a part of our future plans, we intend to employ a performance counter tool, such as TAO and PAPI, to facilitate a finer grained performance measurement (e.g. the number of processor clock cycles). |
| 147 | |