GATE 2006
191 questions
MCQ 1911-mark 191
Questions 81–85 of 191
A CPU has a 32 KB direct mapped cache with 128-byte block size. Suppose A is a twodimensional array of size 512x512 with elements that occupy 8-bytes each. Consider the following two C code segments, P1 and P2.
The value of M1 is:
P1:
for (i=0; i<512; i++) {
for (j=0; j<512; j++) {
x += A[i][j];
}
}
P2:
for (i=0; i<512; i++) {
for (j=0; j<512; j++) {
x += A[j][i];
}
} P1 and P2 are executed independently with the same initial state, namely, the array A is not in the cache and i, j, x are in registers. Let the number of cache misses experienced by P1 be M1 and that for P2 be M2 . The value of M1 is:
Answer: (C)
C stores a 2-D array in row-major order, and P1 reads it in that same order.
A block has 128 bytes and an element has 8 bytes, so one block holds elements. The first read of a block misses and brings in all 16 elements, so the next 15 reads hit. A block is never needed again after its 16 elements are read, so there are no other misses.
Number of elements .
Answer: (C)
A block has 128 bytes and an element has 8 bytes, so one block holds elements. The first read of a block misses and brings in all 16 elements, so the next 15 reads hit. A block is never needed again after its 16 elements are read, so there are no other misses.
Number of elements .
Answer: (C)
Consider two cache organizations: The first one is 32 KB 2-way set associative with 32-byte block size. The second one is of the same size but direct mapped. The size of an address is 32 bits in both cases. A 2-to-1 multiplexer has a latency of 0.6 ns while a kbit comparator has a latency of k/10 ns. The hit latency of the set associative organization is h1 while that of the direct mapped one is h2.
The value of h2 is:
The value of h2 is:
Answer: (D)
Direct mapped cache: number of blocks , and each block is its own set. So the index has 10 bits.
The block has 32 bytes, so the offset has 5 bits.
Tag bits .
On a hit, only one block can match, so the 17-bit tag comparator is the only delay. There is no way to choose between blocks, so no 2-to-1 multiplexer is needed.
Answer: (D)
The block has 32 bytes, so the offset has 5 bits.
Tag bits .
On a hit, only one block can match, so the 17-bit tag comparator is the only delay. There is no way to choose between blocks, so no 2-to-1 multiplexer is needed.
Answer: (D)
Consider two cache organizations: The first one is 32 KB 2-way set associative with 32-byte block size. The second one is of the same size but direct mapped. The size of an address is 32 bits in both cases. A 2-to-1 multiplexer has a latency of 0.6 ns while a kbit comparator has a latency of k/10 ns. The hit latency of the set associative organization is h1 while that of the direct mapped one is h2.
The value of h1 is:
The value of h1 is:
Answer: (A)
Number of sets , so the index has 9 bits.
The block has 32 bytes, so the offset has 5 bits.
Tag bits .
In a 2-way cache, the tags of both blocks in the set are compared at the same time, using two 18-bit comparators. This takes . Then a 2-to-1 multiplexer picks the data of the way that matched, which takes 0.6 ns.
Answer: (A)
The block has 32 bytes, so the offset has 5 bits.
Tag bits .
In a 2-way cache, the tags of both blocks in the set are compared at the same time, using two 18-bit comparators. This takes . Then a 2-to-1 multiplexer picks the data of the way that matched, which takes 0.6 ns.
Answer: (A)
A CPU generates 32-bit virtual addresses. The page size is 4 KB. The processor has a translation look-aside buffer (TLB) which can hold a total of 128 page table entries and is 4-way set associative. The minimum size of the TLB tag is
Answer: (C)
The page number has 32 12 = 20 bits.
Number of TLB sets = 128 / 4 = 32 so 5 index bits are needed.
Tag size = 20 5 = 15 bits
Answer: 15 bits
Number of TLB sets = 128 / 4 = 32 so 5 index bits are needed.
Tag size = 20 5 = 15 bits
Answer: 15 bits
A CPU has a cache with block size 64 bytes. The main memory has k banks, each bank being c bytes wide. Consecutive c-byte chunks are mapped on consecutive banks with wrap-around. All the k banks can be accessed in parallel, but two accesses to the same bank must be serialized. A cache block access may involve multiple iterations of parallel bank accesses depending on the amount of data obtained by accessing all the k banks in parallel. Each iteration requires decoding the bank numbers to be accessed in parallel and this takes k/2 ns . The latency of one bank access is 80 ns . If c = 2 and k=24, then latency of retrieving a cache block starting at address zero from main memory is
Answer: (D)
This is memory interleaving. Memory is split into banks, and consecutive chunks are placed in consecutive banks so that they can be read in parallel. Each round of parallel access needs the bank numbers to be decoded first, so the decode time adds to the bank latency.
One iteration reads all banks, each bytes wide: bytes.
Time for one iteration .
A cache block has 64 bytes, and 48 bytes is not enough. Iterations needed . The remaining 16 bytes lie in different banks (banks 0 to 7), so the second iteration is also one parallel access.
Latency .
Answer: (D)
One iteration reads all banks, each bytes wide: bytes.
Time for one iteration .
A cache block has 64 bytes, and 48 bytes is not enough. Iterations needed . The remaining 16 bytes lie in different banks (banks 0 to 7), so the second iteration is also one parallel access.
Latency .
Answer: (D)