| Home
Projects Software Bio Books Papers Committees Presentations | Effect of compiler options and coding techniquesThis example looks at the performance of a simple vector add operation,
for (i=0; i<n; i++) {
a[i] += b[i];
}
with various levels of compiler optimization and with different
arrangements of the code, including the use of pragmas and
pseudo-functions.
The general recommendations based on these results are:
Interestingly enough, on this example no explicit code tranformations
were necessary; the use of pragmas were
sufficient. The winning version was (with
void add2( double *a, double *b, int n )
{
#pragma disjoint (*a,*b)
int i;
#pragma unroll(10)
for (i=0; i<n; i++) {
a[i] += b[i];
}
}
|
| MCS Division | Argonne National Laboratory | University of Chicago |