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
Consider a machine with a 2-way set associative data cache of size 64 ...
Given Information:
- Cache size: 64 Kbytes
- Block size: 16 bytes
- Virtual address size: 32 bits
- Page size: 4 Kbytes
- Array size: 1024x1024
- Double size: 8 bytes
- Array starts at virtual page 0xFF000
Calculations:
1. Cache Blocks: The cache size is 64 Kbytes, and the block size is 16 bytes. Therefore, the cache is divided into (64 * 1024) / 16 = 4096 blocks.
2. Index Bits: Since the cache is 2-way set associative, each set contains 2 blocks. Therefore, the number of sets is 4096 / 2 = 2048. To address each set, we need log2(2048) = 11 bits for the index.
3. Offset Bits: The block size is 16 bytes, which requires log2(16) = 4 bits to address each byte within a block.
4. Tag Bits: The remaining bits of the virtual address after removing the index and offset bits are used for the tag. Therefore, tag bits = 32 - (11 + 4) = 17 bits.
5. Page Offset Bits: The page size is 4 Kbytes, which requires log2(4 * 1024) = 12 bits to address each byte within a page.
Explanation:
- The array ARR is stored in memory starting at the beginning of virtual page 0xFF000. Since the page size is 4 Kbytes, each page contains 4 * 1024 / 8 = 512 double elements.
- The initialization loop accesses all elements of ARR in row-major order. Therefore, the array elements are accessed sequentially.
- As the cache is initially empty, every memory reference will result in a cache miss. During the initialization loop, a total of 1024 * 1024 = 1048576 memory references will be made.
- Since the cache is 2-way set associative, each set contains 2 blocks. Therefore, the cache can store a maximum of 2 * 2048 = 4096 distinct memory blocks.
- As the loop progresses, the cache will fill up with the accessed memory blocks. Once the cache is full, any new memory reference will result in a cache miss and eviction of an existing block.
- Since the loop accesses all elements of ARR sequentially, each memory block will be evicted from the cache immediately after being accessed. Therefore, the cache hit ratio for this initialization loop is 0%.
- The cache hit ratio represents the percentage of memory references that result in a cache hit. In this case, all memory references result in cache misses, so the cache hit ratio is 0%.
Therefore, the correct answer is option 'A' - 0%.
To make sure you are not studying endlessly, EduRev has designed Computer Science Engineering (CSE) study material, with Structured Courses, Videos, & Test Series. Plus get personalized analysis, doubt solving and improvement plans to achieve a great score in Computer Science Engineering (CSE).