Roms are distinguished by the number of times they

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: E for the function from Pentium III (really!). Still, they would like to do better. to , measured on an Intel One of the programmers heard about loop unrolling. She generated the following code: 1 2 3 4 5 6 7 8 9 int fact_u2(int n) { int i; int result = 1; for (i = n; i > 0; i-=2) { result = (result * i) * (i-1); } return result; } Unfortunately, the team discovered that this code returns 0 for some values of argument n. A. For what values of n will fact_u2 and fact return different values? B. Show how to fix fact_u2. Note that there is a special trick for this procedure that involves just changing a loop bound. C. Benchmarking fact_u2 shows no improvement in performance. How would you explain that? D. You modify the line inside the loop to read: 7 result = result * (i * (i - 1)); To everyone’s astonishment, the measured performance now has a CPE of ¾ . How do you explain this performance improvement? Homework Problem 5.12 [Category 1]: Using the conditional move instruction, write assembly code for the body of the following function: 5.16. SUMMARY 1 2 3 4 5 271 /* Return maximum of x and y */ int...
View Full Document

This note was uploaded on 09/02/2010 for the course ELECTRICAL 360 taught by Professor Schultz during the Spring '10 term at BYU.

Ask a homework question - tutors are online