UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. M.Sc. in Computational Science & Engineering

Similar documents
Open Book Examination. Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. M.Sc. in Mathematics & Computational Science

COMP-421 Compiler Design. Presented by Dr Ioanna Dionysiou

Context-Free Grammar. Concepts Introduced in Chapter 2. Parse Trees. Example Grammar and Derivation

STACKS. A stack is defined in terms of its behavior. The common operations associated with a stack are as follows:

Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE

SECOND PUBLIC EXAMINATION. Compilers

DEEPIKA KAMBOJ UNIT 2. What is Stack?

Question Points Score

Today's Topics. CISC 458 Winter J.R. Cordy

A Simple Syntax-Directed Translator

Draw a diagram of an empty circular queue and describe it to the reader.

Generating Code for Assignment Statements back to work. Comp 412 COMP 412 FALL Chapters 4, 6 & 7 in EaC2e. source code. IR IR target.

Comp 204: Computer Systems and Their Implementation. Lecture 22: Code Generation and Optimisation

Compiler Code Generation COMP360

Stack. 4. In Stack all Operations such as Insertion and Deletion are permitted at only one end. Size of the Stack 6. Maximum Value of Stack Top 5

Chapter 2 A Quick Tour

Stacks. stacks of dishes or trays in a cafeteria. Last In First Out discipline (LIFO)

Chapter 4. MARIE: An Introduction to a Simple Computer

Closed Book Examination. One and a half hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE. Date: Wednesday 20 th January 2010

CSE P 501 Exam 8/5/04

MARIE: An Introduction to a Simple Computer

CS4215 Programming Language Implementation

THE AUSTRALIAN NATIONAL UNIVERSITY Mid Semester Examination April COMP3320/6464 High Performance Scientific Computing

COMP 303 Computer Architecture Lecture 3. Comp 303 Computer Architecture

Postfix Notation is a notation in which the operator follows its operands in the expression (e.g ).

CISC-235. At this point we fnally turned our atention to a data structure: the stack

Lexical Considerations

Stating the obvious, people and computers do not speak the same language.

Compilers and computer architecture: A realistic compiler to MIPS

1 Lexical Considerations

Chapter 2A Instructions: Language of the Computer

One and a half hours. Section A is COMPULSORY

Programming at different levels

19 Much that I bound, I could not free; Much that I freed returned to me. Lee Wilson Dodd

Special Section: Building Your Own Compiler

Anatomy of a Compiler. Overview of Semantic Analysis. The Compiler So Far. Why a Separate Semantic Analysis?

SEMANTIC ANALYSIS TYPES AND DECLARATIONS

Syntax-Directed Translation. Lecture 14

RYERSON POLYTECHNIC UNIVERSITY DEPARTMENT OF MATH, PHYSICS, AND COMPUTER SCIENCE CPS 710 FINAL EXAM FALL 96 INSTRUCTIONS

Recursive Definitions

7/8/10 KEY CONCEPTS. Problem COMP 10 EXPLORING COMPUTER SCIENCE. Algorithm. Lecture 2 Variables, Types, and Programs. Program PROBLEM SOLVING

MARIE: An Introduction to a Simple Computer

Digital Forensics Lecture 3 - Reverse Engineering

COMP 202 Recursion. CONTENTS: Recursion. COMP Recursion 1

CS/COE1541: Introduction to Computer Architecture

CPT1. Unit 1 Computer Systems, Programming and Networking Concepts. General Certificate of Education January 2004 Advanced Subsidiary Examination

Chapter 4. Chapter 4 Objectives. MARIE: An Introduction to a Simple Computer

09 STACK APPLICATION DATA STRUCTURES AND ALGORITHMS REVERSE POLISH NOTATION

Introduction to Syntax Directed Translation and Top-Down Parsers

Wednesday, September 27, 2017

EC 413 Computer Organization

CSE443 Compilers. Dr. Carl Alphonce 343 Davis Hall

Compilers and computer architecture Code-generation (2): register-machines

ECOR Come to the PASS workshop with your mock exam complete. During the workshop you can work with other students to review your work.

Run-Time Data Structures

MIDTERM EXAMINATION - CS130 - Spring 2003

Evaluation of Semantic Actions in Predictive Non- Recursive Parsing

In this chapter you ll learn:

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

The role of semantic analysis in a compiler

Faculty of Engineering Student Number:

Arrays and Functions

ECE 109 Sections 602 to 605 Final exam Fall December, 2007

