Complete Detailed Solutions · 2023 & 2024 Papers
(i) The main memory of a computer has 2 cm blocks while the cache has 2c blocks. If the cache uses the set associative mapping scheme with 2 blocks per set; then block k of the main memory maps to the set:
Answer: (b) (k mod c) of the cache
Explanation: In set-associative mapping, the number of sets $M = ext{Total Cache Blocks} / ext{Blocks per Set} = 2c / 2 = c$ sets. A main memory block $k$ maps to set number $(k \pmod M)$, which is $(k \pmod c)$.
(ii) Suppose the time delay of the four stages of a pipeline are t1=60ns, t2=50ns, t3=90ns, t4=80ns respectively and the interface latch has a delay tl = 10 ns, then the maximum clock frequency (cycle time) for the pipeline is:
Answer: (a) 100 ns
Explanation: The clock cycle time $T$ must be large enough to accommodate the slowest pipeline stage plus the latch delay. $T = \max(t_1, t_2, t_3, t_4) + t_l = 90 + 10 = 100$ ns. (Note: The options are in nanoseconds, which represents the cycle time, not frequency).
(iii) As the bus in a multiprocessor is a shared resource, so there must be some mechanism to resolve the conflict. The ............ algorithm form the below mentioned is not a conflict resolution technique.
Answer: (a) State priority Algorithm
Explanation: Common bus arbitration (conflict resolution) techniques include Daisy Chaining, FIFO, LRU, Polling, and Static Priority. "State priority" is not a standard recognized bus arbitration algorithm.
(iv) Dynamic pipeline allows:
Answer: (a) Multiple functions to evaluate
Explanation: A dynamic (multi-functional) pipeline can be reconfigured dynamically to perform different functions at different times, as opposed to a static pipeline which performs a fixed function.
(v) A computer with cache access time of 100 ns, a main memory access time of 1000 ns and a hit ratio of 0.9 produces an average access time of:
Answer: (b) 200 ns
Explanation: Average Memory Access Time (AMAT) = $T_{cache} + (1 - ext{Hit Ratio}) imes T_{main\_memory} = 100 + (1 - 0.9) imes 1000 = 100 + 100 = 200$ ns.
(vi) The number of cycles required to complete n tasks in a k stage pipeline is:
Answer: (a) k + n - 1
Explanation: The first task takes $k$ cycles to complete. The remaining $(n-1)$ tasks each complete in $1$ cycle. Total cycles = $k + (n - 1)$.
(vii) The prefetching technique is a solution for:
Answer: (c) Control Hazard
Explanation: Instruction prefetching (often coupled with branch prediction) is primarily used to mitigate control hazards by fetching instructions down the predicted path before the branch is fully resolved, keeping the pipeline fed.
(viii) In general an n input Omega network requires ............ stages of 2 * 2 switches.
Answer: (b) 4 (Assuming a 16-input network)
Explanation: An $N$-input Omega network requires $\log_2 N$ stages. Since the options are constants (2, 4, 8, 16), the question likely had a typo and meant a 16-input network, which requires $\log_2 16 = 4$ stages.
(ix) Which of the following has no practical usage?
Answer: (c) MISD
Explanation: In Flynn's taxonomy, Multiple Instruction, Single Data (MISD) has no mainstream commercial implementation, unlike SISD (uniprocessors), SIMD (GPUs/Vectors), and MIMD (multiprocessors).
(x) The expression for Amdahl's law is:
Answer: (a) S(n) = 1/f where n → ∞
Explanation: If $f$ represents the sequential fraction of the code, Amdahl's Law states Speedup $S = rac{1}{f + (1-f)/n}$. As the number of processors $n o \infty$, the speedup asymptotically approaches $1/f$.
Let a pipeline have $k$ stages, and assume each stage takes $t_p$ time to execute. Let there be $n$ tasks to execute.
The speedup $S_k$ is the ratio of non-pipelined time to pipelined time:
To find the maximum (ideal) speedup, we take the limit as the number of tasks $n$ becomes very large ($n o \infty$):
Thus, ideally, a pipeline with $k$ stages can yield a maximum speedup equal to its depth $k$.
Given Instructions:
I1: MUL R1, R2, R3
I2: ADD R2, R3, R4
I3: INC R4
I4: SUB R6, R3, R7
Assumption: To make the dependency analysis meaningful (as per standard academic problems), we assume the instruction format is OP Source1, Source2, Destination. Therefore:
I1: MUL R1, R2, R3 → R3 = R1 * R2 (Writes R3)I2: ADD R2, R3, R4 → R4 = R2 + R3 (Reads R3, Writes R4). RAW hazard on R3 with I1.I3: INC R4 → R4 = R4 + 1 (Reads R4, Writes R4). RAW hazard on R4 with I2.I4: SUB R6, R3, R7 → R7 = R6 - R3 (Reads R3). RAW hazard on R3 with I1 (but resolved by the time I4 executes).Pipeline Execution Diagram (assuming a 5-stage pipeline: IF, ID, EX, MEM, WB and no hardware forwarding):
| Inst \ CC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
|---|---|---|---|---|---|---|---|---|---|---|---|
| I1 (MUL) | IF | ID | EX | MEM | WB | ||||||
| I2 (ADD) | IF | ID | Stall | Stall | EX | MEM | WB | ||||
| I3 (INC) | IF | Stall | Stall | ID | Stall | Stall | EX | MEM | WB | ||
| I4 (SUB) | IF | ID | EX | MEM | WB |
Delay Analysis:
A Reservation Table is a 2D space-time diagram representing the flow of data through the stages (or functional units) of a pipeline over successive clock cycles. The rows represent the functional units (hardware resources) and the columns represent clock cycles.
How it helps study pipeline performance:
Cache Coherence Problem: In a multiprocessor system where each processor has its own private cache, multiple copies of the same main memory data can exist in different caches. If Processor P1 modifies its local copy of variable X, Processor P2's cached copy of X becomes stale (outdated). If P2 reads X, it will read an incorrect value. Ensuring all processors see a consistent, updated view of shared memory is the cache coherence problem.
Method to Resolve (Snoopy Protocol - Write Invalidate):
In a bus-based multiprocessor, all cache controllers "snoop" (monitor) the shared bus. When P1 wants to write to variable X:
Limitations:
Given: Number of instructions $n = 15000$, Clock rate = $25$ MHz, Pipeline stages $k = 5$.
Clock cycle time $t_p = 1 / (25 imes 10^6)$ seconds = $40$ ns.
(i) Speedup compared to non-pipelined processor:
(ii) Efficiency and Throughput:
1. Broadcast (Write-Update) vs Write-Invalidate Protocols:
| Write-Invalidate | Write-Update (Broadcast) |
|---|---|
| On a write, the processor sends an invalidation signal. Other caches mark their copies invalid. | On a write, the processor broadcasts the new data on the bus. Other caches update their copies. |
| Generates less bus traffic if a block is written multiple times before being read by others. | Generates heavy bus traffic because every write to a shared block is broadcasted. |
| Subsequent reads by other processors result in cache misses. | Subsequent reads by other processors are cache hits. |
2. MESI Protocol:
MESI is a popular write-invalidate cache coherence protocol. Each cache line is in one of 4 states:
3. Centralized vs Distributed Shared Memory:
4. Superscalar, Super-pipelined, and VLIW Processors:
1. Flynn's Classification: Classifies computers based on the number of concurrent instruction streams and data streams.
2. Loosely Coupled vs Tightly Coupled Systems:
3. Network Designs:
4. Omega vs Delta Network:
5. Constructing an Omega Network for N=8:
An $N=8$ Omega network requires $\log_2(8) = 3$ stages. Each stage has $8/2 = 4$ switches (total 12 switches). The routing between stages follows a Perfect Shuffle pattern.
Inputs (0-7) undergo Perfect Shuffle before Stage 1:
0 -> 0, 4 -> 1, 1 -> 2, 5 -> 3, 2 -> 4, 6 -> 5, 3 -> 6, 7 -> 7
This shuffle is repeated between Stage 1 & 2, and Stage 2 & 3.
(a) Given Reservation Table:
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | |
|---|---|---|---|---|---|---|---|---|
| S1 | X | X | X | |||||
| S2 | X | X | ||||||
| S3 | X | X | X |
(b) Forbidden Latencies (FL):
The distance between pairs of 'X's in each row:
Union of Forbidden Latencies = {2, 4, 6}.
Permissible Latencies = {1, 3, 5, >=7}.
(c) Initial Collision Vector (CV):
CV is represented as $C_6 C_5 C_4 C_3 C_2 C_1$. Since 2, 4, 6 are forbidden, bits 2, 4, 6 are 1.
CV = 101010
State Transition Diagram generation:
(The full state transition diagram connects these states via directed edges representing the latency taken).
(d) Simple and Greedy Cycles:
(e) Optimal Constant Latency Cycle & Minimal Average Latency:
A constant latency cycle uses the same latency repeatedly. From the permissible latencies {1, 3, 5, 7}, we can try initiating repeatedly:
Trying latency 3: 3, 3, 3... This involves jumping from 101010 (takes 3) -> 101111. From 101111, latency 3 is NOT permissible (bit 3 is 1). So constant latency 3 is not possible.
Trying latency 5: from 101010 (takes 5) -> 101011. From 101011 (takes 5) -> 101011. This forms a constant latency cycle of (5).
Thus, the optimal constant latency cycle is 5.
The Minimal Average Latency (MAL) is the minimum average of any greedy cycle. Comparing (1,7) avg 4, and (3,5) avg 4. MAL = 4.
(f) Throughput:
Pipeline clock period $ au = 20$ ns. MAL = 4 cycles.
Average time between initiations = $MAL imes au = 4 imes 20 = 80$ ns.
Max Throughput = $1 / 80 ext{ ns} = 12.5 imes 10^6$ tasks/sec = 12.5 MIPS.
(a) Amdahl's Law calculations:
| Instruction | Frequency | CPI |
|---|---|---|
| ALU | 0.4 | 1 |
| Branch | 0.2 | 4 |
| Load | 0.3 | 2 |
| Store | 0.1 | 3 |
Base CPI = $(0.4 imes 1) + (0.2 imes 4) + (0.3 imes 2) + (0.1 imes 3) = 0.4 + 0.8 + 0.6 + 0.3 = \mathbf{2.1}$
Base Execution Time $\propto rac{Base\_CPI}{Base\_Clock}$
Conclusion: Improvement 2 (Increasing clock frequency to 2.3 GHz) provides the highest speedup (1.15x) and is the best option.
(b) Virtual Memory Concepts: