Imagine for example a case where all the elements

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: FORMANCE code/opt/combine.c 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 /* Unroll loop by 3 */ void combine5(vec_ptr v, data_t *dest) { int length = vec_length(v); int limit = length-2; data_t *data = get_vec_start(v); data_t x = IDENT; int i; /* Combine 3 elements at a time */ for (i = 0; i < limit; i+=3) { x = x OPER data[i] OPER data[i+1] OPER data[i+2]; } /* Finish any remaining elements */ for (; i < length; i++) { x = x OPER data[i]; } *dest = x; } code/opt/combine.c Figure 5.19: Unrolling Loop by 3. Loop unrolling can reduce the effect of loop overhead. 5.8. REDUCING LOOP OVERHEAD Execution Unit Operations load (%eax, %edx.0, 4) addl t.1a, %ecx.0c load 4(%eax, %edx.0, 4) addl t.1b, %ecx.1a load 8(%eax, %edx.0, 4) addl t.1c, %ecx.1b addl %edx.0, 3 cmpl %esi, %edx.1 jl-taken cc.1 %edx.0 235 t.1a %ecx.1a t.1b %ecx.1b t.1c %ecx.1c %edx.1 cc.1 addl load %ecx.0c %ecx.i +1 cmpl cc.1 %edx.1 load addl t.1a t.1b t.1c jl load %ecx.1a addl %ecx.1b addl %ecx.1c Figure 5.20: Operations for First Iteration of Inner Loop of...
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