Chapter 5. A Closer Look at Instruction Set Architectures. Chapter 5 Objectives. 5.1 Introduction. 5.2 Instruction Formats

MIPS Assembly Programming

BCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 4 Certificate in IT SOFTWARE DEVELOPMENT

SOFTWARE ARCHITECTURE 5. COMPILER

Chapter 5. A Closer Look at Instruction Set Architectures

STUDENT LESSON A9 Recursion

An Interactive Desk Calculator. Project P2 of. Common Lisp: An Interactive Approach. Stuart C. Shapiro. Department of Computer Science

Top down vs. bottom up parsing

Assembly Language Manual for the STACK Computer

Some Applications of Stack. Spring Semester 2007 Programming and Data Structure 1

Review: Expressions, Variables, Loops, and more.

THE HONG KONG UNIVERSITY OF SCIENCE & TECHNOLOGY Computer Organization (COMP 2611) Spring Semester, 2014 Final Examination

Yacc: A Syntactic Analysers Generator

SaM. 1. Introduction. 2. Stack Machine

ECE 2400 Computer Systems Programming Fall 2018 Topic 1: Introduction to C

COMPILER CONSTRUCTION LAB 2 THE SYMBOL TABLE. Tutorial 2 LABS. PHASES OF A COMPILER Source Program. Lab 2 Symbol table

Computing Inside The Parser Syntax-Directed Translation, II. Comp 412 COMP 412 FALL Chapter 4 in EaC2e. source code. IR IR target.

Team 1. Common Questions to all Teams. Team 2. Team 3. CO200-Computer Organization and Architecture - Assignment One

BBM 201 DATA STRUCTURES

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler so far

A parser is some system capable of constructing the derivation of any sentence in some language L(G) based on a grammar G.

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End

MIDTERM EXAM (Solutions)

BBM 201 DATA STRUCTURES

Two hours - online EXAM PAPER MUST NOT BE REMOVED FROM THE EXAM ROOM UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE

Specifying Syntax COMP360

// The next 4 functions return true on success, false on failure

Computer Architecture

Lecture Code Generation for WLM

One and a half hours. Section A is COMPULSORY UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE

CS251 Programming Languages Handout # 29 Prof. Lyn Turbak March 7, 2007 Wellesley College

Introduction to Computer Science Midterm 3 Fall, Points

Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE

COMPILERS BASIC COMPILER FUNCTIONS

SMURF Language Reference Manual Serial MUsic Represented as Functions

LECTURE 3. Compiler Phases

COP4020 Programming Assignment 2 - Fall 2016

Transcription:

COMP60081 Two hours UNIVERSITY OF MANCHESTER SCHOOL OF COMPUTER SCIENCE M.Sc. in Computational Science & Engineering Fundamentals of High Performance Execution Wednesday 16 th January 2008 Time: 09:45 11:45 Please answer TWO Questions from the FOUR questions provided This is an OPEN book examination The use of electronic calculators is permitted provided they are not programmable and do not store text [PTO]

Page 2 of 7 COMP60081 1. a) Describe the general format and operation of the main classes of instruction that are encountered in a typical computer with a register-based load/store instruction set architecture (ISA). Include details of any memory accesses made during execution of each class of instruction. (5 marks) b) The following C program is to be compiled for a register-based load/store ISA and then executed serially on a single CPU. /*define a constant */ #define size 5000 /* declare tiletable as a globally accessible array */ double tiletable[size][size] ; /* signature of function tiletablelookup must */ /* be declared before main program is compiled */ double tiletablelookup(int x, int y); /* definition of main program */ int main( ) { int i,j; double result[size][size]; /* assume arrays are filled with values before here */ /* following is the main loop (see question) */ for (j = 0; j < size; j++) { for (i = 0; i < size; i++) { result[i][j] += tiletablelookup(i,j) ; /* assume result[][] is read after this point */ /* end of main program */ /* now give full definition of function tiletablelookup */ double tiletablelookup(int x, int y) { return tiletable[x][y]; /* end of function tiletablelookup */ Question 1 continues on the following page.

