E
elvira_wang
Hi,
i was studying the virtual memory and the page fault concept in
particularly [see,
http://www.cs.man.ac.uk/~rizos/CS2051/2001-02/lect11.pdf ]
Considering this concept and the two versions code given below. Assume
that the matrix "a" is stored row by row , and considering that the
program is given only 1024 frames, version A below leads to 1024*1024
page fault whereas version B leads to only 1024 Page Fault, thus run
faster.
I have never paid attention to this issue. as a programmer do we have
to? is the compiler intelligent enough to order the loop execution in
the most effective way, i.e. switch automatically version A like code
to version B
thanks
int a[1024][1024];
/* version A */
for (j=0; j<1024; j++)
for (i=0;i<1024; i++)
A[j]=0;
/* version B */
for (i=0; i<1024; i++)
for (j=0;j<1024; j++)
A[j]=0;
i was studying the virtual memory and the page fault concept in
particularly [see,
http://www.cs.man.ac.uk/~rizos/CS2051/2001-02/lect11.pdf ]
Considering this concept and the two versions code given below. Assume
that the matrix "a" is stored row by row , and considering that the
program is given only 1024 frames, version A below leads to 1024*1024
page fault whereas version B leads to only 1024 Page Fault, thus run
faster.
I have never paid attention to this issue. as a programmer do we have
to? is the compiler intelligent enough to order the loop execution in
the most effective way, i.e. switch automatically version A like code
to version B
thanks
int a[1024][1024];
/* version A */
for (j=0; j<1024; j++)
for (i=0;i<1024; i++)
A[j]=0;
/* version B */
for (i=0; i<1024; i++)
for (j=0;j<1024; j++)
A[j]=0;