



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




This document contains examples of questions that would be typical of the kinds of questions that might appear on a real midterm exam #1. The actual exam questions will not be the same, or necessarily even very similar, although they will be generally within the same overall topic area, and will have roughly the same overall level of difficulty.
Suppose you are in charge of setting up a corporate data center, and you have a total budget of $100,000 to spend on a new cluster of computers. The users of your data center need to constantly and repeatedly run a given application program “P” on the machines in this cluster. You are trying to decide what type of computers to buy for the cluster. The company’s goal is to enable the pool of users to run the program P as frequently as possible – the more often, the better. You can buy as many computers for your cluster as you can afford while staying within budget. 1a. Identify the true nature of the problem to be solved, as an engineering problem. What quantity or quantities should you really be trying to optimize, and for each one, should you be trying to maximize or minimize that particular quantity? Circle all that apply. i. Number of instructions-per-second executed per machine. Max / min? ii. Total throughput of your data center, within budget. Max / min? iii. Performance of each individual machine on program P. Max / min? iv. Cost-performance (performance per unit cost) on P Max / min? of the type of machine that is purchased. v. Execution time of each machine when running program P. Max / min? vi. The CPI of the type of machine that is purchased. Max / min? 1b. Now suppose that for each type of machine M , you know all of the following quantities: The dynamic instruction count IC of machine M when running program P. The average cycles-per-instruction CPI of the machine when running P. The clock frequency f of the machine. The cost C of the machine, in dollars. Now, formulate an expression for the key figure of merit that you should be trying to maximize or minimize, in terms of the above variables. Write the expression below.
1c. Given the below data for the following three machines A,B,C (with IC and CPI as measured for program P) use your formula from part (1b) to solve the problem of deciding which of these three types of machines you ought to buy. Show your work below the table. How many times better (according to the correct figure of merit) is the best machine, compared to the second-best alternative? Type A computers Type B computers Type C computers Instruction count 12 × 109 3 × 109 4 × 109 Cycles per instr. 1 1.5 2 Clock frequency 4 GHz 3 GHz 2.8 GHz Cost $1,000 $2,000 $
Given the following C language function that returns the maximum value from an array, design a correct implementation of this function in MIPS assembly language; that is, hand-compile this C code to equivalent MIPS assembly. Use standard MIPS calling conventions, except don’t worry about the frame pointer. Assume that an int is 32 bits. Don’t worry about whether this particular algorithm works correctly when the max is negative (it doesn’t). int max(int A[],int n){ /* Find max value in array A / int m = 0, i; / Initial max = 0 / for(i=0; i<n; i++) / For each index in array, / if (A[i]>m) m=A[i]; / If >max, update max / return m; / Return the final maximum */ } Please write neatly, comment your code, and draw a neat table showing any correspondences that you may have set up between MIPS registers and C code variables.
You may recall that the course syllabus listed the following items under “Course Instructional Objectives:” At the completion of this course, students should be able to: