Final Exam Solutions

Final Exam Solutions - CS 351 Final Exam Solutions Notes...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CS 351 Final Exam Solutions Notes: You must explain your answers to receive partial credit. You will lose points for incorrect extraneous information, even if the answer is otherwise correct. Question 1: Short answer [25 points]. a. Define the compiler terms front end and back end . Front end: The part of the compiler that translates source code to an intermediate internal representation. Back end: The part of the compiler that translates the intermediate internal representation to machine code. Which one is responsible for architecture-specific optimizations, and why? Back end: The front end is machine-independent, while the back end translates the machine-independent IR to the architecture-specific machine code. b. What is a SIMD instruction? (Just stating what it stands for is not sufficient for full credit.) SIMD (“single instruction, multiple data”) has two meanings, either of which earns full credit: 1. An instruction that specifies a single operation to be carried out multiple times on different data, like a vector instruction 2. A specific type of #1 that treats a normal register as a vector of smaller operands, often seen in the media extensions to general- purpose instruction sets. What kind of parallelism does it exploit? DLP
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 c. What is VLIW? (Just stating what it stands for is not sufficient for full credit.) A VLIW (“very long instruction word”) instruction set packages multiple instructions that can execute at the same time into a single word. What kind of parallelism does it exploit? ILP Does it do so statically (at compile time) or dynamically (at runtime)? Explain. Statically. The compiler is responsible for finding instructions that can execute at the same time; that is, instructions that are independent and which the machine has sufficient hardware to execute at once. d. What are the sources of overhead for context switching (switching between threads) on a uniprocessor? The big ones are saving and restoring register state, as well as raising and returning from the exception. e. What model for inter-processor communication is typically used in clusters? Why? Message-passing; it matches the physical reality of processors in clusters (connected over a network) better than shared memory. (Talking about specific distributed programming platforms that abstract this away is also OK.)
Background image of page 2
3 Question 2: Compiler optimizations [20 points]. (a) In MIPS or a higher-level language, show an example of dead code elimination; that is, show the code before and after the optimization is applied. Before: if (false) cout << “False!”; a = 6; After: a = 6; (b) In MIPS or a higher-level language, show an example of constant propagation; that is, show the code before and after the optimization is applied.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 10

Final Exam Solutions - CS 351 Final Exam Solutions Notes...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online