147 | | |
| 147 | To enhance the performance of a program on target architecture, most compilers select the optimal values of program transformation parameters using analytical models. In contrast, Orio adaptively generates a large number of code candidates with different parameter values for a given computation, followed by empirical executions of these code variants on the target machine. Then the code that yields the best performance is chosen. Orio automates such empirical performance tuning process using annotations, exemplified in the following simple program. |
| 148 | |
| 149 | {{{ |
| 150 | /*@ begin PerfTuning ( |
| 151 | def build { |
| 152 | arg command = 'gcc'; |
| 153 | arg options = '-O0'; |
| 154 | } |
| 155 | def performance_params { |
| 156 | param UF[] = [1,2,3,4,5,6,7,8]; |
| 157 | } |
| 158 | def input_params { |
| 159 | param N[] = [1000,10000000]; |
| 160 | } |
| 161 | def input_vars { |
| 162 | decl static double y[N] = 0; |
| 163 | decl double a1 = random; |
| 164 | decl double a2 = random; |
| 165 | decl double a3 = random; |
| 166 | decl double a4 = random; |
| 167 | decl static double x1[N] = random; |
| 168 | decl static double x2[N] = random; |
| 169 | decl static double x3[N] = random; |
| 170 | decl static double x4[N] = random; |
| 171 | } |
| 172 | ) @*/ |
| 173 | int i; |
| 174 | /*@ begin Loop ( |
| 175 | transform Unroll(ufactor=UF) |
| 176 | for (i=0; i<=N-1; i++) |
| 177 | y[i] = y[i] + a1*x1[i] + a2*x2[i] + a3*x3[i] + a4*x4[i]; |
| 178 | ) @*/ |
| 179 | for (i=0; i<=N-1; i++) |
| 180 | y[i] = y[i] + a1*x1[i] + a2*x2[i] + a3*x3[i] + a4*x4[i]; |
| 181 | /*@ end @*/ |
| 182 | /*@ end @*/ |
| 183 | }}} |
| 184 | |
| 185 | Because of the huge search space, a proper search heuristic becomes a critical component of an empirical tuning system. Hence, in addition to an exhaustive search and a random search, two effective and practical search heuristic strategies have been developed and integrated into the Orio’s search engine. These include the ''Nelder-Mead Simplex'' method and ''Simulated Annealing'' method. |