void vecmult(int n, int * restrict a, int * restrict b, int * restrict
c)
{
int i;
for (i=0; i<n; ++i) {
a[i] = b[i] * c[i];
}
}
but the times with or without restrict are the same. Why isn't it
improving performance, am I doing something wrong?
Well, no matter what, the program will have to perform n reads of
elements of b[] and c[], and perform n writes to elements of a[].
You could try adding -O3 and/or some of the vectorisation options.
Also, you could test something like
void vecmult(int n, int * restrict a, int * restrict b, int * restrict
c)
{
int i;
for (i=0; i<n; ++i) {
a[i] = b[0] * c[i];
}
}
which has a much bigger opportunity for optimisation (no need to load
from b[0] more than once, only if there is a restrict on b[]).
Segher