Originally Posted by
C_ntua
Is there a way to explicit tell the compiler to keep a value in the cache for the whole loop? Like
Code:
for (j=0; j<MAX; j++)
for (i=0; i<MAX; i++)
y[j] += a[i] * b[i]
...and tell the compiler to keep the value y[i] for the whole inner loop, gaining optimization. I know it is possible, but i don't know how or if the compiler would do this anyway.
It sounds like you want to do this (assuming you mean y[j], not y[i] in your description):
Code:
for (j=0; j<MAX; j++)
{
double t=0;
for (i=0; i<MAX; i++)
t += a[i] * b[i];
y[j] += t;
}
(Assuming a and b hold an array of doubles)
Don't bother unless you find that it is a bottleneck though.