Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  Consider a machine with a 2-way set associati... Start Learning for Free
Consider a machine with a 2-way set associative data cache of size 64 Kbytes and block size 16 bytes. The cache is
managed using 32 bit virtual addresses and the page size is 4 Kbytes. A program to be run on this machine begins as
follows:
double ARR[1024][1024];
int i, j;
/*Initialize array ARR to 0.0 */
for(i = 0; i < 1024; i++)
for(j = 0; j < 1024; j++)
ARR[i][j] = 0.0;
The size of double is 8 bytes. Array ARR is located in memory starting at the beginning of virtual page 0xFF000 and stored in
row major order. The cache is initially empty and no pre-fetching is done. The only data memory references made by the
program are those to array ARR.
The cache hit ratio for this initialization loop is
  • a)
    0%
  • b)
    25%
  • c)
    50%
  • d)
    75%
Correct answer is option 'C'. Can you explain this answer?
Verified Answer
Consider a machine with a 2-way set associative data cache of size 64 ...
block size=16B and one element=8B.so in one block 2 element will be stored.
for 1024*1024 element num of block required=1024*1024/2 =2^19 blocks required.
in one block first element will be a miss and second one is hit(since we are transferring two unit at a time)
=>hit ratio=total hit/total reference
=2^19/2^20
=1/2=0.5
=0.5*100=50%
This question is part of UPSC exam. View all Computer Science Engineering (CSE) courses
Most Upvoted Answer
Consider a machine with a 2-way set associative data cache of size 64 ...
Cache Configuration
- Cache size: 64 Kbytes
- Block size: 16 bytes
- 2-way set associative
Memory and Array Characteristics
- Double size: 8 bytes
- Total elements in ARR: 1024 x 1024 = 1,048,576
- Total size of ARR: 1,048,576 * 8 bytes = 8,388,608 bytes (or 8 Mbytes)
Cache Structure Analysis
- Number of blocks in cache: 64 Kbytes / 16 bytes = 4096 blocks
- Number of sets: 4096 blocks / 2 ways = 2048 sets
- Each set can hold 2 cache lines (blocks).
Memory Access Pattern
- The loop iterates through the array in row-major order.
- Each row of ARR has 1024 doubles, or 8192 bytes (1024 * 8 bytes).
- Each row fits in 512 cache blocks (8192 bytes / 16 bytes).
Cache Behavior During Initialization
- When iterating through the first row (i=0), the first 512 cache blocks are filled.
- The second row (i=1) will access the same set of cache lines, causing misses in the first iteration.
- As rows are processed, old cache lines will be replaced due to the 2-way associative nature.
Hit Ratio Calculation
- First row: 512 cache blocks filled (all misses for the first row).
- Second row: Hits occur only for the first 2 cache lines.
- Total accesses for each row: 1024 (the number of elements).
- Total accesses for 1024 rows: 1024 * 1024 = 1,048,576.
Final Calculation
- Total hits after processing all rows: 0 hits for the first row, 512 hits for subsequent rows.
- Total hits = 512 hits / 1,048,576 total accesses = 50% hit ratio.
Thus, the correct answer is option 'C', 50%.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Consider a machine with a 2-way set associative data cache of size 64 Kbytes and block size 16 bytes. The cache ismanaged using 32 bit virtual addresses and the page size is 4 Kbytes. A program to be run on this machine begins asfollows:double ARR[1024][1024];int i, j;/*Initialize array ARR to 0.0 */for(i = 0; i < 1024; i++)for(j = 0; j < 1024; j++)ARR[i][j] = 0.0;The size of double is 8 bytes. Array ARR is located in memory starting at the beginning of virtual page 0xFF000 and stored inrow major order. The cache is initially empty and no pre-fetching is done. The only data memory references made by theprogram are those to array ARR.The cache hit ratio for this initialization loop isa)0%b)25%c)50%d)75%Correct answer is option 'C'. Can you explain this answer?
Question Description
Consider a machine with a 2-way set associative data cache of size 64 Kbytes and block size 16 bytes. The cache ismanaged using 32 bit virtual addresses and the page size is 4 Kbytes. A program to be run on this machine begins asfollows:double ARR[1024][1024];int i, j;/*Initialize array ARR to 0.0 */for(i = 0; i < 1024; i++)for(j = 0; j < 1024; j++)ARR[i][j] = 0.0;The size of double is 8 bytes. Array ARR is located in memory starting at the beginning of virtual page 0xFF000 and stored inrow major order. The cache is initially empty and no pre-fetching is done. The only data memory references made by theprogram are those to array ARR.The cache hit ratio for this initialization loop isa)0%b)25%c)50%d)75%Correct answer is option 'C'. Can you explain this answer? for Computer Science Engineering (CSE) 2024 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about Consider a machine with a 2-way set associative data cache of size 64 Kbytes and block size 16 bytes. The cache ismanaged using 32 bit virtual addresses and the page size is 4 Kbytes. A program to be run on this machine begins asfollows:double ARR[1024][1024];int i, j;/*Initialize array ARR to 0.0 */for(i = 0; i < 1024; i++)for(j = 0; j < 1024; j++)ARR[i][j] = 0.0;The size of double is 8 bytes. Array ARR is located in memory starting at the beginning of virtual page 0xFF000 and stored inrow major order. The cache is initially empty and no pre-fetching is done. The only data memory references made by theprogram are those to array ARR.The cache hit ratio for this initialization loop isa)0%b)25%c)50%d)75%Correct answer is option 'C'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for Consider a machine with a 2-way set associative data cache of size 64 Kbytes and block size 16 bytes. The cache ismanaged using 32 bit virtual addresses and the page size is 4 Kbytes. A program to be run on this machine begins asfollows:double ARR[1024][1024];int i, j;/*Initialize array ARR to 0.0 */for(i = 0; i < 1024; i++)for(j = 0; j < 1024; j++)ARR[i][j] = 0.0;The size of double is 8 bytes. Array ARR is located in memory starting at the beginning of virtual page 0xFF000 and stored inrow major order. The cache is initially empty and no pre-fetching is done. The only data memory references made by theprogram are those to array ARR.The cache hit ratio for this initialization loop isa)0%b)25%c)50%d)75%Correct answer is option 'C'. Can you explain this answer?.
Solutions for Consider a machine with a 2-way set associative data cache of size 64 Kbytes and block size 16 bytes. The cache ismanaged using 32 bit virtual addresses and the page size is 4 Kbytes. A program to be run on this machine begins asfollows:double ARR[1024][1024];int i, j;/*Initialize array ARR to 0.0 */for(i = 0; i < 1024; i++)for(j = 0; j < 1024; j++)ARR[i][j] = 0.0;The size of double is 8 bytes. Array ARR is located in memory starting at the beginning of virtual page 0xFF000 and stored inrow major order. The cache is initially empty and no pre-fetching is done. The only data memory references made by theprogram are those to array ARR.The cache hit ratio for this initialization loop isa)0%b)25%c)50%d)75%Correct answer is option 'C'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of Consider a machine with a 2-way set associative data cache of size 64 Kbytes and block size 16 bytes. The cache ismanaged using 32 bit virtual addresses and the page size is 4 Kbytes. A program to be run on this machine begins asfollows:double ARR[1024][1024];int i, j;/*Initialize array ARR to 0.0 */for(i = 0; i < 1024; i++)for(j = 0; j < 1024; j++)ARR[i][j] = 0.0;The size of double is 8 bytes. Array ARR is located in memory starting at the beginning of virtual page 0xFF000 and stored inrow major order. The cache is initially empty and no pre-fetching is done. The only data memory references made by theprogram are those to array ARR.The cache hit ratio for this initialization loop isa)0%b)25%c)50%d)75%Correct answer is option 'C'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of Consider a machine with a 2-way set associative data cache of size 64 Kbytes and block size 16 bytes. The cache ismanaged using 32 bit virtual addresses and the page size is 4 Kbytes. A program to be run on this machine begins asfollows:double ARR[1024][1024];int i, j;/*Initialize array ARR to 0.0 */for(i = 0; i < 1024; i++)for(j = 0; j < 1024; j++)ARR[i][j] = 0.0;The size of double is 8 bytes. Array ARR is located in memory starting at the beginning of virtual page 0xFF000 and stored inrow major order. The cache is initially empty and no pre-fetching is done. The only data memory references made by theprogram are those to array ARR.The cache hit ratio for this initialization loop isa)0%b)25%c)50%d)75%Correct answer is option 'C'. Can you explain this answer?, a detailed solution for Consider a machine with a 2-way set associative data cache of size 64 Kbytes and block size 16 bytes. The cache ismanaged using 32 bit virtual addresses and the page size is 4 Kbytes. A program to be run on this machine begins asfollows:double ARR[1024][1024];int i, j;/*Initialize array ARR to 0.0 */for(i = 0; i < 1024; i++)for(j = 0; j < 1024; j++)ARR[i][j] = 0.0;The size of double is 8 bytes. Array ARR is located in memory starting at the beginning of virtual page 0xFF000 and stored inrow major order. The cache is initially empty and no pre-fetching is done. The only data memory references made by theprogram are those to array ARR.The cache hit ratio for this initialization loop isa)0%b)25%c)50%d)75%Correct answer is option 'C'. Can you explain this answer? has been provided alongside types of Consider a machine with a 2-way set associative data cache of size 64 Kbytes and block size 16 bytes. The cache ismanaged using 32 bit virtual addresses and the page size is 4 Kbytes. A program to be run on this machine begins asfollows:double ARR[1024][1024];int i, j;/*Initialize array ARR to 0.0 */for(i = 0; i < 1024; i++)for(j = 0; j < 1024; j++)ARR[i][j] = 0.0;The size of double is 8 bytes. Array ARR is located in memory starting at the beginning of virtual page 0xFF000 and stored inrow major order. The cache is initially empty and no pre-fetching is done. The only data memory references made by theprogram are those to array ARR.The cache hit ratio for this initialization loop isa)0%b)25%c)50%d)75%Correct answer is option 'C'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice Consider a machine with a 2-way set associative data cache of size 64 Kbytes and block size 16 bytes. The cache ismanaged using 32 bit virtual addresses and the page size is 4 Kbytes. A program to be run on this machine begins asfollows:double ARR[1024][1024];int i, j;/*Initialize array ARR to 0.0 */for(i = 0; i < 1024; i++)for(j = 0; j < 1024; j++)ARR[i][j] = 0.0;The size of double is 8 bytes. Array ARR is located in memory starting at the beginning of virtual page 0xFF000 and stored inrow major order. The cache is initially empty and no pre-fetching is done. The only data memory references made by theprogram are those to array ARR.The cache hit ratio for this initialization loop isa)0%b)25%c)50%d)75%Correct answer is option 'C'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev