L18 if goto loop 1 2 3 4 5 6 7 instruction 2 reads

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: en) */ void vsum2(int n) { int i; for (i = 0; i < n; i+=2) { /* Compute two elements per iteration */ c[i] = a[i] + b[i]; c[i+1] = a[i+1] + b[i+1]; } } code/opt/vsum.c Figure 5.1: Vector Sum Functions. These provide examples for how we express program performance. 1000 900 800 700 600 Cycles 500 400 300 200 100 0 0 50 100 Ele me nts 150 200 vsum1 Slope = 4.0 vsum2 Slope = 3.5 Figure 5.2: Performance of Vector Sum Functions. The slope of the lines indicates the number of clock cycles per element (CPE). 5.3. PROGRAM EXAMPLE length data 012 length–1 ••• 209 Figure 5.3: Vector Abstract Data Type. A vector is represented by header information plus array of designated length. following error measure: ´ Ñ µ ½ ´ Ò ÑÜ · µ¾ Ý An algorithm for computing Ñ and can be derived by finding the derivatives of and setting them to 0. End Aside. ´ Ñ µ with respect to Ñ and 5.3 Program Example To demonstrate how an abstract program can be systematically transformed into more efficient...
View Full Document

Ask a homework question - tutors are online