in CO and Architecture
1,087 views
0 votes
0 votes

ques..


A CPU has a 32 KB direct mapped cache with 128 byte-block size. Suppose A is two dimensional array of size 512×512 with elements that occupy 8-bytes each. Consider the following  C code segment  initially the array is not in cache and i ,j ,x are in registers than calculate the hits_____________?

for (i=0; i<512; i++)
{ 
    for (j=0; j<512; j++)
    { 
        x +=A[i] [j]; 
    } 
}

solution : plz check..if wrong...!

cache size is 32 kb

no of lines in cache = cache size/block size

=28

=256

each element is 8 bytes..

block size =128  bytes

no of elements in one block=128/8

=16(i.e 16 elements in one block)

for c code array is stored in main memory in row major order...

no of rows are 512..and no of elements in each row are 512 therefore no blocks needed to store 1 row elements is 32 blocks...

now these 32 blocks are going to be direct mapped from main to cache memory as there are 16 elements in one block, first element in the block will be miss and rest 15 elements will be hits.means when one block is mapped to cache then there will be 1 miss and 15 hits..

for 32 block there will be 32*15 hits i.e 480 hits and there are 512 rows therefore no fo hits will be 512*480=245760 hits 

in CO and Architecture
1.1k views

1 Answer

0 votes
0 votes
by

3 Comments

actually in that question ..they said calculate missses...but in the same question i tried to calculate no of hits .also i want to check that whether i am going in right direction or not to calculat hits.. that why posted..ques.1
0
0
Yes. You are doing correct. No. oh hits is 15 times no. of misses.
0
0
thanku sir..
0
0

Related questions

0 votes
0 votes
0 answers
4