This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ThreeWay Unrolled Integer Addition. With this degree of loop unrolling we can combine three array elements using six integer/branch operations. In general, the vector length will not be a multiple of 3. We want our code to work correctly for arbitrary vector lengths. We account for this requirement in two ways. First, we make sure the ﬁrst loop does not overrun the array bounds. For a vector of length Ò, we set the loop limit to be Ò ¾. We are then assured that the loop will only be executed when the loop index satisﬁes Ò ¾, and hence the maximum array index · ¾ will satisfy · ¾ ´Ò ¾µ · ¾ Ò. In general, if the loop is unrolled by , we set the upper limit to be Ò · ½. The maximum loop index · ½ will then be less than Ò. In addition to this, we add a second loop to step through the ﬁnal few elements of the vector one at a time. The body of this loop will be executed between 0 and 2 times. To better understand the performance of code with loop unrolling, let us look at th...
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.
 Spring '10
 Schultz
 The American, Gulliver's Travels, 2.2.5 2.2.6 2.2.7 2.3 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5

Click to edit the document details