Final Exam Solutions

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

Info icon This 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
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.)
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.
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 ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern