fall09Exam2Key

fall09Exam2Key - ECE 468/495S Fall 2009, Second Exam...

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

View Full Document Right Arrow Icon
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

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

View Full DocumentRight Arrow Icon
Background image of page 4
Background image of page 5

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

View Full DocumentRight Arrow Icon
Background image of page 6
Background image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ECE 468/495S Fall 2009, Second Exam version 1 DO NOT START WORKING ON THIS UNTIL TOLD TO DO SO. LEAVE IT ON THE DESK. Your exam should have 7 pages total (including this cover sheet). Please let Prof. Midkifi” know immediately if it does not. This exam is open book and open notes. If you have a question, please ask for clarification. If the question is still not clear, state Whatever assumptions you need to make to answer the question, and answer it under those assumptions. Check the front board occasionally for corrections. The questions are not numbered, but are identified by the symbols 4,.5, Q9, 0, and A. ASSUME no aliasing in any question, that is variables with different names occupy different memory locations. WHEN I ask for answers of X words or less, this is a guideline. If you are a few words over, I won’t care. Question &a (8 points): Given the grammar Glz AB$ buterb>co iiiii U3 4(a) 5pts. : Fill in state 10 in the CFSM above. $(b) 4pts: Is the grammar LR(0)? (answer yes, no, cannot tell). $2165 ( m5) f a" 6?: ngt C04 t .6, “EMS $(c) 4pts: Consider the LR(0) parse state: state stack: 1 2 5 symbol stack: A c next input: $ What is the next action, and the contents of the state and symbol stack after that action? Rediwe Simian 3 3L3: gmisrmétbg f A 8 &(d) 4pts: Write an LL(1) parse routine for A e M; Pebmgt‘ "A L 5 7» f 1. (t \ ghfiéw‘gé__ C (N? 1 {NE ( me 3?: ‘6‘ fl ) gug\‘m,{ Cxé ‘ > BM Question Q. Given the loop L1: for (2' = 1;i < 6;2'++){ for (j:1;j<6;j++) { a[i,j] = a[i—2,j+1] + a[i+1][j-2] } } 5 O O O O O 5 O O O O O 4 O O O O O 4 O O O O O 3 O O O O O 3 Ox OM OX 0 O 2 O o 2 o\\\ o \o to o V“ “we. ' Wka p it" 5 j= 1 O O NO j: 1 O b 0 Cd 0 i: 1 2 3 4 5 i: 1 2 3 4 5 (a) (b) ¢(a) 4pts: Fill in at least three dependence edges in the iteration space diagram “(a)” above for any dependence between a[i , j] and a[i-2 , j+1]. If no dependence exists, write “none” across the iteration space diagram. Q(b) 4pts: Fill in at least three dependences edges in the iteration space diagram “(b)” above for any dependence between a[i, j] and a[i+1] [j-2]. If no dependence exists, write “none” across the iteration space diagram. Me! 8 pts: Fill in the table below: references type distance direction loop carried references type distance on any loop? l , w l 017 @ f5 alibi]: ali‘22j+1l glow Or Vélnlf'wié‘ “Mg . . “ m "3" < L 65 “’9 5 \J 4» r E 1* M l Cw x; 9,3 (1m Jc \ w. jaw . l (N l 4} (g mug ‘3 Given the loop nest L2 below: for: 1;z' < 6;i++){ for (j = 1;.7’ < 6;j++){ aliajl = ali-lJl } } ¢(d) 4 pts: Is the 2' loop parallelizable? Why (in 15 words or less) We}; w “(L Q a "Q. 3 (2 ate-$3 C09 9,» r if Ag {jag 4:495:24 a ()(K “(a 6,: C ¢(e) 4pts: Is the j loop parallelizable? Why (in 15 words or less.) V»? ‘5. m. '11 we is mt» led? Cm i r («4? $243“ #4“ Q(e) 4pts: Given the loop nests L3 and L4 below: L3 L4 for(i=1;i<6;i++){ for (i=1;i<6;i++){ for(j=1;j<6;j++){ for(j=1;j<6;j++){ aiixll : aii'l’j'll aiiall : aii-li-j—l—ll } } } Q(f) 4pts: Are the z' and j loops in L3 interchangeable? Why (in 10 words or less)? g \fi I, (41} 3‘\ veg/£19,; 0 "‘ 9i€q§r€fl駀 5? (3%? g R hé‘f 9:; “‘3 ¢(g) 4pts: Are the i and j loops in L4 interchangeable? Why (in 10 words or less)? «1. :3 5M3, §cieeirgneh vac/fag ow “(Z-6 § {3 ‘1) in) Given the loops L5 and L6 below, where L5 runs much faster than L6: L5 L6 f0r(i:1;i<6;i++){ for(i=1;z’<6;i++){ for(j=1;j<6;j++){ for(j:l;j<6;j++){ a[i’j] = aUvil : } l } } Q(h) 4pts: What might be causing the poor performance of loop L6 (20 words or less)? Or remake} e C M“ "y m? l: fine (:1? W m; m O em CI frag a (g. write} a? "x $44? 5164,, (34:54, priemfi {6*} Q(i) 4pts: Given your answer to what is causing the poor performance, what transformation (i.e. optimization) would improve the performance? S? “W {,ng be) "fix 13¢ “3 $473 G1 in? I, i Q r [3%. £121 'E i * If» E “ “(L a ’51 6» 21.6? ‘1 g C} 5‘" a)? p \ he {3-5 {3er \ a m “i” {Z ,1 a n, 5 f 85m:ch Fee we}? ¢(j) 4pts: Will the loop L7 below have better, worse, or the same performance, due to cache effects, as loop L5 above (circle the correct answer)? Say why in 15 words or less. i‘ m s * '“ ”' If! " V i i f‘gé w 08“? Q if £33.; (3 5 pic/[142i- Mn ‘4’! .6 Jim? 45;”? v, f were H E «j ¢(k) 4pts: Will the loop L7 below have better, worse or the same performance, due to cache effects, as loop L5 (circle the correct answer)? Say why in 15 words or less. , l » ‘ F t 7/ Lg, tie”: 69M new, it (:12: (the WWW ¢(l) 4pts: What transformation could improve the performance of L7? (r 5,. Lu. :5 “t we . L7 for = 1,2‘ < 6;i++){ for (j=1;j<6;j++){ aliJl = bljdl } } Question Q? 8 pts: This problem will use the code fragment below: 1. d=a+b 2. a=b+c 3. e=c+d 4. f=e+a 5. g=c*d The table below shows the code generated as statements 1 and 2 are register allocated. There are three registers available: 71, 1’2 and 7‘3, and the variables whose value is in a register is shown in the entry for that register. The 2 z loads z into register rm. The statement 2 = rm spills the contents of register 7% into z. The statement 11) = 2 (X) x performs the operation 2 (X) x and assigns its value into it). If there is a tie on what register to spill, spill the lowest numbered register. Show the code necessary to register allocate statement three. statement 7‘90 3 statement code for statement r1 7‘2 7" 3 r1 = a a 1 7‘2 2 b a b 7‘3 2 T1 ~‘ 7'2 a b d _T_d 2 7'3 a b 2 r3 2 c a b a? " 9? 7‘1 = 7‘2 -— 7’3 at: H: “3:”: a“; :: {Ear-V5: m» (QR) m C H w i m H I a , x V: (:33 m Ram-“63$? éwmg‘t‘” v" if a; a 5 X. , '. r x ‘i i 3 ‘3‘th l ug‘féflg C51 (Jig/“i Cat! ,IJ‘E! 5* Q Hffif’i’ \€. 1 «A 63’ 5‘ “a “g fl Question 0. Given the program: Statement code name p lda q ldb r c:a*b s d=a+c t e=c*b u =d*e x stf Operation Delay 1d, st 3 * 2 + 1 0(a) 7pts : Fill in the precedence graph above. Put the statement name inside of the node for the statement, and put the cumulative delay on the line beside the node. <>(b) 7 pts: In the table below, apply the list scheduling algorithm given in class and in Torczon and Cooper to schedule the code above. In case of a tie use the operation whose name is earliest in the alphabet. Space for extra cycles is provided so do not worry if you do not fill up the table. cycle op scheduled cycle op scheduled (p,q,. - . ,X) (pm - - ,X) 1 Z} 9 5 La. 2 (:3 10 i2 3 11 _—________ ‘25 4 12 5 13 V“ 6 14 7 15 at“: 8 16 J5; Question A 11 pts: Consider the flow graph: Perform a busy variable analysis using this flow graph. A variable is busy if it is read before being written on all paths out of a node. Fill in the GEN, KILL, IN and OUT sets in the table below. Block GEN KILL IN OUT | 1 mi“ WWW viii-w" ‘3: A '2? Wa Luff-1k A x. "4:12 «er wlm rm. Ems mi“ 4' 631m glee/g” {l {we} «as» ~ {Nil We» 45”“! 5‘s WWW—umvwmmwsmm ...
View Full Document

This note was uploaded on 02/19/2012 for the course ECE 468 taught by Professor Test during the Fall '08 term at Purdue.

Page1 / 7

fall09Exam2Key - ECE 468/495S Fall 2009, Second Exam...

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

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