Re: compiler and locality and cache write through policy
by Terje Mathisen <terje.mathisen@[EMAIL PROTECTED]
>
Dec 8, 2007 at 07:27 PM
ThierryBingo@[EMAIL PROTECTED]
wrote:
> hey,
>
> I have two questions regarding the cache and code optimisation and
> woul appreciate your help :)
>
> 1- Do current compilers interchange nested loops order to minimise
> page fault as well as cache fault? for instance if the arrays are
> stored in row order, the following code
>
> for (i = 0; i < 100; i++)
> for (j = 0; j < 100; j++)
> x[i][j] = x[i][j]+3;
>
> will perform much better than
>
> for (j = 0; j < 100; j++)
> for (i = 0; i < 100; i++)
> x[i][j] = x[i][j]+3;
>
> do the current widely used compilers (c++, java) perform such
> optimisation automatically?
Some compilers do, depending upon exactly how the arrays have been
declared/allocated.
In particular, SUN/Sparc blew away one of the SPECint 2000 benchmarks by
determining such a convoluted set of prerequisites for doing this
particular optimization on dynamically allocated arrays that they
effectively only work on the benchmark code.
Terje
--
- <Terje.Mathisen@[EMAIL PROTECTED]
>
"almost all programming can be viewed as an exercise in caching"