Previous | Next --- Slide 7 of 43
Back to Lecture Thumbnails
IntergalacticPeanutMaker

To describe the for loops in 2nd program...


for(int j=0; j<HEIGHT; j+CHUNK_SIZE) = for each chunk size of rows in the image

for(int j2=0; j2<CHUNK_SIZE+2; j2++) = for every row in the chosen chunk (+2 to allow for vertical blurring of last row..)
for(int i=0; i<WIDTH; i++) = for every pixel in chosen row in chosen chunk size
for(int ii=0; ii<3; ii++) = blur the chosen pixel horizontally

for(int j2=0; j2<CHUNK_SIZE; j2++) = for every row in the chosen chunk
for(int i=0; i<WIDTH; i++) = for every pixel in chosen row in chosen chunk
for(int ii=0; ii<3; ii++) = blur the chosen pixel vertically

misaka-10032

First program exploits spatial locality in input and tmp_buf. Second program further exploits producer-consumer locality by trying to fit tmp_buf into cache.