PC Review


Reply
Thread Tools Rate Thread

compiler and locality and cache write through policy

 
 
ThierryBingo@googlemail.com
Guest
Posts: n/a
 
      8th Dec 2007
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?



2- Write Through on write HIT
according to Patterson book: with this policy the data is written in
the cache and the lower-level memory.

my first question if we have two levels caching. will the write be
done in L1, L2 and the physical DRAM or just L2 while using this
write policy?

my second question is related to the book evaluation to the technique.
he says that the processor will be held up on writes unless they are
buffered. I don't clearly understand what he means. my understanding
is that with this policy the data is sent to the cache AND the lower
memory level AT THE SAME TIME. no? if yes, how will this policy hold
the processor back ?unless he means that while writing the data to the
off chip memory the data bus is used and no data can be read from the
DRAM?



thanks for your help
 
Reply With Quote
 
 
 
 
Terje Mathisen
Guest
Posts: n/a
 
      8th Dec 2007
(E-Mail Removed) 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

--
- <(E-Mail Removed)>
"almost all programming can be viewed as an exercise in caching"
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Write cache Ray Mackaway Microsoft Windows 2000 Setup 0 4th Feb 2004 10:16 PM
HDD Write Cache Fabio Gianzanti Windows XP Embedded 0 8th Jan 2004 06:09 PM
How to write a compiler for .NET? Zingam Microsoft Dot NET Framework 3 14th Jul 2003 07:12 PM
How to change BIOS processor cache from write-through to write-back? jbclem Microsoft Windows 2000 3 10th Jul 2003 03:58 PM
How to change BIOS processor cache from write-through to write-back(P2B )? jbclem Asus Motherboards 1 10th Jul 2003 02:58 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:00 PM.