Page 3 of 7 COMP60081 Question 1 continues from the previous page. i) Without attempting any optimisation sketch out the machine-level instructions that might be generated by a C compiler for the main loop (marked) of this program. (You may use here either an assembler language with which you are familiar, or one which you have invented, or an assembler-level pseudo-code. In the latter cases, please make clear what each instruction is intended to do.) ii) iii) Identify two sections of the code in your answer to part i) which may lead to poor performance, explaining in each case the factors causing performance to be poor. (4 marks) Suggest instruction-level optimisations that could be applied to the code from part i) in order to remedy the performance problems identified in part ii). Making reasonable assumptions, quantify the potential benefits of applying your suggested optimisations. (5 marks) (Note: remember that arrays in C are stored in memory in row-major order) [PTO]

Page 4 of 7 COMP60081 2. a) The following C program computes the factorial of 5 using a recursive algorithm. #define size 5 int fac(int n); int main() { int answer; answer = fac(size); /*assume answer printed here/* int fac(int n){ int result; if (n<2) result = 1; else result = n*fac(n-1); return result i) Define suitable activation records for the two functions main and fac. Explain what each field in each activation record is used for. (5 marks) ii) iii) Show how copies of each activation record are placed on the stack and the values in them are changed as execution proceeds from start to finish. How many times is the statement return result executed? What are the values returned at each time? (2 marks) b) Describe the features in a typical register-based instruction set architecture that assist with entry to, and exit from, a function such as that defined above. In both cases, explain the sequence of actions that are necessary and show how the features that you describe help each action. (7 marks)

Page 5 of 7 COMP60081 3. In a typical modern microprocessor system the main memory cycle time is nearly three orders of magnitude larger than the CPU clock cycle time. Computer system designers have thus invented several mechanisms that minimise the need to access main memory. a) CPU registers typically deliver data within one CPU clock cycle. Why do instruction set designers not provide a very large number of CPU registers in order to minimise memory accesses? (2 marks) b) Explain how a cache memory is able to provide the same interface as the main memory and yet provides faster access to data in appropriate circumstances. What characteristics are important in a program in order to take advantage of a cache memory? Why is the notion of a cache line important? (5 marks) c) What policies are available for: i) placement of a cache line when it is first brought into the cache memory; ii) iii) writing a changed cache line back to the main memory; and displacement of a cache line when a new cache line is needed but there is no vacant place to put it in the cache memory? What effects do the above policies have on cache memory performance? (7 marks) d) A memory system designer is faced with a choice between the two two-level cache memory schemes defined in Table 1. Which of the two schemes would you select, and why? Level-1 cache: Size Cycle time Expected read hit rate Scheme A 8 kb 2ns 90% Scheme B 16 kb 2ns 95% Level-2 cache: Size Cycle time Expected read hit rate 256 kb 20ns 80% 128 kb 20ns 60% Main memory access time 100ns 100ns Table 1: (1 ns = 10-9 seconds; the Level-2 hit rate is the local rate, that is, the percentage of accesses referred to the Level-2 cache memory by a miss in the Level-1 cache memory that result in a Level-2 hit.) [PTO]

Page 6 of 7 COMP60081 4. Consider the following grammar that describes arithmetic expressions involving the operators,,,, and brackets, and the associated semantic rules for computing the postfix notation of the expression. Production Semantic Rule expr expr term expr.t : expr.t term. t ' ' expr expr term expr.t : expr.t term. t ' ' expr term expr.t : term. t term term factor term. t : term. t factor. t ' ' term term factor term.: t term. t factor. ' t ' term factor term. t : factor. t factor ( expr ) factor.: t expr.t factor id factor. t : 'id' factor num factor. t : ' num' Here id is an identifier and num is a integer constant. a) By constructing the annotated syntax trees, show that i) ( a 2) ( b c) d ii) a 2 ( b c) d and iii) a 2 b c d where a, b, c, d are identifiers, and 2 is an integer constant, are valid arithmetic expressions and obtain the postfix notations for the three expressions. (14 marks) (Question 4 continues on the following page)

Page 7 of 7 COMP60081 (Question 4 continues from the previous page) b) Given an abstract stack machine with the following instructions: push v push integer constant v onto the stack rvalue l push contents of data location l onto stack lvalue l push address of data location l onto stack + pop and add two topmost values on stack and push result onto stack. pop the two topmost values from stack, subtract the topmost value from the second topmost value and push result onto stack. pop and multiply two topmost values on stack and push result onto stack. pop the two topmost values from stack, divide the second topmost value by the topmost value and push result onto stack. := the r-value on top of the stack is placed in the l-value below and both are popped. write machine instructions to perform the assignment e ( a 2) ( b c) d where e is an identifier. Trace the contents of the stack throughout the set of machine instructions. END OF EXAMINATION