At the assembly code level it appears as if

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: ons. As can be seen, this significantly improves the program performance. In general, it is good to get into the habit of enabling this level of optimization, unless the program is being compiled with the intention of debugging it. For the remainder of our measurements we enable this level of compiler optimization. 212 CHAPTER 5. OPTIMIZING PROGRAM PERFORMANCE code/opt/combine.c 1 2 3 4 5 6 7 8 9 10 11 12 13 /* Move call to vec_length out of loop */ void combine2(vec_ptr v, data_t *dest) { int i; int length = vec_length(v); *dest = IDENT; for (i = 0; i < length; i++) { data_t val; get_vec_element(v, i, &val); *dest = *dest OPER val; } } code/opt/combine.c Figure 5.6: Improving the Efficiency of the Loop Test. By moving the call to vec length out of the loop test, we eliminate the need to execute it on every iteration. Note also that the times are fairly comparable for the different data types and the different operations, with the exception of floating-point multiplication. These very h...
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