Advanced Computer Architecture, Past Papers, UOS Main Campus

Advance Computer Architecture Past Paper 2014 – MS CS 1st Term UOS (CS-5240)

ProgramMS CS
Term1st
Year2014
Course codeCS-5240
AnswersSolved ✓

University of Sargodha MS Computer Science 1st term Advance Computer Architecture (CS-5240) paper, 2014 exam, session 2013-15 (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 Omega/Banyan networks, directory protocols, improved leader election and in-forest scheduling.

Solved answers

Q1 – Short answers (8 × 2)

i. Amdahl’s Law: The speedup of a program on n processors is limited by its serial (non-parallelisable) fraction f: S = 1 / (f + (1 − f)/n), so it can never exceed 1/f however many processors are used.

ii. Grosch’s Law: Herbert Grosch (1953) observed that computer performance increases as the square of its cost (P = k·C²), i.e. a computer twice as expensive is four times as powerful – an argument for one big machine instead of many small ones (later invalidated by cheap microprocessors).

iii. Switching mechanisms: Circuit switching, packet switching (store-and-forward), virtual cut-through and wormhole routing.

iv. Routing potential problems: Deadlock (cyclic waiting for buffers/channels), livelock (packets circulate without reaching the destination) and starvation (a packet waits indefinitely because others always get priority).

v. FlashMob I: The first “flash mob” supercomputer (April 2004, University of San Francisco): hundreds of volunteer PCs and laptops were connected for a single day over a fast network to run the LINPACK benchmark as a temporary cluster, showing that a supercomputer can be assembled on demand from ordinary machines.

vi. Two early successful Beowulf clusters: The original Beowulf at NASA Goddard (1994, Sterling & Becker, 16 Intel 486 PCs on Ethernet running Linux) and Loki/Avalon at Los Alamos (1996/1998); Hyglac at Caltech/JPL is another example.

vii. Barriers and precedence relations: A barrier is a synchronisation point where all processes must arrive before any can continue. Precedence relations specify that a task can start only after certain other tasks finish (edges of a task graph); barriers enforce such ordering between phases.

viii. Virtual topologies: A logical arrangement of processes (e.g. Cartesian grid or graph) defined in MPI with MPI_Cart_create/MPI_Graph_create, mapping the communication pattern of the application onto the physical network and simplifying neighbour addressing.

Q2 – Omega network, Banyan network, reduction operation

a) Omega network: a multistage interconnection network for N inputs and N outputs built from log2N stages, each with N/2 2×2 switches, connected by a perfect-shuffle pattern before every stage. Routing is self-routing using the destination address: at stage i the switch sends the message to the upper output if bit i of the destination is 0, otherwise to the lower output. It is blocking (some permutations conflict) and costs O(N log N) switches.

b) Banyan network: a class of multistage networks in which there is exactly one path between each input and each output. Omega, butterfly, baseline and delta networks are Banyan networks. They are cheap and self-routing but blocking; an N×N Banyan of 2×2 switches has log2N stages.

c) Reduction operation: combining values held by all processes with an associative operator (sum, max, min, product, logical AND…) to produce one result, e.g. MPI_Reduce(&x, &sum, 1, MPI_INT, MPI_SUM, 0, comm). Implemented as a tree: in each of log2p steps half of the processes send their partial results to partners that combine them, so the time is O(log p) instead of O(p). MPI_Allreduce returns the result to every process.

Q3 – Directory-based cache coherence

a) Centralized directory invalidate: a single directory (at memory) keeps, for every block, a presence bit-vector (one bit per cache) and a dirty bit. On a read miss the directory supplies the block (fetching it from the owner if dirty) and sets the reader’s bit. On a write, the directory sends invalidate messages to all caches whose bits are set, waits for acknowledgements, clears their bits and marks the writer as exclusive owner. Simple but the central directory becomes a bottleneck and needs N bits per block.

b) Scalable Coherent Interface (SCI, IEEE 1596): a distributed directory standard in which the sharers of a block are kept in a doubly-linked list; memory stores only a pointer to the head. A new reader inserts itself at the head; on a write the head walks the list invalidating sharers. Storage grows with the number of sharers, not processors, so it scales well, but invalidation latency is proportional to list length.

c) Stanford Distributed Directory (SDD): also uses a linked list of sharers, but singly-linked; the memory directory points to the most recent sharer, which points to the previous one, and so on. A new reader becomes the head; on a write the writer becomes owner and invalidations are passed down the list. It needs less storage than SCI but replacement of a block from the middle of the list is harder.

Q4 – Improved leader election algorithm (ring)

In a ring of n processes with unique IDs, the simple LeLann/Chang-Roberts algorithm needs O(n²) messages in the worst case. The improved (Hirschberg–Sinclair) algorithm works in phases:

  1. In phase k (k = 0, 1, 2, …) every still-active process sends its ID in both directions to a distance 2k.
  2. A process receiving an ID smaller than its own discards it (or replies “no”); if the ID is larger, it forwards it until the distance 2k is reached and then sends a reply back.
  3. A process that receives replies from both directions survives to phase k + 1; otherwise it becomes passive and only relays messages.
  4. A process that receives its own ID travelling all the way round the ring is the leader and announces itself.

Complexity: a process is active in phase k only if it has the largest ID within distance 2k−1, so at most ⌈n/(2k−1+1)⌉ processes start phase k. Each sends at most 4·2k messages (out and back, both directions), so each phase costs at most about 8n messages. There are ⌈log2 n⌉ + 1 phases, giving O(n log n) messages and O(n) time – much better than O(n²).

Q5 – Flynn’s taxonomy

Flynn (1966) classifies computers by the number of concurrent instruction streams and data streams:

ClassMeaningExamples
SISDSingle instruction, single data – one processor executes one instruction on one data item at a timeClassic von Neumann uniprocessor PC
SIMDSingle instruction, multiple data – one control unit broadcasts each instruction to many processing elements working on different dataArray processors, vector units, GPUs, SSE/AVX
MISDMultiple instruction, single data – several processors apply different operations to the same data streamSystolic arrays, fault-tolerant flight computers (rare)
MIMDMultiple instruction, multiple data – independent processors run different programs on different dataMulticores, SMPs, clusters, MPPs

MIMD is further split into shared-memory (multiprocessors, UMA/NUMA) and message-passing (multicomputers) systems.

Q6 – One-sided communication

In one-sided communication (remote memory access, MPI-2 RMA) only one process specifies all communication parameters; the target does not post a matching receive. Each process exposes a memory region called a window (MPI_Win_create). The origin then uses MPI_Put (write into remote memory), MPI_Get (read from remote memory) or MPI_Accumulate (combine with an operation).

Synchronisation is separate from data transfer: active target – MPI_Win_fence or post/start/complete/wait; passive target – MPI_Win_lock/MPI_Win_unlock. Advantages: decouples sender and receiver, reduces synchronisation overhead and suits irregular access patterns and hardware with RDMA. Disadvantages: programmer must avoid conflicting accesses (races) inside an epoch.

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:

  1. 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.
  2. Schedule level by level using a highest-level-first list (Hu’s rule), filling both processors at every time step when tasks are ready.
  3. 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.
  4. 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):

Time0–11–22–33–44–55–6
P1abcdgi
P2efhidleidleidle

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.

Save this paper for offline studyDownload the question paper, or save the paper together with all solved answers as a PDF.
↓ Download Paper (JPG)

About Saif R

An educator and technology enthusiast passionate about empowering students through quality education and digital learning. Dedicated to making academic resources and opportunities accessible to everyone.