From: Raphael C. <dr...@gm...> - 2009-05-25 19:13:59
|
2009/5/25 Josef Weidendorfer <Jos...@gm...>: > Hi, > > On Sunday 24 May 2009, Raphael Clifford wrote: > >> I am mystified by the D1 cache miss lines. I get >> >> D refs: 144,057,551 (94,023,790 rd + 50,033,761 wr) >> D1 misses: 2,119,185 ( 1,993,960 rd + 125,225 wr) > > Why mystified? > If you look at your code, with length=2000000 > >> for (i=0;i<length;i++) { >> val = rand() % length; >> temp += p[val]; >> p[val] = i; >> } > > There are 2000000 loop bodies, and the first random access into p[] is > a read access in line > > temp += p[val]; > > It is expected that almost any access here gives a L1 read miss, and > actually, you see around 2 million D1 read misses. > > As the memory block containing p[val] is in the cache afterwards, there > will be no further misses (esp. no write misses). Thanks. As you point out I didn't really understand the output from valgrind. The line that was confusing me was the percentage one but I should have realised that most of this is not from the array access at all but from everything else associated with running the code. Raphael |