Motorola SC140 user manual Split Summation Exercise, Good To Know

Page 16

Compiler Support on StarCore

12.Type next to step through the code.

13.Look at the register contents in the session window and write the values in the Simulator Columns boxes above for both sections.

Congratulations, you have completed Exercise 4.

.

Good To Know

Unaligned data accesses lead to erroneous results.You must consider these issues when developing assembly code.

5 Split Summation Exercise

The split summation exercise shows how to modify C code using the split summation technique to get better parallelization. The split summation technique helps to maximize the multiple-ALU loading by performing arithmetic operations in parallel while requiring little algorithmic or code modifications. To illustrate this technique, the example performs the the optimization of the energy of a signal calculation already considered in Exercise 2. The power calculation is represented in Equation 2:

N – 1

 

y = x2(i) ,

(2)

where x(i) is the signal input sample at iteration i, y is the power of the signal, and N is the signal length. As Exercise 2 shows, computing the signal energy directly from Equation 2 results in the use of only one ALU out of the four with one multiply-accumulate operation performed at each iteration. However, the split summation technique can load all four ALUs. Equation 2 is expanded as follows:

N – 1

 

y = x( i)x(i) + x(i + 1)x(i + 1) + x( i + 2)x(i + 2) + x(i + 3)x(i + 3)

(3)

i = 0, 4, 8, …

 

Equation 3 explicitly highlights the four multiply-accumulate operations that can be performed in parallel. Figure 9 highlights where each parallel execution is represented by Group 0, Group 1, and so on. It also shows that the sample number, i, from one group to the other is incremented by four.

y =

x(i) * x(i) + x(i+1) * x(i+1) + x(i+2) * x(i+2) + x(i+3) * x(i+3)

Group 0 (First cycle)

+

x(i+4) * x(i+4) + x(i+5) * x(i+5) + x(i+6) * x(i+6) + x(i+7) * x(i+7)

Group 1 (Second cycle)

+ ...

Figure 9. Signal Power Calculation Using the Split Summation Technique

16

Introduction to the SC140 Tools

Image 16
Contents Motorola Typical development process is represented in Figure Compiler Hands On File I/O ExerciseGood To Know Integer and Fractional Arithmetic Exercise Interpretation of 16-bit Integer and Fractional Data ValuesCompiler Support on StarCore Integer ArithmeticFractional Arithmetic Good To Know Local Versus Global Optimization Exercise Local OptimizationCompiler Support on StarCore StarCore C Compiler Local Optimization Global OptimizationMemory Alignment Exercise AA BB CC DD First Code Section Second Code Section Split Summation Exercise Code Generated Assembly Code Multi-Sample Exercise = ∑ a i x n For 0 ≤ n LIntermediate Version Compromise Between Memory and Speed Further Speed Optimization Control Code The True Bit Exercise Save Ex7.c as Ex71.c Calling an Assembly Routine From C Exercise Current Following output should be displayed Challenge Solutions to Exercises Introduction to the SC140 ToolsExercise AlignedExpected Motorola INC Intermediate version Compromise between Memory and Speed Compiler Support on StarCore Further Optimizing the Speed Compiler Support on StarCore Compiler Support on StarCore Motorola INC Zoffset equ Moffset equ Exercise Compiler Support on StarCore Compiler Support on StarCore AN2009/D