Blog
Advance Computer Architecture Past Paper 2015 – MS CS 1st Term UOS (CS-5240)
University of Sargodha MS Computer Science 1st term Advance Computer Architecture (CS-5240) paper, 2015 exam (80 marks, 3 hours). The paper has been retyped, and solved answers are given below for all short questions and all six long questions, including the cache-coherence table for write-through and write-back, Amdahl’s law, MIN bandwidth and the in-forest Gantt chart.
Solved answers
Q1 – Short answers (8 × 2)
1. MISD architecture: Multiple Instruction, Single Data – several processing units perform different operations on the same data stream; rarely built, examples are systolic arrays and redundant fault-tolerant systems.
2. Bus arbitration logic: Hardware that decides which of several masters (processors, DMA) gets control of a shared bus when more than one requests it, using schemes such as daisy chaining, centralized parallel arbitration with priorities, or distributed arbitration.
3. Single-stage network: An interconnection network with one stage of switches between inputs and outputs (e.g. a recirculating shuffle-exchange network); data may need to pass through it several times to reach the destination.
4. Snooping protocol: A cache-coherence protocol for bus-based systems in which every cache controller monitors (snoops) the bus and invalidates or updates its copy when another processor writes the same block (e.g. MSI, MESI).
5. ERCW PRAM: Exclusive-Read Concurrent-Write PRAM: no two processors may read the same memory location in the same step, but several may write to it simultaneously (conflict resolved by a rule such as common, arbitrary or priority).
6. Channel dependency graph: A directed graph whose vertices are network channels and whose edges show that a packet holding one channel may request another under the routing function. A routing algorithm is deadlock-free if this graph is acyclic (Dally & Seitz).
7. MPI: Message Passing Interface – a standard library for writing parallel programs on distributed-memory systems, with point-to-point (MPI_Send/MPI_Recv) and collective (MPI_Bcast, MPI_Reduce) operations.
8. Equal duration model: A speedup model that assumes a task is divided into n equal subtasks, each executed by one processor in time ts/n. Ignoring overhead, S = n; with communication overhead tc, S = ts/(ts/n + tc) = n/(1 + n·tc/ts), and efficiency falls as n grows.
Q2 – Berkeley NOW and task creation in PVM
Berkeley Network of Workstations (NOW): a UC Berkeley project (mid-1990s) that built a cluster of about 100 Sun UltraSPARC workstations connected by a fast Myrinet switch to act as one large parallel machine. Key ideas: Active Messages for low-latency communication, GLUnix (global OS layer for process management and using idle workstations), xFS serverless network file system and network RAM. It showed that commodity workstations can match MPPs in cost-performance.
Task creation in PVM (Parallel Virtual Machine): a PVM program is a set of tasks running on hosts of the virtual machine. A task enrolls with pvm_mytid() and creates new tasks with
numt = pvm_spawn("worker", argv, PvmTaskDefault, "", ntask, tids);which starts ntask copies of the executable on hosts chosen by PVM (or on a named host/architecture with PvmTaskHost/PvmTaskArch) and returns their task IDs in tids. pvm_parent() gives the parent’s ID, so master and workers communicate with pvm_send/pvm_recv; pvm_exit() leaves PVM and pvm_kill(tid) terminates a task. Tasks can also join named groups (pvm_joingroup) for collective operations.
Q3 – Omega network and cube-connected networks
a) Omega network: N×N multistage network of log2N stages, each with N/2 2×2 switches; a perfect-shuffle connection (rotate the address left by one bit) precedes every stage. Self-routing: at stage i look at bit i (MSB first) of the destination – 0 → upper output, 1 → lower output. For N = 8 there are 3 stages of 4 switches. Cost O(N log N), delay O(log N); it is blocking because two messages may need the same link.
8×8 Omega: inputs ─shuffle─[S][S][S][S]─shuffle─[S][S][S][S]─shuffle─[S][S][S][S]─ outputs
Route 010 → 110: stage 1 bit 1 → lower, stage 2 bit 1 → lower, stage 3 bit 0 → upperb) Cube-connected (hypercube) static network: 2n nodes, each labelled with an n-bit address; two nodes are linked if their addresses differ in exactly one bit. Degree = n, diameter = n = log2N, bisection width = N/2. Routing (e-cube): correct the differing bits one dimension at a time. A cube-connected cycles (CCC) network replaces each hypercube node by a ring of n nodes to keep degree 3.
3-cube: 000─001 010─011 100─101 110─111 (dimension 0)
000─010, 001─011, 100─110, 101─111 (dimension 1)
000─100, 001─101, 010─110, 011─111 (dimension 2)Q4 – Amdahl’s law and MIN bandwidth
A) Amdahl’s law: if a fraction f of a computation is serial and the remaining (1 − f) can be perfectly parallelised over n processors:
Speedup S(n) = 1 / ( f + (1 − f)/n ) f = serial fraction, n = processors
As n → ∞, S → 1/f e.g. f = 0.1 → maximum speedup 10So a small serial part limits speedup severely; e.g. with f = 5%, 100 processors give only 16.8×. Gustafson’s law answers this by scaling the problem size with n.
B) Bandwidth of a multistage interconnection network: in an N×N MIN built from k×k switches, each input generates a request with probability r per cycle. Because the network is blocking, two requests may collide on an internal link and one is lost or delayed. For a k×k crossbar switch, the probability that an output is busy is
r_out = 1 − (1 − r_in / k)^kand this is applied stage by stage (logkN stages). Bandwidth = N × rout of last stage, which is lower than for a full crossbar and decreases as the number of stages grows. Performance issues: internal blocking and contention, hot-spot traffic (tree saturation), path conflicts, switch delay per stage, buffering and the cost/bandwidth trade-off. Remedies include buffered switches, extra stages or multiple paths (Benes, dilated networks) and combining switches.
Q5 – Cache coherence (one-block caches)
Initial memory: x = 10, y = 30, z = 80, w = 20; all caches empty. (V = valid, I = invalid, D = valid and dirty.)
(1) Write-through, write-invalidate – every write also updates memory and invalidates other copies:
| Event | P1 cache | P2 cache | P3 cache | Memory x / z |
|---|---|---|---|---|
| 1) P1 Read(x) | x = 10 V | – | – | 10 / 80 |
| 2) P2 Read(x) | x = 10 V | x = 10 V | – | 10 / 80 |
| 3) P3 Read(x) | x = 10 V | x = 10 V | x = 10 V | 10 / 80 |
| 4) P1: x = x + 25 | x = 35 V | x = 10 I | x = 10 I | 35 / 80 |
| 5) P1 Read(z) | z = 80 V (x replaced) | x I | x I | 35 / 80 |
| 6) P2 Read(x) | z = 80 V | x = 35 V | x I | 35 / 80 |
| 7) P3: x = 15 | z = 80 V | x = 35 I | x = 15 V | 15 / 80 |
| 8) P1: z = z + 1 | z = 81 V | x I | x = 15 V | 15 / 81 |
(2) Write-back, write-invalidate – writes stay in the cache (dirty) until the block is replaced:
| Event | P1 cache | P2 cache | P3 cache | Memory x / z |
|---|---|---|---|---|
| 1) P1 Read(x) | x = 10 V | – | – | 10 / 80 |
| 2) P2 Read(x) | x = 10 V | x = 10 V | – | 10 / 80 |
| 3) P3 Read(x) | x = 10 V | x = 10 V | x = 10 V | 10 / 80 |
| 4) P1: x = x + 25 | x = 35 D | x = 10 I | x = 10 I | 10 / 80 |
| 5) P1 Read(z) | z = 80 V (x = 35 written back) | x I | x I | 35 / 80 |
| 6) P2 Read(x) | z = 80 V | x = 35 V | x I | 35 / 80 |
| 7) P3: x = 15 | z = 80 V | x = 35 I | x = 15 D | 35 / 80 |
| 8) P1: z = z + 1 | z = 81 D | x I | x = 15 D | 35 / 80 |
Difference: with write-back, memory is stale after steps 4, 7 and 8 (x = 35 vs 15 in cache, z = 80 vs 81); the dirty owner must supply the block on a later miss. Write-allocate is assumed for the write miss in step 7.
Q6 – Deadlock, livelock and starvation in message-passing multicomputers
- Deadlock: a set of messages each holds a channel/buffer and waits for one held by another, forming a cycle (the four conditions: mutual exclusion of buffers, hold and wait, no preemption, circular wait). Example: four packets in a 2-D mesh ring each waiting for the next link. Avoidance: deadlock-free routing such as dimension-order (XY / e-cube) routing, which makes the channel dependency graph acyclic; virtual channels (e.g. dateline technique on a torus); enough buffers; deadlock detection and recovery (abort and retransmit).
- Livelock: packets keep moving but never reach their destination, typical with adaptive non-minimal or deflection (hot-potato) routing. Avoidance: use minimal routing, limit the number of misroutes, or give priority to older packets (age-based priority) so they eventually progress.
- Starvation: a packet or node waits indefinitely because others always win arbitration for a resource, e.g. a low-priority node at the end of a daisy chain. Avoidance: fair arbitration (round-robin, FIFO queues), aging of priorities, and guaranteed injection bandwidth.
Example: in a 4×4 mesh using XY routing a message first travels fully in X then in Y, so a cyclic wait between X and Y channels cannot form – no deadlock; adding age priority to an adaptive router prevents both livelock and starvation.
Q7 – Scheduling in-forests/out-forests on two processors (with communication)
In-forest: every task has at most one successor (tree edges point towards the root); out-forest: every task has at most one predecessor. With unit execution times and a unit communication delay between tasks on different processors (model C), the algorithm (El-Rewini & Abd-El-Barr) works as follows:
- Compute the level of each task = length of the longest path from it to the root (exit task). Here: level(i) = 1; g, h = 2; c, d, e, f = 3; a, b = 4.
- Schedule level by level using a highest-level-first list (Hu’s rule), filling both processors at every time step when tasks are ready.
- To respect communication, keep a parent on the same processor as the child that finishes last (its critical child), so the parent does not wait one extra unit; a task whose predecessor is on the other processor may start only one unit after that predecessor finishes.
- For out-forests the same algorithm is applied to the reversed graph and the schedule is read in reverse.
Schedule for the given in-forest (a, b → c; c, d → g; e, f → h; g, h → i):
| Time | 0–1 | 1–2 | 2–3 | 3–4 | 4–5 | 5–6 |
|---|---|---|---|---|---|---|
| P1 | a | b | c | d | g | i |
| P2 | e | f | h | idle | idle | idle |
h finishes on P2 at time 3, so with the one-unit delay its result reaches P1 at 4 – well before i starts at 5. c and d are on P1, so g needs no communication. Makespan = 6 units. Without communication the optimum would be 5 (9 unit tasks on 2 processors); with the communication delay an exhaustive search of all schedules (checked in Python) shows that 6 is the minimum, so this schedule is optimal.
