Compiler Support on StarCore
Hands On
1.Open the Ex5.c file.
2.Build the code with
3.Split the current implementation of the loop (that is, res = L_mac(res, x[i], x[i]);) into four independent equations as represented in Figure 9.
“Independent” means that the four equations are accumulated into different variables. Therefore, create four variables for each product. Tip: Watch your index increment.
4.Recompile the file and run it. The output result should be the same as before.
5.Recompile with the
6.Your code is optimized when the loop is only one cycle and computes four operations at a time.
If the inner loop is equal to one cycle for four operations and the result is still correct, congratulations. You have completed Exercise 5.
7.In the box provided below, write the optimized inner loop code:
C Code
Generated Assembly Code
The split summation technique allows full use of all four ALUs, reducing the cycle time by more than 70 percent relative to use of a single ALU. The
Introduction to the SC140 Tools | 17 |